How to generate route with query string parameter in Laravel

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

Now on this post i would like to share with you a example of How to generate route with query string parameter in Laravel. When we need to add any query string or parameter in our link url, here i mean that in the route then we generate a link also with the query string parameter by using Laravel URL facade. most of the new developer doing this way:

<a href="{{ URL::route('home') }}.'?id=1&test_id=2'">Test</a>

But we should do this it that way. Because this the way, bellow the example we can see how it done.

<a href="{{ URL::route('home',['id'=>'2','test_id'=>'3']) }}">Test</a>

Read Also : How to convert Object into Array in PHP?

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 →