agentsclimarketplace

Laravel eloquent

Skill fusengine/agents/plugins/laravel-expert/skills/laravel-eloquent

Redefining development through cognitive automation and collaborative agent systems.

Install
npx -y skills add fusengine/agents --skill laravel-eloquent

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 22 stars22 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Complete Eloquent ORM for Laravel 13 - PHP Attributes (#[Table], #[Fillable], #[Casts]), models, relationships, queries, observers, factories. Use when working with database models.

SKILL.md

6.8 KB, ~1.4k tokens by cl100k_base, as published. Nobody here has run it

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.

FeatureAttribute (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


Reference Guide

Concepts

Templates

TemplateWhen to Use
ModelBasic.php.mdAttribute-based model
ModelRelationships.php.mdAll relationship types
ModelCasts.php.md#[Casts] and accessors
Observer.php.mdComplete observer
Factory.php.mdFactory with states
Resource.php.mdAPI resource
EagerLoadingExamples.php.mdN+1 prevention

Quick Reference

Attribute-based Model (L13 MAIN)

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 (attribute syntax)

#[Scope]
protected function published(Builder $query): void
{
    $query->whereNotNull('published_at');
}
// Usage: Post::published()->get();

Eager Loading

$posts = Post::with('author')->get();  // 2 queries, not N+1

→ Legacy $fillable / $hidden style — see legacy-properties.md


Best Practices

DO

  • Declare metadata with PHP Attributes (#[Table], #[Fillable], #[Casts], ...)
  • Use final on model classes when not extended
  • Eager load with with()
  • Use factories in tests
  • Cast dates, arrays, enums via #[Casts]

DON'T

  • Mix #[Fillable] and $fillable on the same model (conflict — single source of truth)
  • Instantiate models in boot() / booted() — L13 throws LogicException
  • Lazy-load relationships in loops (N+1)
  • Use #[Unguarded] in production
  • Query inside accessors / mutators
  • Put business logic in models (use Services/Actions)

Gives 0 of the 12 instructions most databases sql skills give in ~1.4k tokens

Counted across 589 of the 662 authors here whose files we hold, read 2026-08-06

  • use parameterized queriesin 36 of 589, across 32 files
  • use timestamptz for timestampsin 30 of 589, across 12 files
  • create indexes concurrentlyin 29 of 589, across 23 files
  • index foreign keysin 28 of 589, across 17 files
  • use numeric type for moneyin 25 of 589, across 8 files
  • select only required columnsin 24 of 589, across 19 files
  • use cursor pagination instead of OFFSETin 23 of 589, across 15 files
  • add indexes manually on foreign key columnsin 22 of 589, across 11 files
  • read individual rule files for detailed explanationsin 18 of 589, across 4 files
  • configure connection poolingin 18 of 589, across 16 files
  • put equality columns before range columns in indexesin 17 of 589, across 9 files
  • normalize to third normal formin 17 of 589, across 8 files

Said here and by no other author read

  • spawn exploration agents before implementation
  • declare model metadata using php attributes
  • use final on non-extended model classes
  • cast dates arrays and enums via casts
  • run validation after implementation

Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.