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.
30 lines
592 B
PHP
30 lines
592 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Category;
|
|
use Illuminate\Http\Request;
|
|
|
|
class CategoryController extends Controller
|
|
{
|
|
public function index(Request $request)
|
|
{
|
|
$query = Category::query();
|
|
|
|
if ($request->q) {
|
|
$query->where('name', 'like', "%{$request->q}%");
|
|
}
|
|
|
|
if ($request->except_id) {
|
|
$query->where('id', '!=', $request->except_id);
|
|
}
|
|
|
|
if ($request->all == 1) {
|
|
return $query->get();
|
|
}
|
|
|
|
return $query->get();
|
|
}
|
|
}
|