In this tutorial, i will tell you how to add automatically query string to Laravel pagination links and when you need it ?
Sometime you filter records in Laravel and try to paginate to next page then additional query string is lost with pagination and results are reset to default without filter option. In this scenario, you can add all query sting by single command in Laravel with appends
method.
Let's have a look on given example.
- $products->appends(request()->all())->render();
- or
- $products->appends(Input::all())->render();
You can manually add query string to Laravel pagination links.
- $products->appends(['sort' => 'name'])->render()