Download the PHP package dvsouto/laravel-json-paginate without Composer
On this page you can find all versions of the php package dvsouto/laravel-json-paginate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dvsouto/laravel-json-paginate
More information about dvsouto/laravel-json-paginate
Files in dvsouto/laravel-json-paginate
Package laravel-json-paginate
Short Description Create json paginate for API in Laravel/Lumen
License MIT
Homepage https://github.com/dvsouto/laravel-json-paginate
Informations about the package laravel-json-paginate
Laravel & Lumen Json Paginate
In a vanilla Laravel application exists the method paginate
in Query Builder (https://laravel.com/docs/7.x/pagination#paginating-eloquent-results), that returns the results formated to front pagination.
This package adds a jsonPaginate
method to the Eloquent query builder that listens the results in json format to use in API and show data in others applications.
Installation
You can install the package via composer:
In Laravel 5.5 and above the service provider will automatically get registered. In older versions of the framework just add the service provider in config/app.php
file:
In Lumen you need to load de service provider on bootstrap/app.php
file:
Usage
To paginate the results prepared to return from API, simply call the jsonPaginate
method.
Of course you may still use all the builder methods you know:
By default the maximum page size is set to 100. You can change this number passing the value to jsonPaginate
.
You also pass the each side parameter to method for generate the page keys.
By default the maximum page size is set to 100. You can change this number passing the value to jsonPaginate
.
This return an array containing thats parameters:
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Spatie Laravel Json Api Paginate
- All Contributors
License
The MIT License (MIT). Please see License File for more information.