Laravel Pagination links not including other GET parameters

前端 未结 12 634
遥遥无期
遥遥无期 2020-12-04 08:35

I am using Eloquent together with Laravel 4\'s Pagination class.

Problem: When there are some GET parameters in the URL, eg: http://site.com/u

12条回答
  •  渐次进展
    2020-12-04 08:48

    You could use

    ->appends(request()->query())
    

    Example in the Controller:

    $users = User::search()->order()->with('type:id,name')
        ->paginate(30)
        ->appends(request()->query());
    
    return view('users.index', compact('users'));
    

    Example in the View:

    {{ $users->appends(request()->query())->links() }}
    

提交回复
热议问题