laravel-modern-patterns
Skill4 starsChanged 5 months agoMITView on GitHub
Laravel 8+ architecture patterns including Repository + Action pattern, Sanctum API authentication, Eloquent relationships, and service layer design. Use for Laravel backend development, API design, authentication implementation, or database modeling.
In this repository101 other files it gives its agents.
- ai-video-understandingSkill
- apple-foundation-modelsSkill
- arch-dddSkill
- arch-decision-recordsSkill
- arch-diagramsSkill
- arch-eventsSkill
- arch-mvp-roadmapSkill
- arch-python-modernSkill
- aws-app-runnerSkill
- aws-cicd-patternsSkill
- aws-security-hardeningSkill
- azure-functions-python-v2Skill
- azure-identity-m2m-authSkill
- azure-service-bus-messagingSkill
- azure-workflow-execution-modelsSkill
- caddy-tls-proxySkill
- compliance-frameworksSkill
- design-system-workflowSkill
- dev-debugging-strategiesSkill
- dev-standardsSkill
- docker-python-poetrySkill
- docker-pythonSkill
- fastapi-patternsSkill
- ffmpeg-laravel-videoSkill
- formik-yup-react-nativeSkill
- frontend-accessibilitySkill
- frontend-angular-aiSkill
- frontend-angularSkill
- frontend-angular-toolingSkill
- frontend-design-systemsSkill
- frontend-material-chatSkill
- frontend-material-design-3Skill
- frontend-svelteSkill
- gcp-cicd-patternsSkill
- gcp-cloud-runSkill
- gcp-cloudsql-infrastructureSkill
- gcp-finopsSkill
- gcp-observabilitySkill
- gcp-security-hardeningSkill
- github-actions-cicdSkill
- healthkit-biofeedbackSkill
- infra-terraformSkill
- ios-app-qualitySkill
- ios-audio-hapticsSkill
- jest-nestjs-testingSkill
- langchain-azure-openai-patternsSkill
- laravel-auth-hardeningSkill
- laravel-ci-mysqlSkill
- laravel-mix-webpackSkill
- laravel-pint-patternsSkill
- laravel-s3-storageSkill
- laravel-sail-dockerSkill
- mobile-app-deploymentSkill
- mobile-e2e-testingSkill
- mobile-offline-syncSkill
- mobile-push-notificationsSkill
- mobile-video-uploadSkill
- mongodb-asyncmongoclient-patternsSkill
- mongodb-atlas-patternsSkill
- nestjs-patternsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 58
Verify signature against raw body (getContent()).
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Laravel 8+ Modern Architecture Patterns
Clean architecture patterns for Laravel 8+ applications using Repository + Action pattern, Sanctum authentication, and Eloquent best practices.
Architecture Layers
Controller → FormRequest (validation)
→ Action (business logic)
→ Repository (data access)
→ Model (Eloquent)
→ API Resource (transformation)Pattern Decision Matrix
| Pattern | Use Case | Example |
| Action | Single-purpose operation | SaveItemAction, ProcessPaymentAction |
| Service | Multi-step orchestration | OrderService (create order + email + log) |
| Job | Async/queued work | SendEmailJob, ProcessVideoJob |
| Repository | Data access abstraction | UserRepository, ShapeRepository |
Socialite OAuth + Sanctum Tokens
->stateless() skips session/CSRF for API clients; ->plainTextToken returns the storable string; revoke via currentAccessToken()->delete(). See reference.md → "Sanctum SPA Authentication".
Status Event Pattern
Append-only _status_events table for audits; enum column on the parent for simple toggles. Query current status via latestOfMany() (Laravel 8.42+); record transitions via an Action class. Index on (parent_id, id DESC).
Domain-Organized Controllers
Group by business domain with Route::prefix(). Use ->shallow() to avoid 4-ID URLs; ->scoped() (Laravel 9+) for automatic parent-child binding.
FormRequest as Security Boundary
->validated() strips unallowed keys (mass-assignment safety); authorize() returning true is correct when upstream middleware already enforces auth. See reference.md → "FormRequest as Security Boundary" for the skeleton with nested-array rules (reviews.*.author_user_id).
Mass-Assignment Tripwire
Model::create([...]), firstOrCreate, and seed-time mass-assignment silently drop keys not in $fillable with no warning. Post-create direct assignment ($m->field = $val; $m->save()) is the safe path for privilege-gated fields. See reference.md → "Mass-Assignment Tripwire".
Variadic Role Middleware
role:Admin,Owner syntax via string ...$roles, strict in_array(..., true) to prevent type-juggling, ordered after auth:sanctum so unauthenticated requests get 401 before role returns 403. See reference.md → "Variadic Role Middleware".
Webhook Handler Discipline
Verify signature against raw body (getContent()); wrap idempotency-row creation and the handler in one transaction; partition errors into permanent (200) vs transient (500). See reference.md → "Webhook Idempotency: Atomic Pattern".
Common Pitfalls
See reference.md → "Common Pitfalls" for the full anti-pattern table (30+ entries covering N+1, mass-assignment, enum migrations, polymorphic controllers, Larastan findings, Pint idempotency, and more).
Eloquent Relationships Quick Guide
hasMany/belongsTo for one-to-many; belongsToMany for pivot tables; hasManyThrough for two-hop relations. Always eager-load with with(['relation']) to prevent N+1. See reference.md → "Eloquent Relationships" for strategies including nested eager loading, withCount, and soft deletes.
Constant-Owned Validation-Rule Accessor
Expose static rule(): In on enum/const classes alongside values() — callers write MyConst::rule() instead of Rule::in(MyConst::values()), eliminating the Illuminate\Validation\Rule import from every FormRequest and preventing N-way allow-list duplication across Store/Update/Import requests. See reference.md → "Constant-Owned Validation-Rule Accessor" for the skeleton.
Wildcard field.* Rules Are Per-Present-Element
field.* rules fire only for elements present in the payload — sometimes on the .* key is a no-op. Array-level PATCH semantics (sometimes, nullable) belong on the field key; element-level rules need no presence guard. See reference.md → "Wildcard field.* Rules" for the disambiguation table and the common reviewer false-positive this closes.
JSON Column: Lock Write and Filter Vocabulary
Diverging stored vs. queried strings make whereJsonContains silently match nothing. Lock both the write FormRequest rules and the query filter to one validated constant so stored and filtered values are byte-identical. See reference.md → "Free-Form Storage Behind an Exact-Match JSON Filter".
PHP 8.1+ Spread on Associative Arrays
...$assocArray throws "unknown named parameters" on PHP 8.1+ when the array has string keys. Wrap with array_values() before spreading or replace with an explicit foreach + array_push. See reference.md → "PHP 8.1+ Spread on Associative Arrays".
See reference.md for detailed patterns, configuration, and testing strategies. See examples.md for complete CRUD implementations and real code examples.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

