/laravel-eloquent
Use when working with database models — Eloquent ORM, PHP attributes, relationships, queries, observers, or factories in Laravel 13.
$ npx -y skills add fusengine/agents --skill laravel-eloquent --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/laravel-eloquent
Context preview
The summary Claude sees to decide when to auto-load this skill.
Use when working with database models — Eloquent ORM, PHP attributes, relationships, queries, observers, or factories in Laravel 13.
SKILL.md
laravel-eloquent.SKILL.mdname: laravel-eloquent
description: Use when working with database models — Eloquent ORM, PHP attributes, relationships, queries, observers, or factories in Laravel 13.
versions:
laravel: "13.0"
php: "8.3"
user-invocable: true
references: references/legacy-properties.md, references/models.md, references/relationships-basic.md, references/relationships-many-to-many.md, references/relationships-advanced.md, references/relationships-polymorphic.md, references/eager-loading.md, references/scopes.md, references/casts.md, references/accessors-mutators.md, references/events-observers.md, references/soft-deletes.md, references/collections.md, references/serialization.md, references/factories.md, references/performance.md, references/resources.md, references/transactions.md, references/pagination.md, references/aggregates.md, references/batch-operations.md, references/query-debugging.md, references/templates/ModelBasic.php.md, references/templates/ModelRelationships.php.md, references/templates/ModelCasts.php.md, references/templates/Observer.php.md, references/templates/Factory.php.md, references/templates/Resource.php.md, references/templates/EagerLoadingExamples.php.md
related-skills: laravel-attributes, laravel-migrations, laravel-api, laravel-testing
<objective> Covers Laravel 13 Eloquent ORM with PHP 8.3 Attributes as the primary metadata mechanism (#[Table], #[Fillable], #[Hidden], #[Visible], #[Guarded], #[Casts], #[Appends], #[Touches], #[Connection]) alongside legacy property equivalents for backward compatibility. Includes all relationship types (basic, many-to-many, advanced, polymorphic), eager loading, scopes, accessors/mutators, events/observers, soft deletes, collections, serialization, factories, API resources, transactions, pagination, aggregates, batch operations, and query debugging/performance. </objective>
Laravel Eloquent ORM (L13 — Attributes-first)
Agent Workflow (MANDATORY)
Before ANY implementation, use `TeamCreate` to spawn 3 agents:
1. **fuse-ai-pilot:explore-codebase** - Inspect existing models, mixed property/attribute usage 2. **fuse-ai-pilot:research-expert** - Verify Laravel 13 Eloquent + Attributes docs via Context7 3. **mcp__context7__query-docs** - Query attribute patterns (#[Fillable], #[Casts], #[Scope])
After implementation, run **fuse-ai-pilot:sniper** for validation.
---
Overview
Laravel 13 promotes **PHP 8.3 Attributes** as the primary metadata mechanism on Eloquent models. Legacy properties (`$fillable`, `$hidden`, ...) remain supported for backward compatibility but should not be mixed with their attribute counterparts.
| Feature | Attribute (L13 MAIN) | Legacy property | |---------|---------------------|-----------------| | Table name | `#[Table('users')]` | `protected $table` | | Mass assignment | `#[Fillable([...])]` | `protected $fillable` | | Hidden / Visible | `#[Hidden([...])]` / `#[Visible([...])]` | `protected $hidden` / `$visible` | | Guarded | `#[Guarded([...])]` / `#[Unguarded]` | `protected $guarded` | | Casts | `#[Casts([...])]` | `casts()` method | | Appends | `#[Appends([...])]` | `protected $appends` | | Touches | `#[Touches([...])]` | `protected $touches` | | Connection | `#[Connection('mysql')]` | `protected $connection` |
---
Critical Rules
1. **Attributes are the source of truth** - Use `#[Fillable]`, `#[Casts]`, `#[Hidden]` on new code 2. **Never mix attribute + property** for the same concern (`#[Fillable]` AND `$fillable`) 3. **Eager load relationships** - Prevent N+1 queries with `with()` 4. **No `new Model()` in `boot()`** - Throws `LogicException` in L13 (booted lifecycle protected) 5. **Use factories** in tests - Never hardcode test data
---
Architecture
app/Models/
├── User.php # #[Table], #[Fillable], #[Hidden], #[Casts]
├── Post.php # #[Connection], #[Appends], relationships
└── Concerns/
└── HasUuid.php # Reusable trait→ See [templates/ModelBasic.php.md](references/templates/ModelBasic.php.md)
---
Reference Guide
Concepts
- **Migration L12→L13:** [legacy-properties.md](references/legacy-properties.md)
- **Modeling:** [models.md](references/models.md) · [casts.md](references/casts.md) · [accessors-mutators.md](references/accessors-mutators.md) · [serialization.md](references/serialization.md) · [soft-deletes.md](references/soft-deletes.md)
- **Relationships:** [relationships-basic.md](references/relationships-basic.md) · [relationships-many-to-many.md](references/relationships-many-to-many.md) · [relationships-advanced.md](references/relationships-advanced.md) · [relationships-polymorphic.md](references/relationships-polymorphic.md)
- **Querying:** [eager-loading.md](references/eager-loading.md) · [scopes.md](references/scopes.md) · [aggregates.md](references/aggregates.md) · [pagination.md](references/pagination.md) · [batch-operations.md](references/batch-operations.md) · [query-debugging.md](references/query-debugging.md)
- **Lifecycle / Output:** [events-observers.md](references/events-observers.md) · [collections.md](references/collections.md) · [resources.md](references/resources.md) · [factories.md](references/factories.md) · [transactions.md](references/transactions.md) · [performance.md](references/performance.md)
Templates
| Template | When to Use | |----------|-------------| | [ModelBasic.php.md](references/templates/ModelBasic.php.md) | Attribute-based model | | [ModelRelationships.php.md](references/templates/ModelRelationships.php.md) | All relationship types | | [ModelCasts.php.md](references/templates/ModelCasts.php.md) | #[Casts] and accessors | | [Observer.php.md](references/templates/Observer.php.md) | Complete observer | | [Factory.php.md](references/templates/Factory.php.md) | Factory with states | | [Resource.php.md](references/templates/Resource.php.md) | API resource | | [EagerLoadingExamples.php.md](references/templates/EagerLoadingExamples.php.md) | N+1 prevention |
---
Quick Reference
#
Read more
name: laravel-eloquent description: Use when working with database models — Eloquent ORM, PHP attributes, relationships, queries, observers, or factories in Laravel 13. versions: laravel: "13.0" php: "8.3" user-invocable: true references: references/legacy-properties.md, references/models.md, references/relationships-basic.md, references/relationships-many-to-many.md, references/relationships-advanced.md, references/relationships-polymorphic.md, references/eager-loading.md, references/scopes.md, references/casts.md, references/accessors-mutators.md, references/events-observers.md, references/soft-deletes.md, references/collections.md, references/serialization.md, references/factories.md, references/performance.md, references/resources.md, references/transactions.md, references/pagination.md, references/aggregates.md, references/batch-operations.md, references/query-debugging.md, references/templates/ModelBasic.php.md, references/templates/ModelRelationships.php.md, references/templates/ModelCasts.php.md, references/templates/Observer.php.md, references/templates/Factory.php.md, references/templates/Resource.php.md, references/templates/EagerLoadingExamples.php.md related-skills: laravel-attributes, laravel-migrations, laravel-api, laravel-testing
<objective> Covers Laravel 13 Eloquent ORM with PHP 8.3 Attributes as the primary metadata mechanism (#[Table], #[Fillable], #[Hidden], #[Visible], #[Guarded], #[Casts], #[Appends], #[Touches], #[Connection]) alongside legacy property equivalents for backward compatibility. Includes all relationship types (basic, many-to-many, advanced, polymorphic), eager loading, scopes, accessors/mutators, events/observers, soft deletes, collections, serialization, factories, API resources, transactions, pagination, aggregates, batch operations, and query debugging/performance. </objective>
Laravel Eloquent ORM (L13 — Attributes-first)
Agent Workflow (MANDATORY)
Before ANY implementation, use `TeamCreate` to spawn 3 agents:
1. **fuse-ai-pilot:explore-codebase** - Inspect existing models, mixed property/attribute usage 2. **fuse-ai-pilot:research-expert** - Verify Laravel 13 Eloquent + Attributes docs via Context7 3. **mcp__context7__query-docs** - Query attribute patterns (#[Fillable], #[Casts], #[Scope])
After implementation, run **fuse-ai-pilot:sniper** for validation.
---
Overview
Laravel 13 promotes **PHP 8.3 Attributes** as the primary metadata mechanism on Eloquent models. Legacy properties (`$fillable`, `$hidden`, ...) remain supported for backward compatibility but should not be mixed with their attribute counterparts.
| Feature | Attribute (L13 MAIN) | Legacy property | |---------|---------------------|-----------------| | Table name | `#[Table('users')]` | `protected $table` | | Mass assignment | `#[Fillable([...])]` | `protected $fillable` | | Hidden / Visible | `#[Hidden([...])]` / `#[Visible([...])]` | `protected $hidden` / `$visible` | | Guarded | `#[Guarded([...])]` / `#[Unguarded]` | `protected $guarded` | | Casts | `#[Casts([...])]` | `casts()` method | | Appends | `#[Appends([...])]` | `protected $appends` | | Touches | `#[Touches([...])]` | `protected $touches` | | Connection | `#[Connection('mysql')]` | `protected $connection` |
---
Critical Rules
1. **Attributes are the source of truth** - Use `#[Fillable]`, `#[Casts]`, `#[Hidden]` on new code 2. **Never mix attribute + property** for the same concern (`#[Fillable]` AND `$fillable`) 3. **Eager load relationships** - Prevent N+1 queries with `with()` 4. **No `new Model()` in `boot()`** - Throws `LogicException` in L13 (booted lifecycle protected) 5. **Use factories** in tests - Never hardcode test data
---
Architecture
app/Models/
├── User.php # #[Table], #[Fillable], #[Hidden], #[Casts]
├── Post.php # #[Connection], #[Appends], relationships
└── Concerns/
└── HasUuid.php # Reusable trait→ See [templates/ModelBasic.php.md](references/templates/ModelBasic.php.md)
---
Reference Guide
Concepts
- **Migration L12→L13:** [legacy-properties.md](references/legacy-properties.md)
- **Modeling:** [models.md](references/models.md) · [casts.md](references/casts.md) · [accessors-mutators.md](references/accessors-mutators.md) · [serialization.md](references/serialization.md) · [soft-deletes.md](references/soft-deletes.md)
- **Relationships:** [relationships-basic.md](references/relationships-basic.md) · [relationships-many-to-many.md](references/relationships-many-to-many.md) · [relationships-advanced.md](references/relationships-advanced.md) · [relationships-polymorphic.md](references/relationships-polymorphic.md)
- **Querying:** [eager-loading.md](references/eager-loading.md) · [scopes.md](references/scopes.md) · [aggregates.md](references/aggregates.md) · [pagination.md](references/pagination.md) · [batch-operations.md](references/batch-operations.md) · [query-debugging.md](references/query-debugging.md)
- **Lifecycle / Output:** [events-observers.md](references/events-observers.md) · [collections.md](references/collections.md) · [resources.md](references/resources.md) · [factories.md](references/factories.md) · [transactions.md](references/transactions.md) · [performance.md](references/performance.md)
Templates
| Template | When to Use | |----------|-------------| | [ModelBasic.php.md](references/templates/ModelBasic.php.md) | Attribute-based model | | [ModelRelationships.php.md](references/templates/ModelRelationships.php.md) | All relationship types | | [ModelCasts.php.md](references/templates/ModelCasts.php.md) | #[Casts] and accessors | | [Observer.php.md](references/templates/Observer.php.md) | Complete observer | | [Factory.php.md](references/templates/Factory.php.md) | Factory with states | | [Resource.php.md](references/templates/Resource.php.md) | API resource | | [EagerLoadingExamples.php.md](references/templates/EagerLoadingExamples.php.md) | N+1 prevention |
---
Quick Reference
#
Showing the first part of this file.
A plugin ecosystem that turns Claude Code into a supervised, multi-agent development environment.
Repo: fusengine/agents
Other skills on fusengine-agents.
- /agent-creator
Use when creating expert agents. Generates agent.md with frontmatter, hooks, required sections, and skill references.
Open skill - /apex-methodology
Use when starting ANY development task -- feature, bug fix, refactor, hotfix (triggers: implement, create, build, fix, add feature, refactor, develop).
Open skill - /brainstorming
Use when creating a feature/component or adding functionality. Fires BEFORE APEX Analyze to refine requirements via structured questioning.
Open skill - /challenge
Use before a root-cause, done/verified claim, irreversible action, or 2nd-time fix reaches the owner (APEX or plain conversation); also fires at every eLicit/Verify gate. Not for code correctness (use sniper).
Open skill - /code-quality
Use when validating code quality after modifications -- SOLID compliance, DRY duplication, linter errors, architecture violations. Do NOT use for functional verification (run verification FIRST, then code-quality).
Open skill - /elicitation
Use when an expert agent self-reviews and self-corrects code after the Execute phase, before sniper validation (BMAD-METHOD elicitation techniques).
Open skill

