Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

camiant's avatar
Level 18

[ACL spatie/laravel-permission] "can" statement for user's permissions and roles' permissions

Hi, as the title states, is there a blade method or something else to check if a user or the roles assigned to him have a specific permission? I tried with "can", but it only search for permissions among user's ones.

0 likes
4 replies
Lars-Janssen's avatar

@camiant not true it also looks for permissions on the role. Do not forget to run: php artisan cache:forget spatie.permission.cache

mushood's avatar

From the documentation:

You can dump the following to check if the user actually has the right permissions:

// Direct permissions
$user->getDirectPermissions() // Or $user->permissions;

// Permissions inherited from user's roles
$user->getPermissionsViaRoles();

// All permissions which apply on the user
$user->getAllPermissions();
camiant's avatar
Level 18

You're totally right! I apologize for my mistake. Many thanks for your help, lars :)

1 like

Please or to participate in this conversation.