samedi 30 janvier 2016

Laravel handle default route if optional parameter is not in the list

I define optional parameter "type" in the route and limit acceptable values (A,B or C) with where clause:

Route::get('test/{type?}', ['uses' => 'MyController@index'])->where('type', 'A|B|C');

If type value is different to A,B or C (e.g. "X") framework returns error page:

NotFoundHttpException in RouteCollection.php

In such case I would like to ignore received optional parameter and handle route as it is with no specified parameter i.e.: test/

How can it be implemented?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1JPcNQh
via IFTTT

Aucun commentaire:

Enregistrer un commentaire