elemenx/laravel-api-pagination is a Laravel package for api pagination for laravel & lumen.
It currently has 2 GitHub stars and 12.610 downloads on Packagist (latest version 0.1.6).
Install it with composer require elemenx/laravel-api-pagination.
Discover more Laravel packages by elemenx
or browse all Laravel packages to compare alternatives.
Last updated
Inspired By Illuminate Pagination, This Package Used For Api Pagination (by limit/offset)
composer require "elemenx/laravel-api-pagination"
On bootstrap/app.php add:
$app->register(ElemenX\ApiPagination\PaginationServiceProvider::class);
use ElemenX\ApiPagination\Paginatable;
class User {
use Paginatable;
}
This is an example for how to use this package.
$users = User::apiPaginate(100); // 100 is your defalut limit number
when you visit with
http://api.dev/user?limit=100&offset=0
It will return Structure As follows.
[
'data' => [
[
'id' => 1,
'name' => 'test'
]
],
'meta' => [
'limit' => 100,
'offset' => 0,
'total' => 1
]
]