定制 a-dob/preview-paginator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

a-dob/preview-paginator

Composer 安装命令:

composer require a-dob/preview-paginator

包简介

Laravel pagination with different size for first page (preview-paginator)

README 文档

README

This package allows you to add a local scope to your Model.
The Pagination class implements the Illuminate\Pagination\AbstractPaginator contract and it is similar to the basic simplePaginate method.

Installation

composer require a-dob/preview-paginator

Add PreviewPaginated trait to models

Add Adob\PreviewPaginator\PreviewPaginated trait to your model you want to paginate

use Illuminate\Database\Eloquent\Model;
use Adob\PreviewPaginator\PreviewPaginated;

class Post extends Model
{
    use PreviewPaginated;

    protected $initialQuantity = 2;
    
    protected $perPage = 5;

The $initialQuantity property sets the number of returned models on the first page by default.

The $perPage property sets the number of returned models on the remaining pages by default.

Usage

You may paginate Eloquent queries. In this example, we will paginate the App\Models\User model and indicate that we plan to display 5 records on first page and 15 records on the remaining pages. As you can see, the syntax is nearly identical to paginating query builder results:

use App\Models\User;

$users = User::previewPaginate(5, 15);

Of course, you may call the previewPaginate method after setting other constraints on the query, such as where clauses:

$users = User::where('votes', '>', 100)->previewPaginate(5, 15);

You may also use the previewPaginate method when paginating Eloquent models:

$users = User::where('votes', '>', 100)->previewPaginate(5, 15);

The first argument of the previewPaginated method specifies the number of returned models on the first page.

The second argument of the previewPaginated method specifies the number of returned models on the remaining pages.

If null is passed as the first argument, the initial quantity will be defined from the specified model property. If this property is not defined in the model the initial quantity will be 5

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-07-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固