← ClaudeAtlas

labrodev-enumlisted

Use when creating, reviewing, or naming PHP enums in a Labrodev Laravel project (BookingStatus, ProductType, OrderState — any status/type/mode field with a finite value set), or when wiring an enum across a boundary: label() presentation helpers, Rule::enum validation in Data classes, enum casts in a model's casts(), value + *_label emission in Resources, or EnumMapper select/filter options in ViewModels.
labrodev/laravel-playbook · ★ 0 · AI & Automation · score 73
Install: claude install-skill labrodev/laravel-playbook
# Enums (the full enum contract) Part of the Labrodev playbook. **The law for this component lives in the always-on `labrodev-enum` guideline** (musts, must-nots); the per-file checklist is `rules/enums.md`. This skill holds the craft: anatomy, canonical templates, and edge cases. Enums represent constrained domain values: statuses, types, modes — any field with a finite allowed set and matching logic. When an enum crosses a boundary, the **full enum contract** applies (the law → `labrodev-enum` guideline). Its four parts map onto the sections below: | # | Boundary | Contract | |---|----------|------| | 1 | Enum class | Backed scalar enum, model-prefixed name, `label(): string` wrapping `trans()` | | 2 | Data class (write side) | Typed enum property (implicit Spatie cast) + `Rule::enum(EnumClass::class)` | | 3 | Model (persistence) | Enum cast declared in the `casts()` **method** | | 4 | Frontend (Inertia props) | Resources emit `value` + `*_label` pairs; ViewModels build options via `EnumMapper::keyValues()` | ## 1) Enum anatomy — canonical template Naming pattern: `{Model}{Aspect}` (e.g. `BookingStatus`, `BookingChannel`, `ProductType`), namespace `Core\Domain\{Domain}\Enums`. Full class/method naming rules → see the labrodev-naming skill. ```php <?php declare(strict_types=1); namespace Core\Domain\Booking\Enums; enum BookingStatus: int { case Pending = 1; case Confirmed = 2; case Cancelled = 3; public function label(): string { return