Collections
Returning a data collection from the controller:Paginators
It is also possible to provide a paginator:Transforming Empty Objects
When creating a new model, you probably want to provide a blueprint to the frontend with the required data to create a model:Default Values
You can provide default values in the constructor:empty call:
Response Status Code
When a resource is returned from a controller, the status code will automatically be set to201 CREATED when Laravel Data detects that the request’s method is POST. In all other cases, 200 OK will be returned.
Resource Classes
To make it clearer that a data object is a resource, you can use theResource class instead of the Data class:
Resource classes won’t validate data or check authorization. They are only used to transform data which makes them faster.