q != '') { $query->where('name', 'like', "%$request->q%") ->orWhere('fullname', 'like', "%$request->q%") ->orWhere('username', 'like', "%$request->q%"); } if ($request->levels != '') { $query->whereHas('level', fn ($q) => $q->whereIn('key', $request->levels)); } return $query->limit(100)->get(); } }