Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  1. public function store(Request $request)
  2.     {
  3.         //dd($request->all());
  4.         $codigo_producto = str_replace(' ', '', $request->codigo_producto);
  5.         $precio_unidad = str_replace(' ', '', $request->precio_unidad);
  6.         $cantidad_producto = str_replace(' ', '', $request->cantidad_producto);
  7.         $codigo_producto = explode(",", $codigo_producto);
  8.         $precio_unidad = explode(",", $precio_unidad);
  9.         $cantidad_producto = explode(",", $cantidad_producto);
  10.         $total=count($codigo_producto);
  11.         $i = 0;
  12.        $nv= notaventa::create(['id_cli'=>$request->id_cli,'id_emp'=>$request->id_emp]);
  13.             while ($i < $total) {
  14.             if ($i!='0' ) {
  15.  
  16.                detalleventa::create(['id_venta'=>$nv->id,
  17.                     'id_prod'=>$codigo_producto[$i],
  18.                     'cantidad'=>$cantidad_producto[$i],
  19.                     'importe'=>$precio_unidad[$i]*$cantidad_producto[$i]]);
  20.             }
  21.             $i++;
  22.         }
  23.        //obtener ultimo id para terminar entre la linea 48 y 49
  24.         return view('admin.compra.index');
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement