当我点击进入第2页时,我会被引导到我网站的主页。不知道为什么。
这是控制器文件中的分页代码:
public function paginate($items, $perPage = 15, $page = null, $options = [])
{
$page = $page ?: (Paginator::resolveCurrentPage() ?: 1);
$items = $items instanceof Collection ? $items : Collection::make($items);
return new LengthAwarePaginator(
$items->forPage($page, $perPage),
$items->count(),
$perPage,
$page,
$options
);
}
在视图文件中:
@if(!isset($_REQUEST['fees'])) {{
$result->appends([
'FeesRange' => request('FeesRange'),
'sortby' => request('sortby'),
'location' => request('location'),
'searchItem' => request('searchItem'),
'searchLocation' => request('searchLocation'),
'criteria' => request('criteria'),
'search' => request('search')
])->links()
}}
@endif
答案 0 :(得分:1)
$options = [
'path' => Paginator::resolveCurrentPath()
]
在paginate
函数的options参数中传递此内容。
示例:
public function paginate($items, $perPage = 15, $page = null)
{
$page = $page ?: (Paginator::resolveCurrentPage() ?: 1);
$items = $items instanceof Collection ? $items : Collection::make($items);
return new LengthAwarePaginator($items->forPage($page, $perPage), $items->count(), $perPage, $page, [
'path' => Paginator::resolveCurrentPath()
]);
}