我在UserController中有一个名为destroy的操作,我不想用这个操作代替UserInfoController@destroy应该跑步。所以我需要重定向到UserInfoControlle@destroy
控制器。
UserController@destroy行动
return redirect()->action(
'UserInfoController@destroy',['id' => 1]
);
操作已成功运行,但我收到此错误
The GET method is not supported for this route. Supported methods: POST.
您有一些方法可以做到这一点,如下所示:
-
为该创建新的
get
路由Route::get('/delete/{id}','UserInfoController@destroy')->name('deleteWithGetMethod');
-
在路线中将
post
更改为any
Route::any('/delete/{id}','UserInfoController@destroy')->name('delete');
-
返回包含以下代码的视图
<form id="myForm" action="{{ route('delete',$userInfoId) }}" method="post"> </form> <script type="text/javascript"> document.getElementById('myForm').submit(); </script>