1
Initially, I created the following route (1st search):
Route::get('/buscar/profissoes/{city_id_slug?}', array('as' => 'neighborhoods.city',
'uses' => 'NeighborhoodsController@getIndexCity'));
So the URL looks like this at the end:
http://example.com/buscar/profissoes/1-uberlandia
After, I created the segund arota (2nd search - continuation)
Route::get('/buscar/profissionais/{city_id_slug}/{neighborhood_id_slug}/
{profession_id_slug}', array('as' => 'professionals.search', 'uses' => 'ProfessionalsController@getSearch'));
Then the URL should look like this:
http://example.com/buscar/profissionais/1-uberlandia/15-santa-monica/1-pedreiro
But since the above URL is generated dynamically, initially it does not have the last 2 parameters. They will be added by clicking on Submit. Anyway, I added the parameters, just as a test and it didn’t work:
URL::route('professionals.search', array($city_id_slug, $city_id_slug, $city_id_slug))
Then Laravel returns the following:
Symfony \ Component \ Routing \ Exception \ RouteNotFoundException
Unable to generate a URL for the named route "http://example.com/buscar/profissionais/1-uberlandia/1-uberlandia/1-uberlandia" as such route does not exist.
What’s the right way to do this? And what is wrong in my routes, aiming that are different, and that even forcing the last 2 parameters with the number 1, did not work?
On the second route, the neighborhood_id_slug parameter could not, or should not, be optional({neighborhood_id_slug?}).
– FReNeTiC
Yeah, I’ve done that too. But as I was doing a test "forcing" the parameters with the value 1, I made it mandatory to see if the same problem would happen.
– Patrick Maciel