AI SummaryAdvanced Eloquent ORM patterns for performance and query reuse. Use when working with Eloquent relationships, scopes, or advanced query optimization in Laravel. (triggers: app/Models/**/*.php, scope, with, eager, chunk, model)
Install
Copy this and paste it into Claude Code, Cursor, or any AI assistant:
I want to install the "laravel-eloquent" skill in my project. Please run this command in my terminal: # Install skill into your project (2 files) mkdir -p .claude/skills/laravel-eloquent && curl --retry 3 --retry-delay 2 --retry-all-errors -o .claude/skills/laravel-eloquent/SKILL.md "https://raw.githubusercontent.com/HoangNguyen0403/agent-skills-standard/develop/skills/laravel/laravel-eloquent/SKILL.md" && mkdir -p .claude/skills/laravel-eloquent/references && curl --retry 3 --retry-delay 2 --retry-all-errors -o .claude/skills/laravel-eloquent/references/implementation.md "https://raw.githubusercontent.com/HoangNguyen0403/agent-skills-standard/develop/skills/laravel/laravel-eloquent/references/implementation.md" Then restart Claude Code (or reload the window in Cursor) so the skill is picked up.
Description
Advanced Eloquent ORM patterns for performance and query reuse. Use when working with Eloquent relationships, scopes, or advanced query optimization in Laravel. (triggers: app/Models/**/*.php, scope, with, eager, chunk, model)
Structure
`text app/ └── Models/ ├── {Model}.php └── Scopes/ # Advanced global scopes `
Implementation Guidelines
• N+1 Prevention: Always use with() or $with for relationships. • Eager Loading: Set strict loading via Eloquent::preventLazyLoading(). • Reusable Scopes: Define scopeName methods for common query filters. • Mass Assignment: Define $fillable and use $request->validated(). • Performance: Use chunk(), lazy(), or cursor() for large tasks. • Casting: Use $casts for dates, JSON, and custom types.
Anti-Patterns
• N+1 Queries: No lazy loading: Never query relationships in loops. • Fat Models: No business logic: Models are for data access only. • Magic Queries: No raw SQL: Use Query Builder or Eloquent. • Select \*: No excessive data: Select only required columns.
References
• Eloquent Performance Guide
Discussion
Health Signals
My Fox Den
Community Rating
Sign in to rate this booster