ezavalishin/laravel-jsonapi-paginator

0.1.3 2020-10-22 22:15 UTC

This package is auto-updated.

Last update: 2024-10-23 06:30:35 UTC


README

Latest Version on Packagist Total Downloads StyleCI Codecov Travis (.com)

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.