laravel - Specify controller & method to use in anonymous function of a route parameter? -


i'm checking out laravel. trying make use of wildcard route. 2nd parameter anonymous function. ideally i'd little bit of validation determine if it's valid wildcard option & specify controller & method use.

route::get('lodging/{entrance}', function($entrance){     // validate if entrance 'north','south','east','west'     // send controller & specific method     return "entrance $entrance"; }); 

is appropriate place this?

or should validation taken care of in controller , use format route:

route::get('lodging/{entrance}', 'lodging@chooseentrance'); 

you can add simple validation route

route::get('lodging/{entrance}', function(){ ... })->where('entrance', 'north|south|east|west'); 

see routing#parameters-regular-expression-constraints


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -