laravel - Optional route parameter that must equal a string -
i need show exact same page/data 2 differents paths (/ , /index). how can create route satisfies rule?
i tried following, optional parameter allows any word (like /hello, /world, or /anything), whereas want / or /index:
route::get('/{trending?}', array('as' => 'index', function() { // code });
you can add regular expression route parameters, in case this:
route::get('/{trending?}', array('as' => 'index', function() { // code }))->where('trending', 'index'); however if have controller anyways (and should) i'd add 2 routes:
route::get('/', ['as' => 'index', 'uses' => 'somecontroller@index']); route::get('index', 'somecontroller@index');
Comments
Post a Comment