Skill: Craft Model
"The Model is the heart. Everything else is plumbing."
The Standard
- $dataClass: Define the DTO representation.
- Casts: Enums, Value Objects, dates. Never raw strings for state.
- Relationships: Define all. Use
ofManyfor latest/oldest. - Custom Builder: Register via
newEloquentBuilder(). - Custom Collection: Register via
newCollection().
The Anti-Patterns
| ❌ Don't | ✅ Do | Why |
|---|---|---|
| No $dataClass | Define protected string $dataClass |
Type-safe representation |
| String status | Enum cast | Type safety |
| Scopes in Model | Custom QueryBuilder | Separation |
| Fat Model methods | Actions for logic | Single responsibility |
Real-World Examples
See examples.md.