I have the following in routes.php:
Route::get('test/foo', 'TestController@index');
Route::get('test/bar', 'TestController@index');
Route::get('test/baz', 'TestController@index');
and I try to reduce it to the following:
Route::get(either 'test/foo' or 'test/bar' or 'test/baz', 'TestController@index');
One documented approach that is applicable here is to bind a regular expression to a route:
Route::get('test/{uri}','TestController@index')->where('uri', 'regex for foo, bar, and baz...');
However, this decision would be ugly. Isn’t there an elegant way to simply express
{uri} in foo,bar,baz
in Laravel? Otherwise, what does the regex look like?
Thank!
PS I read this one , but this does not apply to my case with three routes.
source
share