agence-adeliom/lumberjack-pagination
最新稳定版本:1.0.57
Composer 安装命令:
composer require agence-adeliom/lumberjack-pagination
包简介
README 文档
README
Implementation of pagination into Lumberjack
Requirements
- PHP 8.0 or greater
- Composer
- Lumberjack
Installation
composer require agence-adeliom/lumberjack-pagination
Usage
Add the trait into your post type
<?php namespace App\PostTypes; use Rareloop\Lumberjack\Post as BasePost; use Adeliom\Lumberjack\Pagination\Pagination; class Post extends BasePost { use Pagination; }
Now your can use it into your controllers
<?php namespace App; use Adeliom\Lumberjack\Pagination\PaginationViewModel; use App\Http\Controllers\Controller; use Rareloop\Lumberjack\Http\Responses\TimberResponse; use App\PostTypes\Post; use Timber\Timber; class IndexController extends Controller { public const RESULTS_PER_PAGE = 10; public function handle(): TimberResponse { global $paged; if (!isset($paged) || !$paged) { $paged = 1; } $context = Timber::get_context(); $context['posts'] = Post::paginate(self::RESULTS_PER_PAGE); $context['pagination'] = PaginationViewModel::fromQueryBuilder(self::RESULTS_PER_PAGE, $paged); return new TimberResponse(['page/index.html.twig'], $context); } }
License
Lumberjack Pagination is released under the MIT License.
统计信息
- 总下载量: 6.4k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-08