承接 stepanenko3/laravel-pagination 相关项目开发

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

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

stepanenko3/laravel-pagination

最新稳定版本:v1.0.4

Composer 安装命令:

composer require stepanenko3/laravel-pagination

包简介

Great pagination generator for Laravel

README 文档

README

Latest Version on Packagist Total Downloads License

Description

Great pagination generator for Laravel

Examples

1, 2, 3, 4, 5, ..., 20

1, ..., 12, 13, 14, ..., 20

1, ..., 16, 17, 18, 19, 20

Requirements

  • php: >=8.0
  • laravel/framework: ^9.0

Installation

# Install the package
composer require stepanenko3/laravel-pagination

Usage

Create your own database builder in app\Builders\BaseBuilder.php

use Stepanenko3\LaravelPagination\Pagination;
use Illuminate\Database\Eloquent\Builder;

class BaseBuilder extends Builder
{
    public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
    {
        $page = $page ?: Pagination::resolveCurrentPage($pageName);
        $perPage = $perPage ?: $this->model->getPerPage();
        $results = ($total = $this->toBase()->getCountForPagination())
            ? $this->forPage($page, $perPage)->get($columns)
            : $this->model->newCollection();

        return new Pagination($results, $total, $perPage, $page, [
            'path' => Pagination::resolveCurrentPath(),
            'pageName' => $pageName,
        ]);
    }
}

Or use without database builder

new Pagination(
    $items,
    $total,
    $perPage,
    $currentPage,
);

Credits

Contributing

Thank you for considering contributing to this package! Please create a pull request with your contributions with detailed explanation of the changes you are proposing.

License

This package is open-sourced software licensed under the MIT license.

统计信息

  • 总下载量: 124.26k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 1
  • 依赖项目数: 5
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

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