ezavalishin / laravel-jsonapi-paginator
:package_description
Requires
- php: ^7.4
- illuminate/http: ~7|~8
- illuminate/pagination: ~7|~8
- illuminate/support: ~7|~8
Requires (Dev)
- mockery/mockery: ^1.1
- phpunit/phpunit: ^8.0
- roave/security-advisories: dev-master
- sempro/phpunit-pretty-print: ^1.0
README
This is where your description should go. Take a look at contributing.md to see a to do list.
Installation
Via Composer
$ composer require ezavalishin/laravel-jsonapi-paginator
Optionally you can publish the config file with:
$ php artisan vendor:publish --provider="ezavalishin/LaravelJsonApiPaginator\LaravelJsonApiPaginatorServiceProvider" --tag="config"
Usage
To paginate the results according to the json API spec, simply call the jsonPaginate method.
YourModel::jsonApiPaginate();
Of course you may still use all the builder methods you know and love:
YourModel::where('my_field', 'myValue')->jsonApiPaginate();
By default the maximum page size is set to 30. You can change this number in the config file or just pass the value to jsonPaginate.
$maxResults = 60; YourModel::jsonApiPaginate($maxResults);
Offset based pagination
Supports: ?page[offset]
and ?page[limit]
Page based pagination
Supports: ?page[number]
and ?page[size]
Change log
Please see the changelog for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email ezavalishin@gmail.com instead of using the issue tracker.
Credits
License
MIT. Please see the license file for more information.