laravel search user details by specific role

Solutions on MaxInterview for laravel search user details by specific role by the best coders in the world

showing results for - "laravel search user details by specific role"
Juana
05 Feb 2019
1$search_query = $request->search_query;
2$role = 'Member';
3$results = User::with('roles')->whereHas("roles", function($q) use($role){ 
4            $q->where('title', '=', $role);
5        })->where('name', 'LIKE', "%{$search_query}%")->paginate(4);