在 Laravel 4 中,我尝试设置嵌套资源控制器。
in 路线.php:
Route::resource('admin/photo', 'Controllers\\Admin\\PhotoController');
in 应用程序\控制器\管理\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(/管理/照片获取),create(/admin/photo/create) 和store(/admin/photo POST) 操作工作正常...但不行edit and show,我刚刚得到页面未找到 404 状态。
如果我删除管理根路径,它会起作用。
谁能告诉我如何设置 Route::resource 控制器来使用像 admin/photo 这样的嵌套路径
See https://github.com/laravel/framework/issues/170在那里找到了我的答案(看看泰勒写的)
对于那些想查看我的代码现在可以在 paths.php 中运行的人:
Route::group(array('prefix' => 'admin'), function() {
// Responds to Request::root() . '/admin/photo'
Route::resource('photo', 'Controllers\\Admin\\PhotoController');
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)