Home Laravel How to Add Query String Automatic on Laravel Pagination

How to Add Query String Automatic on Laravel Pagination

by Shahriar Sagor

Today now in this post i will show you how to add query string automatically on laravel pagination links. On this example we will work on items module and we need to add a index page as like listing all items also with pagination. And also we did give a search function on items name. Now we a bellow query string when we need to search something and we also want to pass that query string for all pagination link.

Query String URL:


But where is problem. when we search any for example “test” and need to get the result but when we click on the next page we can’t filter on name as we did “test”. so now at this time we need to appends that query string on our pagination links.

so, let’s start and see how to solve this issue.

View Example:

{!! $products->appends(Input::all())->render() !!}

We need to just add an appends method of pagination and it will give an array as argument. Input::all() it will be get whole query string from the url and it will pass with pagination.

Read Also : How to add charts in Laravel using Highcharts ?

Thanks for read. I hope it help you. For more you can follow us on facebook.


You may also like