Closed constantinosergiou closed 2 years ago
e.g
$query = Search::new() ->add(User::select('*')->with('Role')->access($request) ->selectRaw('(SELECT roles.name FROM roles, role_users WHERE users.id = role_users.user_id AND role_users.role_id = roles.id LIMIT 1) as rolename') ->groupBy('id'), ['first_name', 'last_name']) ->paginate(\Request::get('per_page') ?: 30)->search($request['query']);
i want to filter roles also so when i am doing this
if ($request['roles']) { $query->orwhereHas('Role', function ($q) use ($request) { $q->whereIn('role_id', $request['roles']); }); }
i get this error
"message": "Method Illuminate\\Database\\Eloquent\\Collection::orwhereHas does not exist.",
e.g
i want to filter roles also so when i am doing this
i get this error