我想在Laravel中使用LengthAwarePaginator对数组进行分页。
当我尝试在页面之间导航时,laravel会显示以下错误:
NotFoundHttpException in RouteCollection.php line 161
这是我的代码:
//$queries1 is an array.
$currentPage = LengthAwarePaginator::resolveCurrentPage();
$collection = new Collection($queries1);
$currentPageSearchResults = $collection->slice($currentPage * 5, 5)->all();
$paginatedSearchResults= new LengthAwarePaginator($currentPageSearchResults, count($collection), 5);
//configure Path
$paginatedSearchResults->setPath(App::getLocale().'/activity/search_Activity');
return view(App::getLocale().'.activities.ActivityResults', ['results' => $paginatedSearchResults]);
如果我没有设置路径,则分页链接会自动重定向到' /'
可能会发生什么?
感谢您的帮助