best way to add route under resource in Laravel 4
- by passingby
I would like know if there is a better way to add additional route aside from the default of resource in Laravel 4. I have this code below which is no problem with regard to the functionality, it's just that it seems to be long:
<?php
Route::group(array('before' => 'auth'), function()
{
# API
Route::group(array('prefix' => 'api'), function() {
Route::resource('projects', 'ProjectsController');
Route::resource('projects.groups', 'GroupsController');
Route::post('/projects/{projects}/groups/{groups}/reorder', 'GroupsController@reorder');
});
});
If in Rails
Rails.application.routes.draw do
# API
namespace :api, defaults: { format: 'json' } do
scope module: :v1 do
resources :projects do
resources :groups do
member do
post :reorder
end
end
end
end
end
end