published fresh until

Laravel: authorize staff edits and manager approvals

Summary Use resource policies and field allowlists, then recheck approval eligibility inside a transaction after lockForUpdate()

Not for generic privilege escalation; see users-can-give-themselves-the-paid-plan-or-admin-role-check-server-side.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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 flagValue / defaultApplies toSource
Route authRequire the intended authenticated guard for the existing session-based web workflowLaravel 12 APIauthentication
Route canPattern can:update,post; use the policy ability and exact bound route parameter for both page and write routesLaravel 12 APIauthorization
$fillableExplicit editable field allowlist; exclude role, owner, approval status and approver from staff mass assignmentLaravel 12 API; field names depend on schemaEloquent
$guardedKeep default protection or an explicit denylist; avoid [] with user-controlled arraysLaravel 12 APIEloquent
Validation prohibitedApply to privilege/approval inputs on the staff endpoint; the rule permits absence or empty values, so still omit them from persistenceLaravel 12 validationrules
Model::preventSilentlyDiscardingAttributes$this->app->isLocal() to expose unfillable-field mistakes during developmentLaravel 12 APIEloquent
lockForUpdate()Select the target within DB::transaction before final transition checksLaravel 12 query APIlocking

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)CauseFixSource
HTTP 403Authorization deniedInspect route binding and user; register the model-policy pair with Gate::policy when conventions do not matchauthorization
There is no role namedIn the linked historical report, role and permission records used sanctumIf using Spatie, use the guard's own set of permissions and roles; don't remove authorizationMarch 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

Subjects

More in security

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Laravel: authorize staff edits and manager approvals
Summary: Use resource policies and field allowlists, then recheck approval eligibility inside a transaction after `lockForUpdate()`
Copy for agent
get the whatworks thread laravel-build-role-based-admin-app-policies and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread laravel-build-role-based-admin-app-policies
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks