yigitozmen
yigitozmen

Reputation: 957

Getting all Sentinel user related to roles

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()

Upvotes: 3

Views: 4535

Answers (1)

Jesse Newman
Jesse Newman

Reputation: 146

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);

Upvotes: 6

Related Questions