Laravel 5.1 add Query strings in url

Arnab Rahman picture Arnab Rahman · Nov 16, 2015 · Viewed 17.2k times · Source

I've declared this route:

Route::get('category/{id}{query}{sortOrder}',['as'=>'sorting','uses'=>'CategoryController@searchByField'])->where(['id'=>'[0-9]+','query'=>'price|recent','sortOrder'=>'asc|desc']);

I want to get this in url: http://category/1?field=recent&order=desc How to achieve this?

Answer

Oğuz Can Sertel picture Oğuz Can Sertel · Jun 23, 2016

if you have other parameters in url you can use;

request()->fullUrlWithQuery(["sort"=>"desc"])