2
我注意到,您在组内路由前缀中指定的参数也会提供给位于该特定组内的所有控制器,这是合理的。带有前缀的Laravel组路由参数
例如:然后
Route::group(array('prefix' => 'team/{id}/{slug}', 'before' => 'auth'), function() {
Route::get('documents/{document}', 'controllers\\team\\[email protected]');
});
的DocumentsController的表演方法必须遵循所有参数的顺序:
show($id, $slug, $document)
不过,我并不真正需要的团队ID和蛞蝓在DocumentsController中,它们只是用于漂亮的URLS。反正是有传递仅在DocumentsController该路由指定的参数(即不包括前缀PARAMS),具体如下:
show($document)
谢谢你的建议。目前我一直使用Route :: getCurrentRoute() - > getParameter('document'),但解析声音更明智,因为我在许多控制器中遇到了这个问题,所以我会给它一个镜头。 –