laravel-patterns

Implements Laravel architecture patterns for controllers, Eloquent models, queues, and API resources.

Updated Apr 18, 2026
One-click install
npx skills add https://github.com/JohnRebellion/.claude-public --skill laravel-patterns-johnrebellion
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: laravel-patterns
Source: https://github.com/JohnRebellion/.claude-public/tree/main/claude/skills/laravel-patterns
Command: npx skills add https://github.com/JohnRebellion/.claude-public --skill laravel-patterns-johnrebellion

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Structuring a Laravel application for long-term maintainability is hard: controllers bloat, N+1 queries creep in, and cross-tenant data leaks happen without scoped bindings. This Skill provides production-grade Laravel architecture patterns covering routing, Eloquent, services, queues, caching, and API responses. ## Core Features & Use Cases - Layered Architecture: Keep controllers thin by delegating to services and single-purpose action classes, with form requests handling validation and DTO conversion. - Eloquent Best Practices: Typed casts, query scopes, eager loading to avoid N+1 queries, transactions, global scopes, and soft deletes. - API & Routing Patterns: Scoped route-model binding for multi-tenant safety, resource controllers, consistent JSON responses with pagination metadata. - Use Case: When building a multi-tenant Laravel API, apply scoped bindings like Route::scopeBindings() so a user can never access another account's nested resources, while actions and repositories keep business logic testable. ## Quick Start Ask the AI to review or scaffold your Laravel controller, model, or route structure using these production architecture patterns.

Frequently Asked Questions about laravel-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a Laravel application with controllers and services?▼

Keep controllers thin by delegating orchestration to service classes and single-purpose logic to action classes. Form requests handle validation and convert input to DTOs, while controllers only return API resources as responses.

How to avoid N+1 queries in Laravel Eloquent?▼

Use eager loading with the `with()` method to load relationships upfront, such as `Order::with(['customer', 'items.product'])->paginate(25)`. This fetches related models in a constant number of queries instead of one per record.

What is scoped route model binding in Laravel?▼

Scoped bindings enforce parent-child relationships in nested routes using `Route::scopeBindings()`. This prevents cross-tenant access by ensuring a nested resource like `{project}` actually belongs to the parent `{account}` in the URL.

Should I use global scopes or query scopes in Eloquent?▼

Use a global scope for filters that must always apply, like excluding archived records, and named query scopes for reusable optional filters like `ownedBy($userId)`. Avoid applying both for the same filter unless layered behavior is intended.

When should Laravel jobs be queued instead of run synchronously?▼

Queue IO-heavy or slow work such as report generation, exports, emails, and webhook delivery. Handlers should be idempotent with retries and backoff so failures can be safely reprocessed without duplicate side effects.