laravel-models
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.
Security Assessment
Detected risks:
About laravel-models
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.
FAQ
How do I define custom query builders for models?
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.
What types of casts can I use for model attributes?
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.
Can I add business logic inside Eloquent models?
No, business logic should not reside in models. Models should focus on database interactions, while business logic belongs in dedicated Action classes.
Install laravel-models
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
leeovery/claude-laravel