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');
Comments
Post a Comment