Laravel 4 nested resource controllers Route::resource('admin/photo', 'PhotoController'); not working

后端 未结 4 1083
無奈伤痛
無奈伤痛 2021-01-13 16:38

In Larvel 4 I\'m trying to setup nested resource controllers.

in routes.php:

Route::resour         


        
相关标签:
4条回答
  • 2021-01-13 17:01

    In actual fact you should replace the "admin/photo" with "admin.photo" for laravel to set-up a resource for photo being a sub of admin.

    Check this https://tutsplus.com/lesson/nested-resources/

    0 讨论(0)
  • 2021-01-13 17:14

    Just simply use a group prefix -> admin. Using nested admin.photo will create you an wrong url like admin/{admin}/photo/{photo}, which you don't want.

    0 讨论(0)
  • 2021-01-13 17:15

    See https://github.com/laravel/framework/issues/170 Found my answer there (see what Taylor wrote)

    For those who want to see my code that works now in routes.php:

    Route::group(array('prefix' => 'admin'), function() {
    
        // Responds to Request::root() . '/admin/photo'
        Route::resource('photo', 'Controllers\\Admin\\PhotoController');
    });
    
    0 讨论(0)
  • 2021-01-13 17:19

    Probably you will need to tell Composer to reload classes again, run from your command line:

    composer dump-autoload
    

    That should work.

    0 讨论(0)
提交回复
热议问题