Minimal Resource
Hook Reference
init(): void (required)
Declare data properties with $this->addProperty(...). The constructor is final — all setup happens here.
getIdentifierProperty(): AbstractProperty (required)
The property used for view / update / delete path parameters (/animals/{animal_uuid}) and the resource’s identity in response bodies.
Use UUID-typed identifiers (StringProperty) rather than integer IDs to comply with the framework’s REST naming standards.
getBaseUrl(): string (required)
The URL prefix used by Route::resource() when building paths. Example: /api/v1 produces /api/v1/animals, /api/v1/animals/{animal_uuid}.
getName(): string (required)
Singular resource name. Used in descriptions (“Create animal”), OpenAPI response names, generated request class names (e.g. AnimalListRequest), and plural URL derivation.
getPluralName(): string (optional)
Defaults to getName() . 's'. Override for irregular plurals:
excludeFromMode(string $mode): array (required)
Return an array of property names to exclude from a given mode. Typical uses:
- Hide
passwordfrom every response. - Hide
weightfrom list responses only. - Exclude
created_at/updated_atfrom create bodies because the server sets them.
AbstractResource: MODE_CREATE, MODE_VIEW, MODE_UPDATE, MODE_DELETE, MODE_LIST.
availableFilters(): FilterInterface[]
Declare filters exposed on the list endpoint. Use the typed filter builders from Router\Route\Filter\:
$request->filtering()->status.
availableSortings(): Sort[]
Declare sortable fields for the list endpoint:
?order_by=... that isn’t in this list is rejected by the validation middleware with a 422.