Php 在Laravel网站上分页重定向到主页

Php 在Laravel网站上分页重定向到主页,php,laravel,laravel-5,pagination,Php,Laravel,Laravel 5,Pagination,当我点击进入第2页时,我会直接进入我网站的主页。不知道为什么 以下是控制器文件中的分页代码: public function paginate($items, $perPage = 15, $page = null, $options = []) { $page = $page ?: (Paginator::resolveCurrentPage() ?: 1); $items = $items instanceof Collection ? $items : Collection

当我点击进入第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
paginate
函数的选项参数中传递此参数

例如:

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()
    ]);
}

在web.php中尝试Route::any,也可以发布paginator生成的HTML吗?将有助于确定paginator是否生成了错误的URL,或者您的laravel应用程序正在转到正确的页面,但控制器/中间件正在重定向到其他地方。@Goather-不太确定“该页面”是什么意思。我有一个控制列表的刀片文件。但是列表并没有真正的页面。您只需在主页的表单中键入要搜索的内容,然后就可以直接进入结果页面。将再次检查。@PhilCross-这是分页器栏上一个按钮的html:
  • 您所说的“选项参数”是什么意思?“你的意思是放在附录下?”托马斯更新了我的回答!非常感谢。
    
    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()
        ]);
    }