Search code examples
phplaravellaravel-4

multiple routes in single Route::get() call Laravel 4


When defining a route in Laravel 4 is it possible to define multiple URI paths within the same route?

presently i do the following:

Route::get('/', 'DashboardController@index');
Route::get('/dashboard', array('as' => 'dashboard', 'uses' => 'v1\DashboardController@index'));

but this defeats my purpose, i would like to do something like

Route::get('/, /dashboard', array('as' => 'dashboard', 'uses' => 'DashboardController@index'));

Solution

  • If I understand your question right I'd say:

    Use Route Prefixing: http://laravel.com/docs/routing#route-prefixing

    Or (Optional) Route Parameters: http://laravel.com/docs/routing#route-parameters

    So for example:

    Route::group(array('prefix' => '/'), function() { Route::get('dashboard', 'DashboardController@index'); });
    

    OR

    Route::get('/{dashboard?}', array('as' => 'dashboard', 'uses' => 'DashboardController@index'));