plugins/laravel-expert/skills/laravel-eloquent/SKILL.md
Complete Eloquent ORM for Laravel 13 - PHP Attributes (#[Table],
npx skillsauth add fusengine/agents laravel-eloquentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Before ANY implementation, use TeamCreate to spawn 3 agents:
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 | #[Casts([...])] | casts() method |
| Appends | #[Appends([...])] | protected $appends |
| Touches | #[Touches([...])] | protected $touches |
| Connection | #[Connection('mysql')] | protected $connection |
#[Fillable], #[Casts], #[Hidden] on new code#[Fillable] AND $fillable)with()new Model() in boot() - Throws LogicException in L13 (booted lifecycle protected)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, Casts};
use Illuminate\Database\Eloquent\Model;
#[Table('users')]
#[Fillable(['name', 'email', 'password'])]
#[Hidden(['password', 'remember_token'])]
#[Casts(['email_verified_at' => 'datetime', 'is_admin' => 'boolean'])]
final class User extends Model
{
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
→ Legacy $fillable / $hidden style — see legacy-properties.md
#[Table], #[Fillable], #[Casts], ...)final on model classes when not extendedwith()#[Casts]#[Fillable] and $fillable on the same model (conflict — single source of truth)boot() / booted() — L13 throws LogicException#[Unguarded] in productiondevelopment
Use when optimizing entity-based / semantic SEO 2026. Covers entity maps, Google Knowledge Graph resolution, salience scoring, passage-level ranking, about/sameAs/knowsAbout schema, Cloud Natural Language API validation.
development
Use when running SEO, GEO, schema, Core Web Vitals, sitemap, hreflang, E-E-A-T, AI Overviews, technical SEO, or structured data tasks. Covers full-site audits, single-page analysis, schema markup, content quality, AI search optimization, local SEO, sitemap/robots, internal linking, semantic clustering, and search experience.
development
Use when optimizing search experience (SXO). Covers intent matching, user personas, user stories, page-type analysis, dwell time, scroll depth, pogo-sticking prevention.
development
Use when optimizing local SEO. Covers Google Business Profile, NAP consistency, citations, reviews acquisition, Local Pack ranking, location pages, LocalBusiness schema.