Inspired By Illuminate Pagination, This Package Used For Api Pagination (by limit/offset)
- 0.1.6 Fix Wrong Default Limit Value
- 0.1.5 Fix Error When No Data
- 0.1.4 Fix Typo.
- 0.1.3 Fix Scope.
- 0.1.2 Bump Version.
- 0.1.1 Fix Unresolved Dependency.
- 0.1.0 Init Version.
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
]
]