/fuse-laravel:laravel-eloquentfrom fuse-laravel
Provides guidance on Laravel 13 Eloquent ORM with PHP 8.3 Attributes, covering models, relationships, queries, observers, factories, and performance.
Ships in fuse-laravel. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Before ANY implementation, spawn 3 agents in parallel, one Agent call each with a name:
After implementation, run fuse-ai-pilot:sniper for validation.
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 | no attribute — casts() method | protected $casts |
| Appends | #[Appends([...])] | protected $appends |
| Touches | #[Touches([...])] | protected $touches |
| Connection | #[Connection('mysql')] | protected $connection |
| Primary key | #[Table(key: 'uuid', keyType: 'string', incrementing: false)] (#[Table(key: false)] = no primary key, 13.39+) | $primaryKey / $keyType / $incrementing |
| Timestamps off | #[WithoutTimestamps] | public $timestamps = false |
| Refresh after write (13.33+) | #[Refreshes(['slug'])] | — |
#[Fillable], #[Hidden], #[Table] on new code (casts stay in casts())#[Fillable] AND $fillable)with()new static() / new Model() inside the model's own boot() / trait boot*() - Throws LogicException in L13 (nested booting disallowed)app/Models/
├── User.php # #[Table], #[Fillable], #[Hidden] + casts()
├── Post.php # #[Connection], #[Appends], relationships
└── Concerns/
└── HasUuid.php # Reusable trait
→ See templates/ModelBasic.php.md
| Template | When to Use |
|---|---|
| ModelBasic.php.md | Attribute-based model |
| ModelRelationships.php.md | All relationship types |
| ModelCasts.php.md | casts() and accessors |
| Observer.php.md | Complete observer |
| Factory.php.md | Factory with states |
| Resource.php.md | API resource |
| EagerLoadingExamples.php.md | N+1 prevention |
use Illuminate\Database\Eloquent\Attributes\{Table, Fillable, Hidden};
use Illuminate\Database\Eloquent\Model;
#[Table('users')]
#[Fillable(['name', 'email', 'password'])]
#[Hidden(['password', 'remember_token'])]
final class User extends Model
{
protected function casts(): array
{
return ['email_verified_at' => 'datetime', 'is_admin' => 'boolean'];
}
public function posts(): HasMany
{
return $this->hasMany(Post::class);
}
}
#[Scope]
protected function published(Builder $query): void
{
$query->whereNotNull('published_at');
}
// Usage: Post::published()->get();
$posts = Post::with('author')->get(); // 2 queries, not N+1
#[Refreshes(['slug'])] // 13.33+: re-read generated columns after insert/update
final class Post extends Model {}
DB::transaction(function () use ($flight) {
$flight->refreshForUpdate(); // 13.27+: reload with a FOR UPDATE lock
});
→ Legacy $fillable / $hidden style — see legacy-properties.md
#[Table], #[Fillable], #[Hidden], ...)final on model classes when not extendedwith()casts() method (there is no #[Casts] attribute)#[Fillable] and $fillable on the same model (conflict — single source of truth)boot() / trait boot*() — L13 throws LogicException#[Unguarded] in productionreferences/accessors-mutators.md (opens in a new tab)references/aggregates.md (opens in a new tab)references/batch-operations.md (opens in a new tab)references/casts.md (opens in a new tab)references/collections.md (opens in a new tab)references/eager-loading.md (opens in a new tab)references/events-observers.md (opens in a new tab)references/factories.md (opens in a new tab)references/legacy-properties.md (opens in a new tab)references/models.md (opens in a new tab)references/pagination.md (opens in a new tab)references/performance.md (opens in a new tab)references/query-debugging.md (opens in a new tab)references/relationships-advanced.md (opens in a new tab)references/relationships-basic.md (opens in a new tab)references/relationships-many-to-many.md (opens in a new tab)references/relationships-polymorphic.md (opens in a new tab)references/resources.md (opens in a new tab)references/scopes.md (opens in a new tab)references/serialization.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
23 skills in this plugin
/fusecoreUse when creating modules, understanding FuseCore structure, or implementing features in a FuseCore modular-monolith Laravel project./laravel-ai-sdkUse when integrating AI agents, tool calling, embeddings, structured output, or streaming in Laravel 13 via the `laravel/ai` package./laravel-apiUse when creating API endpoints, transforming responses with API Resources, or handling API authentication, rate limiting, or versioning./laravel-architectureUse when structuring a Laravel project, creating services/repositories/actions, implementing dependency injection, or organizing code layers./laravel-attributesUse when migrating Eloquent models, Jobs, Console commands, Controllers, API Resources, Validation, Factories or Seeders to Laravel 13 PHP attributes./laravel-authUse when implementing user authentication, API tokens, social login, or authorization in Laravel 13.npx claudepluginhub fusengine/claude-plugins --plugin fuse-laravelOther plugins' skills for the same job