laravel user role relationship code example
Example: get user with role laravel
$students = User::whereHas(
'roles', function($q){
$q->where('name', 'Teacher');
}
)->get();
$students = User::whereHas(
'roles', function($q){
$q->where('name', 'Teacher');
}
)->get();