vendredi 25 juin 2021

Method Illuminate\Database\Eloquent\Collection::save does not exist

i have a problem when updating the database

error: Method Illuminate\Database\Eloquent\Collection::save does not exist.

controller:

 public function actualizar(Request $request){
    
    $nuevoIngreso = \App\Models\Servicio::all();
    $nuevoIngreso->costo = $request->costo;
    $nuevoIngreso->duracion = $request->duracion;
    $nuevoIngreso->mantenimiento = $request->mantenimiento;
    $nuevoIngreso->save();
    return redirect('servicios')->with('mensaje', 'Ficha Actualizada.');

}

blade.php

         <form method="POST" action="">
                
@csrf

                    @foreach ($servicios as $costo)
<h1 class="text-center text-primary">   </h1>
                  <div class="form-group row">
                    <label for="example-text-input" class="col-md-2 col-form-label form-control-label">Costo</label>
                    <div class="col-md-10">
                      <input class="form-control" type="text" value="">
                
                    </div>
                    <label for="example-text-input" class="col-md-2 col-form-label form-control-label">Duración</label>
                    <div class="col-md-10">
                      <input class="form-control" type="text" value="" id="example-text-input">
                    </div>
                    <label for="example-text-input" class="col-md-2 col-form-label form-control-label">Mantenimiento</label>
                    <div class="col-md-10">
                      <input class="form-control" type="text" value="" id="example-text-input">
                    </div>
                  </div>
                 <hr>
               @endforeach

               <button type="submit" class="btn btn-success float-right" float-rightdata-toggle="sweet-alert" data-sweet-alert="success">SAVE</button>
                </form>

help please



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire