Eloquent model patterns and database layer. Use when working with models, database entities, Eloquent ORM, or when user mentions models, eloquent, relationships, casts, observers, database entities.
Detected risks:
The 'laravel-models' skill provides guidance on implementing and working with Eloquent models and database layers in Laravel applications. It addresses essential patterns for interacting with models, defining relationships, casting data types, and simplifying database operations using Laravel's ORM (Object-Relational Mapping). This skill is especially valuable for developers who need to manage complex database structures and interactions in an efficient and readable manner, following Laravel’s conventions and best practices.
You can define custom query builders by overriding the 'newEloquentBuilder' method in your model. This method allows you to return a custom builder class that extends the base Eloquent builder functionality, giving you the ability to add custom query logic.
You can use a variety of cast types such as 'integer', 'float', 'boolean', 'array', 'json', 'date', 'datetime', 'timestamp', and more. You can also define custom casts or use classes for enums and DTOs.
No, business logic should not reside in models. Models should focus on database interactions, while business logic belongs in dedicated Action classes.
Quick Setup:
.claude/skills/Repository
leeovery/claude-laravel