public static function AgregarCompraDetalle($items, $id) { foreach ($items as $item) { $producto = new compra_detalle(); $producto->compra_id = $id; $producto->producto_configurable_id = $item['producto_configurable']; $producto->cantidad = $item['cantidad']; $producto->valor = $item['sub_total'] / $item['cantidad']; $producto->dto = $item['dto'] / 100 * $item['valor']; $producto->iva = $item['iva'] / 100 * ($item['valor'] - $producto->dto); $producto->sub_total = $item['sub_total']; $producto->save(); } }
public function imprimir($id) { $compra = compras::with('proveedor')->findOrfail($id); $items = compra_detalle::where('compra_id', '=', $id)->with('producto_configurable')->get(); return view('app/compras/compras_print', compact(['compra', 'items'])); }