How to Add Query String Automatic on Laravel Pagination

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

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:

http://text.hd/admin/products?name=test&page=1

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.

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →