laravel-patterns

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

Updated Mar 18, 2026
One-click install
npx skills add https://github.com/freedom909/real-estate-saas --skill laravel-patterns-freedom909
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: laravel-patterns
Source: https://github.com/freedom909/real-estate-saas/tree/main/.trae/skills/laravel-patterns
Command: npx skills add https://github.com/freedom909/real-estate-saas --skill laravel-patterns-freedom909

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Laravel applications often grow into tangled codebases with fat controllers, N+1 query problems, and inconsistent API responses. This Skill provides production-grade architecture patterns that keep Laravel apps structured, maintainable, and scalable. ## Core Features & Use Cases - Layered Architecture Guidance: Enforces thin controllers with orchestration in services and single-purpose actions, plus service container bindings for clean dependency wiring. - Eloquent Best Practices: Covers typed models, custom casts, query scopes, eager loading to avoid N+1 queries, transactions, and migration conventions. - API & Infrastructure Patterns: Standardizes form request validation, API resources with pagination, scoped route-model binding, queues, events, and caching strategies. - Use Case: When building a multi-tenant Laravel API, use this Skill to set up scoped route bindings that prevent cross-tenant access, structure controllers around actions, and return consistent paginated JSON responses. ## Quick Start Ask the AI to scaffold a Laravel orders API using thin controllers, form request validation, Eloquent resources, and scoped route-model binding.

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?▼

Structure Laravel apps with thin controllers that delegate to services and single-purpose actions. Keep domain logic in typed Eloquent models with casts and scopes, and bind interfaces to implementations in a service provider for clear dependency wiring.

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

Avoid N+1 queries in Eloquent by eager loading relationships with the with() method before iterating results. For example, use Order::with(['customer', 'items.product'])->paginate(25) to load all related data in a fixed number of queries.

What is scoped route-model binding in Laravel?▼

Scoped route-model binding enforces parent-child relationships in nested routes, preventing cross-tenant access. Apply Route::scopeBindings() to a route group so a child model like {project} only resolves when it belongs to the parent {account}.

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

Use a global scope for filters that should always apply by default, and named query scopes for reusable opt-in filters. Avoid applying both a global scope and a named scope for the same filter unless you intend layered behavior.

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

Queue jobs for slow or IO-heavy work such as reports, exports, emails, and webhooks so HTTP requests stay fast. Handlers should be idempotent with retries and backoff to tolerate failures safely.