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
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'
routes.php, I've just tested it and it creates exactly URL you need.