Reputation: 191
I'm trying to make an url query string with laravel but this method:
url()->to('categories', ['id' => 1, 'name' => 'cars']);
Returns me:
http://localhost/categories/1/cars
But I need this:
http://localhost/categories?id=1&name=cars
Upvotes: 0
Views: 99
Reputation: 191
The answer is:
Route::any(Request::path(), ['as' => Request::path(), 'uses' => 'Extender@xRun']);
Upvotes: 0
Reputation: 163748
First of all, you'll need to create a named route without parameters:
Route::get('categories', ['as' => 'categories', 'uses' => 'SomeController@showCategories']);
Then use route()
helper:
route('categories', ['id' => 1, 'name' => 'cars']);
This will generate:
'/categories?id=1&name=cars'
Upvotes: 2