Download the PHP package chelout/offset-pagination without Composer
On this page you can find all versions of the php package chelout/offset-pagination. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download chelout/offset-pagination
More information about chelout/offset-pagination
Files in chelout/offset-pagination
Package offset-pagination
Short Description Offset pagination made easy for Laravel
License MIT
Homepage https://github.com/chelout/offset-pagination
Informations about the package offset-pagination
This package provides an offset based pagination already integrated with Laravel's query builder and Eloquent ORM. It calculates the SQL query limits automatically by checking the requests GET parameters, and automatically builds the next and previous urls for you.
Installation
You can install this package via composer using:
The package will automatically register itself.
Config
To publish the config file to config/offset_pagination.php
run:
`
This will publish the following file. You can customize default items per page and maximum items per page.
Basic Usage
Paginating Query Builder Results
``
Paginating Eloquent Results
``
Of course, you may call paginate after setting other constraints on the query, such as where clauses:
``
Or sorting your results:
``
Displaying Pagination Results
Converting to JSON
A basic return will transform the paginator to JSON and will have a result like this:
``
Calling api/v1
will output:
`
Using a Resource Collection
By default, Laravel's API Resources when using them as collections, they will output a paginator's metadata
into links
and meta
.
`
Testing
Run the tests with:
Credits
- Viacheslav Ostrovskiy
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of offset-pagination with dependencies
illuminate/support Version 5.8.*
illuminate/http Version 5.8.*
illuminate/database Version 5.8.*