Backend How-To Guides
Task-oriented walkthroughs for common backend changes. Each guide cites the real files and patterns in cpr-backend so you can copy the recipe without re-reading the codebase first.
If you are looking for concepts rather than steps, see Design Patterns and Standards instead.
API & Resources
- Add an API CRUD resource — controller, request, resource, service, repository, route, test
- Add a clinical exam module — the per-visit exam pattern (tonometry, biometry, etc.)
- Couple a secondary resource to a primary endpoint — write to two tables from one endpoint (PRP via indirect ophthalmoscopy)
- Avoid Wayfinder route-name collisions — reserved TypeScript names and how to rename
Admin Panel (Inertia)
- Add an Excel export button — Spatie SimpleExcelWriter +
streamDownload - Add an admin CRUD page — controller, Inertia page, route, permission
CLI & Scheduling
- Add an Artisan command — service-backed, dry-run/commit, table output
- Schedule a recurring task —
routes/console.php, overlap + single-server guards
Permissions & Access Control
- Add a permission and grant it to roles —
config/permissions.php, RoleSeeder, route middleware - Gate Inertia admin routes —
permission:middleware + Vue$can()
Data Migration
- Add a legacy-import mapping type — register a new
fkorvaluetarget
Background
- Sentry integration — error tracking and release tagging (existing)
- Pest tests — Pest test runner (existing)
