acadea/collection-paginator
Composer 安装命令:
composer require acadea/collection-paginator
包简介
Laravel Package to paginate any collection
README 文档
README
A helper package to paginate Laravel collections.
About
Learn the idea behind this package:
- Read on my Medium blog: How to Paginate Collection
- or watch it on Youtube
Follow us on Youtube: Acadea.io
Installation
You can install the package via composer:
composer require acadea/collection-paginator
Usage
$collection = collect([1,2,3,4,5,6,7,8]); $pageSize = 4; $paginated = \Acadea\CollectionPaginator\CollectionPaginator::paginate($collection, $pageSize); // .. // in resource controller, returning as an api response return new \Illuminate\Http\JsonResponse($paginated);
Expects:
{
"current_page": 1,
"data": [
1,
2,
3,
4
],
"first_page_url": "http://localhost:8000/api/fruits?page=1",
"from": 1,
"last_page": 2,
"last_page_url": "http://localhost:8000/api/fruits?page=2",
"links": [
{
"url": null,
"label": "Previous",
"active": false
},
{
"url": "http://localhost:8000/api/fruits?page=1",
"label": 1,
"active": true
},
{
"url": "http://localhost:8000/api/fruits?page=2",
"label": 2,
"active": false
},
{
"url": "http://localhost:8000/api/fruits?page=2",
"label": "Next",
"active": false
}
],
"next_page_url": "http://localhost:8000/api/fruits?page=2",
"path": "http://localhost:8000/api/fruits",
"per_page": 4,
"prev_page_url": null,
"to": 4,
"total": 8
}
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 265
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-18