Laravel-permission: Get role name from user.

Created on 9 Aug 2017  路  3Comments  路  Source: spatie/laravel-permission

Can you tell me how to get roles name from users model?

Thanks before.

Most helpful comment

You can pluck them from the roles.

$user->roles->pluck('name');

All 3 comments

You can pluck them from the roles.

$user->roles->pluck('name');

Since v2.5.1 you can use $user->getRoleNames(), which returns a collection of role names associated with that user.
And then you can access that collection using all the normal collection methods.

Can you tell me how to get roles name from Auth User while loing

Thanks before.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MichalKrakow picture MichalKrakow  路  4Comments

bbdangar picture bbdangar  路  4Comments

feliperoan picture feliperoan  路  3Comments

Dreambox13 picture Dreambox13  路  3Comments

antweny picture antweny  路  4Comments