In Larvel 4 I'm trying to setup nested resource controllers.
in routes.php:
Route::resource('admin/photo', 'Controllers\\Admin\\PhotoController');
in app\controllers\Admin\PhotoController.php:
<?php namespace Controllers\Admin;
use Illuminate\Routing\Controllers\Controller;
class PhotoController extends Controller {
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
return 'index';
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//
}
/**
* Display the specified resource.
*
* @return Response
*/
public function show($id)
{
return $id;
}
/**
* Show the form for editing the specified resource.
*
* @return Response
*/
public function edit($id)
{
return "edit $id";
}
/**
* Update the specified resource in storage.
*
* @return Response
*/
public function update($id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @return Response
*/
public function destroy($id)
{
//
}
}
index (/admin/photo GET), create (/admin/photo/create) and store (/admin/photo POST) actions work fine... but not edit and show, I just get a page not found 404 status.
it will work though if I drop the admin root path.
Can anyone tell me how I setup the Route::resource controller to work with a nested path like admin/photo
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');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With