【发布时间】:2018-06-18 15:45:04
【问题描述】:
我想要这样的嵌套资源:
Route::group(['prefix' => 'manage', 'middleware' => ['role:boss']], function ()
{
Route::resource('/articles', 'ArticleController');
Route::group(['prefix' => '/articles', 'as' => 'articles.'], function () {
Route::resource('/types', 'ArticleTypeController');
});
});
但是“文章/类型”的嵌套路由不起作用,我在“文章”路由之外检查了我的 ArticleTypeController 并工作。
我真的很困惑,大家可以帮帮我吗?
这是我的控制器:
class ArticleTypeController extends Controller
{
public function index()
{
$types = ArticleType::all();
return view('manage.articles.types.index')->withtypes($types);
}
}
【问题讨论】:
-
/article/type或/articles/types?检查您的定义方式并确保使用正确的值(复数与非复数) -
不,蒂姆,它是复数形式
-
But nested route for "article/type" doesn't work这句话有什么问题?该声明应该读作 article/type 还是 articles/types?
标签: laravel controller routes