laravel-models

Installation
SKILL.md

Laravel models

Covers everything that defines or exposes a domain model: the Eloquent model itself, its custom Builder and Filter, its migration, and the rule that its public reference is always the ULID identifier — never the numeric id.

1. Models

  • Use the HasIdentifier trait so a ULID identifier column acts as the route key.

  • Use Laravel's HasBuilder trait when a model has a custom query builder.

  • Add SoftDeletes to most models.

  • Define a casts() method for enum/DTO casting (preferred over the $casts property).

  • Because HasIdentifier overrides getRouteKeyName() to return 'identifier', route definitions resolve URL parameters to models via the ULID column automatically (the route-side syntax lives in laravel-routing).

  • After creating or changing a model, run:

    php artisan ide-helper:models --write-mixin --reset --ansi
    

    to refresh _ide_helper_models.php.

  • Always start Eloquent queries from Model::query() so chained methods (->withTrashed(), ->select(), ->where(), …) line up neatly:

Installs
4
First Seen
May 6, 2026
laravel-models — glamorous/coding-skills