1
我正在使用Laravel分页脚本。我想在LengthAwarePaginator中添加每页下拉选择,这样我可以根据脚本中的页面选择列出所有条目。 我的脚本:如何使用Laravel在LengthAwarePaginator中添加下拉页面选择
public function index(Request $request){
$data = [];
$keyword = request('keyword','');
$applicationData = $this->ppObjAdmin->getBackOfficeApplications(['keyword' =>$keyword]);
$paginate =10;
$pageStart = request('page', 1);
$offSet = ($pageStart * $paginate) - $paginate;
$itemsForCurrentPage = array_slice($applicationData,$offSet, $paginate);
$journeyListData = new LengthAwarePaginator($itemsForCurrentPage , count($applicationData) , $paginate , Paginator::resolveCurrentPage() , ['path' => Paginator::resolveCurrentPath()]);
$data['journeyData'] = $journeyListData;
$data['searchKeyword'] = $keyword;
return view('admin.listing',$data);
}
下拉HTML:
<select class="page_limit pgination-select" onchange="page_limit(this)">
<option value="10" >10 Entries per page</option>
<option value="20 " >20 Entries per page</option>
<option value="30 " >30 Entries per page</option>
<option value="50">50 Entries per page</option>
</select>
</div>`enter code here`
请参见附件链接问题显示更加清晰。 http://prntscr.com/guto00
请在此脚本中选择下拉帮助。
在此先感谢!
但分页底页上仍存在 所有记录没有显示 http://prntscr.com/gut3r5 –
好的,实际上你不必切片你的数组,只要确保它是一个集合,所以你可以分页。看看我编辑的答案是否有帮助。 –
谢谢你的回答有帮助。问题解决了。 –