← ClaudeAtlas

labrodev-authorizationlisted

Use when creating or reviewing authorization in a Labrodev Laravel project: writing a {Model}Policy class, defining permission constants, wiring #[UsePolicy] on a model, adding #[Authorize] to an invokable controller, or deciding how any endpoint checks who may view/create/update/remove a resource.
labrodev/laravel-playbook · ★ 0 · API & Backend · score 73
Install: claude install-skill labrodev/laravel-playbook
# Authorization: Policies, #[UsePolicy], #[Authorize] Part of the Labrodev playbook. **The law for this component lives in the always-on `labrodev-authorization` guideline** (musts, must-nots); the per-file checklist is `rules/policies.md`. This skill holds the craft: anatomy, canonical templates, and edge cases. Authorization is one cluster with three pieces that must always be wired together: 1. **Policy** — `final class {Model}Policy` in `Core/Domain/{Domain}/Policies/`, answering "may this user perform this action on this object?" in business terms. 2. **Model wiring** — `#[UsePolicy({Model}Policy::class)]` attribute on the model class. 3. **Controller wiring** — class-level `#[Authorize(...)]` attribute on every invokable controller. ## The constant contract (critical) The permission constant's **value** is the string the Gate uses to find the policy method: ```php public const string PERMISSION_VIEW = 'view'; // resolves to view() public const string PERMISSION_UPDATE = 'update'; // resolves to update() ``` `#[Authorize(BookingPolicy::PERMISSION_UPDATE, 'booking')]` only works because `'update'` is a method on `BookingPolicy`. Two distinct string universes exist and must never be mixed: | String | Universe | Where it lives | |---|---|---| | `'view'`, `'update'` | Gate ability = policy method name | Constant values; `#[Authorize]` arguments | | `'booking.bookings.view'` | Dotted RBAC permission key (e.g. spatie/laravel-permission) | **Inside** method bodies o