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.
// get logged-in user
$user = auth()->user();
// get all inherited permissions for that user
$permissions = $user->getAllPermissions();
dd($permissions);
Shouldn't this be closed! :)
Most helpful comment