You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
419 B
PHP
19 lines
419 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
use App\Models\Category;
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
|
|
class CategoriesQuery extends Controller
|
|
{
|
|
public function __invoke(Request $request)
|
|
{
|
|
if ($request->q != null) {
|
|
return Category::where('name', 'like', '%'.$request->q.'%')->limit(10)->get();
|
|
}
|
|
return Category::limit(10)->get();
|
|
}
|
|
}
|