$search_query = $request->search_query; $role = 'Member'; $results = User::with('roles')->whereHas("roles", function($q) use($role){ $q->where('title', '=', $role); })->where('name', 'LIKE', "%{$search_query}%")->paginate(4);