This package provides a custom Serializer for Fractal that transforms data into the API output that we at Pixel Fusion prefer.
To install the latest version of this package run the following command:
composer require pixelfusion/api-serializer
After that you should change the serializer that you want to use to PixelFusion\Fractal\Serializer\ApiSerializer
.
This API serializer extends the default ArraySerializer but has a slight difference. For the pagination we omitted the fields that we don't use. Below is an example of how a response that includes pagination will look like:
{
"data": [
{
"id": "7ywpxp6r",
"title": "The Godfather",
},
{
"id": "q9pykp17",
"title": "Pulp Fiction",
}
],
"pagination": {
"total": 9,
"per_page": 2,
"current_page": 1,
"last_page": 5
}
}