sergionc
5 months ago
483
4
Laravel

update array

Posted 5 months ago by sergionc

How would my function to update.

public function store(PrestamoRequest $request)
{
    $prestamo           = new Prestamo;
    $prestamo->socio_id = $request->socio_id;
    $prestamo->monto    = $request->monto;
    $prestamo->cuotas   = $request->cuotas;
    $prestamo->alias    = $request->alias;
    $prestamo->estado   = $request->estado;
    $prestamo->save();
    $idprestamo = $prestamo->id;

    if (count($request->ncuota) > 0) {
        foreach ($request->ncuota as $item => $v) {
            $presocio = new Presocio;
            $presocio->fill(
                array(
                    'prestamo_id' => $idprestamo,
                    'ncuota'      => $request->ncuota[$item],
                    'montopag'    => $request->montopag[$item],
                    'fechapag'    => $request->fechapag[$item],
                    'estadopag'   => $request->estadopag[$item],
                )
            );
            $presocio->save();
        }
    }
    toast('Pago Programados Registrado', 'success');
    return redirect('prestamo');
}

This is my function to save, how to modify to update, thanks

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