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.

28 lines
711 B
PHTML

1 year ago
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\Customer;
use Illuminate\Http\Request;
class CustomerController extends Controller
{
public function index(Request $request)
{
$query = Customer::orderBy('updated_at', 'desc');
if ($request->q != '') {
$query->where('name', 'ilike', "%$request->q%")
->orWhere('fullname', 'ilike', "%$request->q%")
->orWhere('username', 'ilike', "%$request->q%");
1 year ago
}
if ($request->levels != '') {
$query->whereHas('level', fn ($q) => $q->whereIn('key', $request->levels));
}
return $query->limit(100)->get();
1 year ago
}
}