santigarcor

Santiago Garcia

Verified

@santigarcor

Laravel artisan, scuba diver, and full-stack developer. Crafting code and exploring depths.

1 Answer Joined Mar 2024

/ 255

Hello Santiago. I am using the Laratrust package in my local project. I have created roles, permissions and assigned different permissions to each role. Assigned roles to users. Question, how to check the permissions of an authorized user role?

If you want to check roles you can do this:
$user->hasRole('admin');

If you want to check permissions you can do this:
$user->hasPermission('edit-user');
$user->isAbleTo('edit-user');

For more information, please check this out
laratrust.santigarcor.me/docs/8.x/usage/roles-and-permissions.html#checking-for-roles-permissions