laravel-patterns

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

1|Updated Oct 11, 2025
One-click install
npx skills add https://github.com/ibytechaos/claude --skill laravel-patterns-ibytechaos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-patterns
Source: https://github.com/ibytechaos/claude/tree/main/plugins/everything-claude-code/skills/laravel-patterns
Command: npx skills add https://github.com/ibytechaos/claude --skill laravel-patterns-ibytechaos

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Laravel applications often grow into tangled codebases with fat controllers, inconsistent queries, and N+1 performance problems. This Skill provides production-grade architectural patterns that keep Laravel apps maintainable, testable, and scalable. ## Core Features & Use Cases - Layered Architecture: Structure apps with thin controllers delegating to services and single-purpose action classes, with form request validation and DTOs. - Eloquent Best Practices: Typed models with casts, query scopes, eager loading to avoid N+1 queries, transactions, and global scopes with soft deletes. - API & Infrastructure Patterns: Consistent API resources with pagination, scoped route-model binding for multi-tenant safety, queues, events, caching, and environment-based configuration. - Use Case: When building a multi-tenant Laravel API, apply scoped route bindings to prevent cross-tenant access, wrap multi-step writes in transactions, and return paginated resource responses with a consistent envelope. ## Quick Start Ask the assistant to scaffold a Laravel orders endpoint using thin controllers, an action class, form request validation, and a paginated API resource response.

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 clean architecture?

Keep controllers thin and move orchestration into service classes and single-purpose action classes. Validate input in form requests, convert to DTOs, and return API resources, keeping domain logic in typed Eloquent models.

How to avoid N+1 query problems in Laravel Eloquent?

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

What is scoped route model binding in Laravel?

Scoped bindings enforce that a nested child model belongs to its parent in the route, using Route::scopeBindings(). This prevents cross-tenant access where a user guesses another account's resource IDs.

Should I use global scopes or query scopes in Eloquent?

Use a global scope for filters that should always apply, like excluding archived records, and named query scopes for reusable opt-in filters. Avoid applying both for the same condition 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. Make handlers idempotent with retries and backoff so failed jobs can be safely reprocessed.