LengthAwarePaginator 手动分页
$page # 这里获取时 根据 $total 判断限制下
$total = 50;
$perPage = 10;
$users = $users->where(...)->paginate($page);
$users = new LengthAwarePaginator(
$users->items(),
$users->total() < $total ? $users->total() : $total,
$perPage,
$page,
[
'path' => url()->current() # 可选 分页URL不完整时 按需添加
]
);
# LengthAwarePaginator 参数
$items,
$total ,
$perPage,
$currentPage = null,
array $options = []
Paginator 手动分页
# 该方法 对查询的结果(一次性取出大量数据) 在分页; 数据量大时 不建议使用
# 比如 $users->where(...)->limit(1000)->paginate($page);