3

How can I get all users related to user roles by Sentinel? And how can I get all users in Sentinel? This does not work:

Sentinel::all()
kryger
  • 12,906
  • 8
  • 44
  • 65
yigitozmen
  • 947
  • 4
  • 23
  • 42

1 Answers1

6

You can try this to get all users related to a specific role.

$role = Sentinel::findRoleById(1);
// or findRoleBySlug('admin'); for example
$users = $role->users()->with('roles')->get();

and you can access the first user (and so on and so forth like this)

dd($users[0]['attributes']);

and to get all users you can do this:

$test = Sentinel::getUserRepository();
dd($test);
Jesse Newman
  • 146
  • 1
  • 8