This is the documentation for
v2 but the latest version is
v5
.
You can switch versions in the menu on the left/at the top.
Check your current version with the following command:
composer show spatie/laravel-permission
It is generally best to code your app around permissions
only. That way you can always use the native Laravel @can
and can()
directives everywhere in your app.
Roles can still be used to group permissions for easy assignment, and you can still use the role-based helper methods if truly necessary. But most app-related logic can usually be best controlled using the can
methods, which allows Laravel's Gate layer to do all the heavy lifting.