Laravel Pagination links not including other GET parameters Laravel Pagination links not including other GET parameters laravel laravel

Laravel Pagination links not including other GET parameters


EDIT: Connor's comment with Mehdi's answer are required to make this work. Thanks to both for their clarifications.

->appends() can accept an array as a parameter, you could pass Input::except('page'), that should do the trick.

Example:

return view('manage/users', [    'users' => $users->appends(Input::except('page'))]);


I think you should use this code in Laravel version 5+.Also this will work not only with parameter page but also with any other parameter(s):

$users->appends(request()->input())->links();

Personally, I try to avoid using Facades as much as I can. Using global helper functions is less code and much elegant.

UPDATE:

Do not use Input Facade as it is deprecated in Laravel v6+


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