1.4 KiB
1.4 KiB
Backend — Laravel 10
Module pattern
Every feature lives in app/Modules/<Name>/:
Controllers/<Name>Controller.php— thin: authorize → DTO → action → resourceActions/Create<Name>Action.php— handle(DTO): ModelActions/Update<Name>Action.php— handle(Model, DTO): ModelModels/<Name>.php— Eloquent modelResources/<Name>Resource.php— explicit field list, no$this->resourceDTOs/<Name>Data.php— readonly constructor + staticfromRequest()Requests/Create<Name>Request.php/Update<Name>Request.phpPolicies/<Name>Policy.php
Commands
composer test # Pest, SQLite in-memory
composer static-analysis # pint --test + phpstan + phpmd (all must pass)
php artisan migrate # run migrations (against Docker MySQL)
DB schema
users: id, name, email, password, role(enum:admin|staff), timestampsclients: id, client_number(unique), name, notes(JSON), timestampshistory_entries: id, client_id(FK), type(enum), body(text), author_id(FK), updated_by(FK nullable), deleted_at, timestamps
Auth
- Sanctum SPA cookie sessions —
EnsureFrontendRequestsAreStatefulonapimiddleware group - Filament:
webguard,/admin/login - No Passport, no tokens
API conventions
- Resources always wrap in
datakey (JsonResource default) - Paginated lists:
data[]+meta.totaletc. - 201 on create, 200 on update, 204 on delete