Laravel-permission: How to get all permissions of authorized user

Created on 18 Jul 2018  路  2Comments  路  Source: spatie/laravel-permission

Hello,
first time using spatie permission package. but find problem to get all permissions of log-in user.
i want to know which user has which role/permissions.
I have tried some code listed below but nothing happened & returned empty array. can someone guide me how to do this.
I am using laravel 5.6.
// get a list of all permissions directly assigned to the user
$permissions = $user->permissions;
// get all permissions inherited by the user via roles
$permissions = $user->getAllPermissions();
// get a collection of all defined roles
$roles = $user->getRoleNames(); // Returns a collection

Thanks.

Most helpful comment

// get logged-in user
$user = auth()->user();

// get all inherited permissions for that user
$permissions = $user->getAllPermissions();

dd($permissions);

All 2 comments

// get logged-in user
$user = auth()->user();

// get all inherited permissions for that user
$permissions = $user->getAllPermissions();

dd($permissions);

Shouldn't this be closed! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

enghelewa picture enghelewa  路  4Comments

bhulsman picture bhulsman  路  3Comments

holymp2006 picture holymp2006  路  4Comments

MichalKrakow picture MichalKrakow  路  4Comments

ergonomicus picture ergonomicus  路  3Comments