【发布时间】:2017-04-26 12:48:23
【问题描述】:
在我的 Laravel 路由文件 (web.php) 中,我有以下路由。
Route::resource('notifications/{section_id}', 'NotificationController', ['as' => 'notifications']);
然后我有一个刀片模板,可以打开这样的表单
{!! Form::model($qList,['route' => ['notifications.store']]) !!}
但是,此行会生成错误消息Route [notifications.store] not defined.
运行php artisan route:list 可以看到路由名称是notifications.{section_id}.store。即{section_id} 包含在路由名称中。这是我的问题吗?该参数似乎没有出现在我的任何其他路由中,并且我的 NotificationController 中确实有一个 store 方法
谢谢
【问题讨论】:
-
再次尝试删除 {section_id} 参数和 route:list。
-
这确实有效并显示了正确的路线,但我需要将参数传递给我的控制器。 {section_id} 是必需的
-
将 $request->input('section_id') 转储到 store 方法中。不要忘记在方法实现中添加 Request $request 作为参数
-
店铺路线现在怎么样了?从 route:list 输出粘贴它。
-
但这是我的问题。我的 NotificationsController 中确实有一个 store 方法,但错误消息是该方法不存在