nathan
nathan

Reputation: 163

How to get groups belonging to user Cartalyst Sentry 2

What is the best way to get the Sentry Groups my USER model belongs to in Laravel 4.1?

I couldn't find anything in the docs about this.

Upvotes: 2

Views: 3789

Answers (2)

mbarlund
mbarlund

Reputation: 116

The Sentry docs are pretty bare bones. You can do this to get the groups belonging to a user:

$user = User::findOrFail($id);

$user->getGroups();

foreach($user->groups as $group)
{
     echo $group->name;
}

Upvotes: 10

ManiacTwister
ManiacTwister

Reputation: 321

According to the sentry docs perform the getGroups() Method on the user.

Upvotes: 2

Related Questions