Download the PHP package oscabrera/laravel-json-api-format-paginate without Composer
On this page you can find all versions of the php package oscabrera/laravel-json-api-format-paginate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-json-api-format-paginate
Laravel JSON:API Format Paginate
Please follow the documentation at laravel-json-api-format-paginate.
This package provides three classes to respond with Resource and Collection in JSON:API format. It simplifies the transformation of Eloquent models and pagination results into JSON compliant responses.
Installation
Install the package via Composer:
In the Model:
Is important use properties $fillable
and $hidden
in your model.
in $hidden
you have to add id
in your model.
In $fillable
you should add all the properties you want to be returned by your model.
Usage
EntityResourceTransformer
EntityResourceTransformer
transforms individual resources into JSON:API format.
Example Result:
JsonApiResourceTransformer
JsonApiResourceTransformer
transforms individual resources into JSON:API format.
Example Result:
Integration with Spatie Packages
For filtering and sorting JSON:API responses, it is recommended to use the following Spatie packages:
-
spatie/laravel-json-api-paginate: To paginate JSON responses Documentation: spatie/laravel-json-api-paginate
- spatie/laravel-query-builder: To build and apply queries. Documentation: spatie/laravel-query-builder
Using the QueryBuilder
To facilitate the use of QueryBuilder, the getFields method is added, which obtains the model columns from the $fillable and $hidden variables, and merges this data. This allows easy use of methods such as allowedFilters, allowedSorts, among others.
example:
More Information
For more information, visit the documentation.
All versions of laravel-json-api-format-paginate with dependencies
laravel/framework Version ^9.0|^10.0|^11.0
spatie/laravel-json-api-paginate Version ^1.14
spatie/laravel-query-builder Version ^6.0