How to add query string automatically on laravel pagination links ?

By Hardik Savani | March 30, 2016 | | 3387 Viewer | Category : Laravel

Share this post:

For example you are working on items module and you have a index page like listing all items with pagination. also you did give search function on items name. I have a bellow query string when i search something and i want to pass that query string on all pagination link.

Query String URL:


But where is problem. when you search any for example "tes" and get the result but when you click on next page you can't filter on name as you did "tes". so at that time we have to appends that query string on pagination links. so, let's see how to solve this issue.

View Example:

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

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

We are Recommending you: