laravel-permission-development
Installation
SKILL.md
Laravel Permission Development
When to use this skill
Use this skill when working with authorization, roles, permissions, access control, middleware guards, or Blade permission directives using spatie/laravel-permission.
Core Concepts
- Users have Roles, Roles have Permissions, Apps check Permissions (not Roles).
- Direct permissions on users are an anti-pattern; assign permissions to roles instead.
- Use
$user->can('permission-name')for all authorization checks (supports Super Admin via Gate). - The
HasRolestrait (which includesHasPermissions) is added to User models.
Setup
Add the HasRoles trait to your User model:
use Spatie\Permission\Traits\HasRoles;