承接 agence-adeliom/lumberjack-pagination 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-09-08