$checkMethod = $request->method();
if (!$checkMethod) {
return redirect('todo_show');
} else {
echo "yes";
}
如果请求未发布,那么我如何重定向到另一条路线。发生此错误“此路由不支持 GET 方法。支持的方法:POST”。
答案 0 :(得分:1)
将您的路线 Route::post...
更改为 Route::any...
或 Route::match(['GET', 'POST')]…
根据 Laravel documentation,您可以在控制器上检查此请求方法:
$method = $request->method();
if ($request->isMethod('post')) {
return redirect('todo_show');
} else {
echo "yes";
}