jeudi 8 décembre 2016

Laravel exclude route

I have this in my web.php (Laravel 5.3)

 Route::get('/{perfil}/{seccion}', 'HotelsController@index')->where(['perfil' => '(perfil|profile)'])->where(['seccion' => '(mis-hoteles|my-properties)']);
 Route::get('/{perfil}/{seccion}', 'PerfilController@index')->where(['perfil' => '(perfil|profile)']);

I want the urls /perfil/mis-hoteles and /profile/my-properties to be served by the first route. And the urls /perfil/[whatever] and /profile/[whatever] to be served by the second route.

It does not work, /perfil/mis-hoteles is redirected by the second route.

I'd also tried something like

Route::get('/{perfil}/{seccion}', 'PerfilController@index')->where(['perfil' => '(perfil|profile)','seccion' => '^(!mis\-hoteles$)'])

for the second route, but it does not work .

What am I doing wrong? The weird thing is, if I delete the second route and leave only

 Route::get('/{perfil}/{seccion}', 'HotelsController@index')->where(['perfil' => '(perfil|profile)'])->where(['seccion' => '(mis-hoteles|my-properties)']);

it works, so there is a match. Why if there is a match laravel continues looking for a match finding the second route?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire