What this thread does
Do first: protect the workflow routes with auth, then authorize each record transition through a policy before writing approval fields.
Short answer
As of November 2026, this card targets Laravel 12 (support/release table). Staff may edit eligible owned records; managers may approve eligible records belonging to someone else. Those are application rules, not built-in Laravel roles. Enforce them on GET and mutation routes, then repeat state-sensitive checks under a database lock.
Choose / don't choose
- Policy: choose for a resource's view, update and approve decisions, including owner and tenant constraints.
- Gate: choose for a manager dashboard without a particular record. Don't let a dashboard gate replace per-record authorization.
- Role package: choose only when stored permission administration is required; a simple workflow can use core policies and an application-controlled role field (authorization).
Not for: diagnosing generic client-side privilege escalation; see users-can-give-themselves-the-paid-plan-or-admin-role-check-server-side.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
Route auth | Require the intended authenticated guard for the existing session-based web workflow | Laravel 12 API | authentication |
Route can | Pattern can:update,post; use the policy ability and exact bound route parameter for both page and write routes | Laravel 12 API | authorization |
$fillable | Explicit editable field allowlist; exclude role, owner, approval status and approver from staff mass assignment | Laravel 12 API; field names depend on schema | Eloquent |
$guarded | Keep default protection or an explicit denylist; avoid [] with user-controlled arrays | Laravel 12 API | Eloquent |
Validation prohibited | Apply to privilege/approval inputs on the staff endpoint; the rule permits absence or empty values, so still omit them from persistence | Laravel 12 validation | rules |
Model::preventSilentlyDiscardingAttributes | $this->app->isLocal() to expose unfillable-field mistakes during development | Laravel 12 API | Eloquent |
lockForUpdate() | Select the target within DB::transaction before final transition checks | Laravel 12 query API | locking |
Order of operations
1. Authenticate and perform coarse route authorization. Validate only the endpoint's editable fields; use validated() or explicit selected values. If the authorize method returns false, HTTP 403 is returned and the controller method will not execute (validation). 2. Start DB::transaction, re-fetch the record in the caller's tenant scope with lockForUpdate(), then re-authorize the transition against that locked record. Require manager permission, pending status, and different submitter/approver identities. This sequence is application design derived from Laravel locking; the framework does not supply an approval state machine (queries). 3. Set server-owned approval fields explicitly and persist the transition plus its audit record atomically. A repeated decision must return the existing outcome or a deliberate conflict without another mutation. 4. Commit before triggering external effects. Exceptions within the transaction closure roll back the transaction; the documented attempts: 5 retries deadlocks, so keep retried transaction bodies free of non-idempotent remote calls (transactions). 5. Exercise guest, staff owner, other staff, manager and self-approval requests directly; denied writes must leave data unchanged. Submit concurrent decisions and inspect the final record/audit count.
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
| HTTP 403 | Authorization denied | Inspect route binding and user; register the model-policy pair with Gate::policy when conventions do not match | authorization |
There is no role named | In the linked historical report, role and permission records used sanctum | If using Spatie, use the guard's own set of permissions and roles; don't remove authorization | March 11, 2023 report, guard documentation |
Missing
- Exact workflow states, tenancy rules and role storage are application inputs. The Spatie report is historical evidence of guard confusion, not a core-policy regression.
Checked
2026-11-12; Laravel 12 (release table); linked authentication, authorization, validation, Eloquent, query/transaction docs and Spatie report/guide read. No Artisan or database commands executed.
Started from a post by @Laravel, packaged by the editor. Original post