laravel:数组手动分页 --paginate()方法
Posted 多啦C梦
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了laravel:数组手动分页 --paginate()方法相关的知识,希望对你有一定的参考价值。
use IlluminatePaginationLengthAwarePaginator;
use IlluminatePaginationPaginator;
$perPage = 10; //每页显示数量
if ($request->has(‘page‘)) {
$current_page = $request->input(‘page‘);
$current_page = $current_page <= 0 ? 1 :$current_page;
} else {
$current_page = 1;
}
$item = array_slice($Array, ($current_page-1)*$perPage, $perPage);//$Array为要分页的数组
$totals = count($Array);
$paginator =new LengthAwarePaginator($item, $totals, $perPage, $current_page, [
‘path‘ => Paginator::resolveCurrentPath(),
‘pageName‘ => ‘page‘,
]);
return response()->json([‘code‘=> 200,‘msg‘=>‘ok‘,‘data‘=>$paginator]);
---------------------
https://blog.csdn.net/qq_39191303/article/details/80564135
以上是关于laravel:数组手动分页 --paginate()方法的主要内容,如果未能解决你的问题,请参考以下文章