Design a Laravel REST API: 10 levels of resource controllers, API Resources, validation and auth. An advanced Laravel REST design game.
In REST, each thing an app keeps (one task, the task list) is a resource with its own address, and the action travels in the HTTP method. The designs in this game write :id as Express does; Laravel writes that changing part as {id}.
200 OK answers with a body, 201 Created means a new resource exists (RFC 9110 asks for a Location header pointing to it), 204 No Content means success with no body. The same answer shape at every window makes it easy for the app to read.
A nested resource shows a parent and child relation: posts that belong to one resident. Laravel can register nested routes from one line, and with shallow() only the list and creating stay nested.
Signing in and out change state, so they are sent with POST. A route inside the auth:sanctum middleware refuses a request with no valid token with 401, and Laravel answers a failed validation with 422 and a message per field.
One shop uses everything so far: resource names, nested resources, status codes, filters in the query string, and the auth:sanctum middleware for what belongs to a user.