{"enrichment":{"faq":[{"a":"Laravel Best Practices recommends organizing your Laravel 13 application by separating concerns across controllers, models, services, and repositories. Follow the framework's conventions for directory structure, use feature-folder organization when appropriate, and implement dependency injection throughout. Adhere to RESTful resource controller patterns, keep business logic in service classes rather than controllers, and use form requests for validation. This architecture ensures scalability and maintainability as your application grows.","q":"What are the key Laravel 13 best practices for application structure?"},{"a":"Laravel Best Practices emphasizes using Eloquent eager loading to prevent N+1 query problems. Load relationships upfront with methods like `with()` or `load()` rather than lazy-loading them in loops. Use `select()` to fetch only needed columns, leverage query scopes for reusable filters, and profile queries with Laravel's query log. Consider pagination for large datasets and use database indexes strategically. These Eloquent optimization techniques significantly improve application performance.","q":"How do you prevent N+1 queries and optimize Eloquent database access?"},{"a":"Laravel Best Practices advocates keeping controllers thin and focused on HTTP concerns\u2014routing requests to appropriate services and returning responses. Models should contain only data relationships and query scopes, not business logic. Service classes encapsulate business rules and complex operations, promoting reusability and testability. Use repositories for data access abstraction when needed, and implement dependency injection to wire these components together cleanly.","q":"What is the proper way to structure controllers, models, and services?"},{"a":"Laravel Best Practices recommends using FormRequest classes to centralize validation logic separate from controllers. Define rules in the `rules()` method, customize messages with `messages()`, and use the `authorize()` method for permission checks. This keeps controllers clean and makes validation reusable across multiple endpoints. Leverage Laravel's built-in validators and custom rule classes for complex validation scenarios, ensuring data integrity before processing.","q":"How should Laravel form request validation and handling be implemented?"},{"a":"Laravel Best Practices emphasizes using the `$fillable` or `$guarded` properties on Eloquent models to control which attributes can be mass-assigned. Always validate user input through form requests before creating or updating models. Implement proper authorization checks using policies and gates, sanitize user data, and use prepared statements through Eloquent to prevent SQL injection. These practices build secure, scalable Laravel applications resistant to common vulnerabilities.","q":"What security measures protect Laravel applications from mass assignment?"},{"a":"Laravel Best Practices recommends designing APIs with clear resource controllers, consistent response formatting, and proper HTTP status codes. Use API resources to transform model data, implement pagination for large datasets, and version your API endpoints when needed. Apply the same architectural principles\u2014service classes, form requests, repositories\u2014to API code. Leverage Laravel's built-in features like API rate limiting, CORS configuration, and token authentication to create secure, scalable APIs.","q":"How do you build scalable and maintainable Laravel API applications?"}],"shadow_tags":["code-organization","database-optimization","api-development","security-patterns","performance-tuning","architectural-design","validation-rules","eloquent-orm","scalability-guide","php-framework"],"summary_rewrite":"Laravel Best Practices is a comprehensive reference for building scalable Laravel 13 applications, covering 31 rules organized across architecture, Eloquent patterns, controllers, validation, security, performance, and API design. Use it when structuring applications, creating models and migrations, implementing form requests, or designing APIs. Includes essential patterns for service classes, repositories, form requests, and Eloquent models."},"files":[{"bytes":9382,"path":"skills/laravel-best-practices/SKILL.md","sha256":"8bf2d5087d2c1b3dd68c1617bae9de52855056797714bb0ec79574ab6ac8b30e","url":"https://skillfed.io/files/AsyrafHussin/agent-skills/laravel-best-practices/87887ba0/SKILL.md"}],"id":"AsyrafHussin/agent-skills/laravel-best-practices","links":{"html":"https://skillfed.io/AsyrafHussin/agent-skills/laravel-best-practices","md":"https://skillfed.io/AsyrafHussin/agent-skills/laravel-best-practices.md","repo":"https://github.com/AsyrafHussin/agent-skills"},"meta":{"agents_supported":[],"first_seen":"2026-07-28","forks":9,"language":null,"last_updated":"2026-05-16","license":"MIT","name":"laravel-best-practices","publisher":"AsyrafHussin","stars":58},"relations":{"similar":[{"id":"rawveg/skillsforge-marketplace/laravel"},{"id":"personamanagmentlayer/pcl/php-expert"},{"id":"Jeffallan/claude-skills/laravel-specialist"},{"id":"iSerter/laravel-claude-agents/eloquent-best-practices"},{"id":"Pixel-Process-UG/superkit-agents/laravel-specialist"},{"id":"affaan-m/ECC/laravel-patterns"},{"id":"AsyrafHussin/agent-skills/laravel-inertia-react"},{"id":"AsyrafHussin/agent-skills/laravel-database-optimization"},{"id":"JustSteveKing/laravel-api-skill/laravel-api"},{"id":"noartem/skills/laravel-api"}]},"slug":{"owner":"AsyrafHussin","repo":"agent-skills","skill":"laravel-best-practices"},"version":"87887ba0"}
