I have a question, when I try to update a data I get the MethodNotAllowedHttpException error, I understand that this error comes out when there is a problem with the paths that are get
and should be post
but in my case my path is resource
:
web.php
Route::resource('inventario', 'InventarioController');
Controller (update function)
public function update(Request $request, $id)
{
$this->validate($request,[ 'cantidad'=>'required']);
Inventario::find($id)->update($request->all());
return redirect()->route('inventario.show')->with('success','Registro actualizado satisfactoriamente');
}
Vista (show.blade.php)
<form method="POST" action="{{ route('inventario.update', $inv->id_inventario )}}" role="form">
{{ csrf_field() }}
<div class="form row">
<input type="hidden" name="id_inventario" class="form-control input-sm" id="id_inventario"
value="{{ $inv->id_inventario }}">
<input type="number" name="cantidad" class="form-control input-sm" id="cantidad"
value="{{ $inv->cantidad }}">
</div>
<div class="form-group col-md-6">
<input type="submit" value="Guardar" class="btn btn-success">
<button type="button" class="btn btn-white" data-dismiss="modal">Cerrar</button>
</div>
</form>
In my case when clicking on the update button, a modal opens, which is where the data I want to update appears.