laravel-eloquent

Design and optimize Laravel Eloquent models, relationships, and query patterns.

Updated Feb 3, 2026
One-click install
npx skills add https://github.com/krlmrr/laravel-playground --skill laravel-eloquent-krlmrr
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-eloquent
Source: https://github.com/krlmrr/laravel-playground/tree/main/.claude/skills/laravel-eloquent
Command: npx skills add https://github.com/krlmrr/laravel-playground --skill laravel-eloquent-krlmrr

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Laravel developers often struggle with structuring Eloquent models, relationships, and query optimization, leading to boilerplate code and suboptimal queries.

Core Features & Use Cases

  • Model design and relationships: Define hasMany, belongsTo, and morph relationships with proper typing.
  • Query optimization: Implement local/global scopes, eager loading, and efficient query construction.
  • Tooling and maintenance: Use accessors/mutators, casts, and model events to enforce domain logic and data integrity.

Quick Start

Create a Laravel Eloquent Post model with a hasMany relationship to Comment and a local scope for published posts.

Frequently Asked Questions about laravel-eloquent

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize Laravel Eloquent queries to prevent N+1 problems?

Optimize Laravel Eloquent queries by applying eager loading strategies to automatically fetch relationships and prevent the N+1 problem. This Skill enforces eager loading and efficient query construction standards to ensure robust database access without redundant queries.

What is the best way to define relationships in Laravel Eloquent models?

Define Laravel Eloquent relationships like hasMany, belongsTo, and morphs with proper type hints on relation methods. This approach structures domain logic and enforces typing standards when creating or refactoring Eloquent models.

How do I use local and global scopes in Laravel for query filtering?

Use local and global scopes in Laravel to encapsulate query constraints for filtering. This Skill automates implementing these scopes to standardize query construction and maintain consistent query optimization across applications.

Can I use accessors, mutators, and casts to enforce domain logic in Eloquent?

Yes, you can enforce domain logic and data integrity in Eloquent by using accessors, mutators, and casts. This Skill applies these tooling and maintenance features alongside model events to automate robust data formatting.

When should I refactor Laravel models to use morph relationships?

Refactor Laravel models to use morph relationships when a single model needs to belong to multiple other model types. This Skill automates defining polymorphic relations and refactoring models to maintain proper typing and structural integrity.