MichaelJennings / eloquent-paginator
为Laravel Eloquent添加一个新的分页方法,该方法在分页时保留选择语句
v1.0
2018-07-12 10:24 UTC
Requires
- illuminate/database: ^5.1
- illuminate/pagination: ^5.1
Requires (Dev)
- orchestra/testbench: ^3.6
This package is auto-updated.
Last update: 2024-09-06 09:02:26 UTC
README
Eloquent很棒,但偶尔会遇到在使用分页时带有子句的问题。
此包向Eloquent构建器添加了一个新方法,该方法在分页时保留选择语句。
安装
使用composer require michaeljennings/eloquent-paginator
通过composer安装,或者将包添加到composer.json
文件中的require部分。
"require": {
...
"michaeljennings/eloquent-paginator": "^1.0"
}
然后运行composer update
来安装包。
使用方法
使用paginate
时,请使用paginateWithSelects
代替。
$query->paginate(15); $query->paginateWithSelects(15);
由于我们保留了查询中的选择查询,因此您不能像使用标准paginate
方法那样指定列。
然而,如果需要,您仍然可以指定分页器名称和货币页面。
$query->paginateWithSelects(15, 'foo', 2);