sergionc
6 months ago
758
11
Laravel

insert multiple data laravel

Posted 6 months ago by sergionc

I am trying to enter several records in a row but only one registers me, would the correct way be? is for a master table, detail.

public function store(Request $request)
{
    $request->validate([
        'prestamo_id' => 'required|numeric',
        'montopag' => 'required|numeric',
        'fechapag' => 'required|date',
    ]);

    $presocio = new Presocio;
    $data = [
        [$presocio->prestamo_id = $request->prestamo_id,
            $presocio->montopag = $request->montopag,
            $presocio->fechapag = $request->fechapag],
    ];
    Presocio::insert($data);

    toast('Pago Programados Registrado','success');
    return redirect('presocio');
}

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