sergionc
6 months ago
670
12
Laravel

change save to create

Posted 6 months ago by sergionc

how could I change the code so that it is with "CREATE" instead of -> save with condition isDirty

public function update(AhorrogaRequest $request, $id)
{
    $ahorroga           = Ahorroga::findOrFail($id);
    $ahorroga->junta_id = $request->junta_id;
    $ahorroga->socio_id = $request->socio_id;
    $ahorroga->ahorro   = $request->ahorro;
    $ahorroga->estado   = $request->estado;

    if ($ahorroga->isDirty()) {
        $ahorroga->save();
        toast('Ahorro Garantia Editado', 'success');
        return redirect('ahorroga');
    }
    toast('No se detectaron cambios', 'error');
    return redirect('ahorroga');
}

Please sign in or create an account to participate in this conversation.