Collect array data

0

I have a form in which there is a table in which you must choose a product or several and their respective units. it works but if you do not choose the first product it does not save the other products.

$datab= Input::get('cantidad');
    $data=Input::get('seleccion');
    $idproducto= Input::get('idproducto');
    $id_pedido=Pedidos::where('id_usuario',$recogerUsuario->id)->orderBy('id','DESC')->first();     
            if (isset($_POST["seleccion"])){
                $cantidad= $request->cantidad;
                $seleccion=$request->seleccion;
                $idprod = $request->id_producto;

                    for($i=0;$i<count($seleccion);$i++){

                        $b = new ProductosPedidos;
                        $b->id_pedido=$id_pedido->id;
                        $b->id_producto=$idprod[$i];
                        $b->cantidad=$cantidad[$i];
                        $b->save();
                };
            };
    
asked by Peta P3t4d0r Zeta 21.02.2018 в 13:20
source

0 answers