laravel带条件查询手动分页
后台php代码:
//手动分页 $users = $kaoqin; //打算输出的数组,二维 $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($users, ($current_page-1)*$perPage, $perPage); //注释1 $total = count($users); $paginator =new LengthAwarePaginator($item, $total, $perPage, $current_page, [ 'path' => Paginator::resolveCurrentPath(), //注释2 'pageName' => 'page', ]); $userlist = $paginator->toArray()['data']; return view('web.attendance.groupList',compact('userlist', 'paginator','ary_request'));
前台分页,带条件:
<div class="text-center"> {{ $paginator->appends(request()->input())->links() }} </div>
关键代码:
$paginator->appends(request()->input())->links()
来源出处:http://www.cnblogs.com/yunchuang96/p/7515244.html