Skill: Craft Query
"Eloquent is a superpower. Don't hide it behind a Repository."
The Standard
- No Repositories: Use Custom QueryBuilders.
- Atomic Methods: Composable (
->pending()->forUser($u)). - Return Self: Always
return $thisfor chaining. - Descriptive Names:
pending(), notwherePending().
The Anti-Patterns
| ❌ Don't | ✅ Do | Why |
|---|---|---|
| Repository pattern | QueryBuilder | Eloquent is already the abstraction |
| One-off scope methods | Reusable builder methods | DRY |
whereStatus('pending') |
pending() |
Semantic clarity |
| Update logic in builder | Actions for mutations | Builders query, Actions mutate |
Real-World Examples
See examples.md.