laravel get users with given role code example
Example 1: get users of specific role laravel role spatie
$users = User::role('writer')->get();
Example 2: get user with role laravel
$students = User::whereHas(
'roles', function($q){
$q->where('name', 'Teacher');
}
)->get();