LARAVEL Validation Method PUT

Asked

Viewed 397 times

-2

Good morning, you guys. I’m a beginner in Lisbon, I searched on the subject but nothing can help me(or that I have understood), so , who can give me a strength and thank.

LARAVEL 5.8 <<<<

I have a form that directs p/ controller

<form role="form" method="POST" action="{{route('pedidos.update',$edit->id)}}">
   @method('PUT')                   
   @csrf

and in the controller:

 $rules=$request->validate([
            'nome'=>'required|min:3|max:191',
            'cpf'=>'required|max:11|unique:pedido_seja_socio,cpf,'.$request->id,
        ]);
 if ($rules->fails()){
        redirect(route('verifica.do'))->withErrors($rules)->withInput();
 }

and returns the following error:

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
The GET method is not supported for this route. Supported methods: POST.

if I comment (/**/) the validation code section, allows updating records.

  • Please post the route.php file with the route description for this controller. I believe it is the lack of setting the route to the screen where the form is being mounted. If you can also put the code that calls this view with the form. PS:I didn’t understand why they denied your question.

  • was exactly that @Ademirmazerjr-Nuno, was directing p/ route err, thank you very much.

1 answer

0

You must be in trouble on the routes and maybe on the form. Check your route file to make sure that the "requests.update" route is PUT and try to make the form this way:

{{ Form::open(array('url' => '/', 'method' => 'PUT', 'class'=>'col-md-12')) }}
.... seu código
{{ Form::close() }}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.