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

NattananWs picture NattananWs  路  3Comments

notflip picture notflip  路  3Comments

ghost picture ghost  路  3Comments

bhulsman picture bhulsman  路  3Comments

vpratfr picture vpratfr  路  4Comments