Essential session storage is required to sign in. Optional analytics remain off unless you allow them.
Build a REST API with Laravel over a small domain (a store, an issue tracker, a library). Requirements: model the domain with relationships; expose it via API RESOURCES (JsonResource / ResourceCollection) on routes/api.php; authenticate with SANCTUM (token or SPA) and gate writes with a policy or middleware; query Eloquent EFFICIENTLY — filter with query scopes and AVOID N+1 by eager loading with with() (and use withPivot/withTimestamps if you read pivot data); add pagination (->paginate()); and write feature tests ($this->getJson/postJson + assertJson/assertDatabaseHas) using factories. Explain one place with() removed an N+1.
API Resources shape consistent JSON on api.php routes; pagination configured; RESTful structure.
Sanctum auth gating writes; a documented N+1 removed with eager loading (with()); pivot data read correctly if used.
Feature tests (getJson/postJson + assertions) with factories cover a success and an error/auth case.
Use this README structure to make the work reviewable.
DevPath fetches a read-only, size-capped snapshot. Submitted code is never executed.
# A JSON API with Sanctum & efficient Eloquent ## Goal Build a REST API with Laravel over a small domain (a store, an issue tracker, a library). Requirements: model the domain with relationships; expose it via API RESOURCES (JsonResource / ResourceCollection) on routes/api.php; authenticate with SANCTUM (token or SPA) and gate writes with a policy or middleware; query Eloquent EFFICIENTLY — filter with query scopes and AVOID N+1 by eager loading with with() (and use withPivot/withTimestamps if you read pivot data); add pagination (->paginate()); and write feature tests ($this->getJson/postJson + assertJson/assertDatabaseHas) using factories. Explain one place with() removed an N+1. ## Acceptance criteria - [ ] API & resources: API Resources shape consistent JSON on api.php routes; pagination configured; RESTful structure. - [ ] Sanctum & Eloquent efficiency: Sanctum auth gating writes; a documented N+1 removed with eager loading (with()); pivot data read correctly if used. - [ ] Tests: Feature tests (getJson/postJson + assertions) with factories cover a success and an error/auth case. ## Verification - [ ] Document installation and run commands. - [ ] Record automated checks and their exact commands. - [ ] Add representative output, screenshots, or a short demo where useful. - [ ] Confirm failure paths and known constraints. ## Decision log ### Decision title - Context: - Choice: - Alternatives considered: - Tradeoffs: ## Evidence - Link each rubric criterion to the file, test, or artifact that demonstrates it. ## Known limitations - List what is intentionally out of scope and what should be improved next.