Laravel 资源上带有参数的LAVEL路由名称

Laravel 资源上带有参数的LAVEL路由名称,laravel,twig,laravel-5.2,Laravel,Twig,Laravel 5.2,这是我所有的路线 Route::group(['prefix' => 'admin'], function () { Route::resource('surveys', 'SurveyController'); Route::resource('surveys/{survey}/groups', 'GroupController'); Route::resource('surveys/{survey}/groups/{group}/questions', 'Que

这是我所有的路线

Route::group(['prefix' => 'admin'], function () {
    Route::resource('surveys', 'SurveyController');
    Route::resource('surveys/{survey}/groups', 'GroupController');
    Route::resource('surveys/{survey}/groups/{group}/questions', 'QuestionController');
});
这是我(许多)定义的路线之一

METHOD = GET|HEAD
URI = admin/surveys/{survey}/groups/{groups}
Name = admin.surveys.{survey}.groups.show
Action = App\Http\Controllers\GroupController@show
我如何调用它并在我的视图中传入group.id和survey.id(如果重要的话,这是twig使用twig_bridge)

我试过了

{{ route('admin.surveys.{survey}.groups.show', ['survey' => survey.id, group.id]) }}
和其他类似的语法,但总是会出现意外的标点错误


我自己没有说出这些路线。这是遵守命名约定时的默认Laravel。

您可以使用点语法定义嵌套的资源路由:

Route::group(['prefix' => 'admin'], function () {
    Route::resource('surveys', 'SurveyController');
    Route::resource('surveys.groups', 'GroupController');
    Route::resource('surveys.groups.questions', 'QuestionController');
});
然后您可以按如下方式路由到它们:

route('admin.surveys.groups.show', [$surveyId, $groupId])
route('admin.surveys.groups.questions.show', [$surveyId, $groupId, $questionId])