best way to add route under resource in Laravel 4

Posted by passingby on Stack Overflow See other posts from Stack Overflow or by passingby
Published on 2014-08-24T16:01:09Z Indexed on 2014/08/24 16:20 UTC
Read the original article Hit count: 215

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about php

Related posts about laravel-4