Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel append URI in route

Hi I want to append the uri in laravel route function.

e.g we have /search?type=listing

//how do i can achieve this with 

route('search',['type'=>'listing'])

Once the we are on the search. I want to have all the variable appended to search like

type=listing&query=blah blah

like image 443
Romantic Dev Avatar asked Jun 19 '17 09:06

Romantic Dev


1 Answers

If I get you right, you want to save all query parameters. Use Request::query() to get it and then merge with your new parameters.

route('search', array_merge(\Request::query(), ['type' => 'listing'])));
like image 119
Andrey Lutskevich Avatar answered Oct 14 '22 08:10

Andrey Lutskevich