[英]Laravel The GET method is not supported for this route. Supported methods: POST
I have the next trouble I have a form, and when I click to register button, show me the next: 我有下一个麻烦,我有一个表格,当我点击注册按钮,告诉我下一个:
"The GET method is not supported for this route. Supported methods: POST." “此路由不支持GET方法。支持的方法:POST。”
But my method is POST, this is my Route: 但我的方法是POST,这是我的路线:
Route::post('/createpedido',[
'uses'=>'PedidosControlador@pedidoagregado',
'as'=>'Pedidos.pedidoagregado']);
And this is part of my blade 这是我刀片的一部分
<form method="post" action="{{route('Pedidos.pedidoagregado')}}" enctype="multipart/form-data">
{{csrf_field()}}
<div class="row text-center">
<div class="col-lg-12 col-sm-12">
<h2>Agregar Pedido</h2>
<h3>Cliente: {{$Clientes->nombreempresa}}</h3>
</div>
<div class="col-lg-6 col-sm-6">
<h2>Datos Pedido</h2>
<hr size="5" color="#FF0000" />
And this is my complete controller 这是我完整的控制器
public function pedidoagregado(Request $request)
{
$validator = Validator::make($request->all(), [
'pedido' => 'required|string|max:255',
'fechapedido' => 'required|date|max:255',
'fechaentrega' => 'required|date|max:255',
'tipopedido' => 'required|string|max:255',
'observaciones' => 'required|email|max:255',
]);
if ($validator->fails()) {
return redirect('/createpedido')
->withErrors($validator)
->withInput();
}
$pedido = $request['pedido'];
$fechapedido = $request['fechapedido'];
$fechaentrega = $request['fechaentrega'];
$tipopedido = $request['tipopedido'];
$observaciones = $request['observaciones'];
$idcliente = $request['idcliente'];
$pedidos = new Pedidos();
$pedidos->idcliente = $idcliente ;
$pedidos->npedido = $pedido;
$pedidos->fechapedido = $fechapedido;
$pedidos->fechaentrega = $fechaentrega;
$pedidos->tipopedido = $tipopedido;
$pedidos->observacones = $observaciones;
$pedidos->save();
$request->session()->flash('alert-success', 'Pedido Agregado Correctamente');
if(Auth::user()->userlevel == "admin"){
return redirect()->to('administrador/');
}
if(Auth::user()->userlevel == "ventas"){
return redirect()->to('ventas/');
}
}
Thanks for your help 谢谢你的帮助
I check your code, which you provided and everything is fine. 我检查你提供的代码,一切都很好。 I guess, there is a probability you make two routes
one get the form and second for post route for posting your data to the server. 我想,你有可能制作两条routes
一条获得表格,第二条路线用于将数据发布到服务器。
and perhaps by mistake, you give same alias to both routes. 也许是错误的,你给两条路线都有相同的别名。
You give method post
so whether you give same alias it should work, perhaps you forget to close form tag
or by mistake, you have another form inside your form
. 你提供方法post
所以无论你给它应该工作的别名,也许你忘记关闭form tag
或错误地,你的表格中有另一个form
。 Perhaps there is some issue with route cache. 也许路由缓存存在一些问题。 so clear it with artisan command. 用artisan命令清除它。
php artisan route:clear
Perhaps This will work, there is some probability you did something wrong, so I suggest you recheck all part I included in the answer. 也许这会有效,你有可能做错了,所以我建议你重新检查我在答案中包含的所有部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.