1

我想在 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]);

如果我不设置路径,分页的链接,自动重定向到'/'

会发生什么?

感谢帮助

4

0 回答 0