public function loadProducts() { $databaseHelper = new DatabaseHelper(); $receiptProductsDb = $databaseHelper->query("SELECT `id` FROM `receipt_product` WHERE receiptId = " . $this->id); if (count($receiptProductsDb) > 0) { foreach ($receiptProductsDb as $receiptProductDb) { $ReceiptProduct = new ReceiptProduct($receiptProductDb['id']); $this->receiptProducts[] = array('id' => $ReceiptProduct->getId(), 'productId' => $ReceiptProduct->getProductId(), 'label' => $ReceiptProduct->getLabel(), 'priceInVat' => $ReceiptProduct->getPriceInVat(), 'priceExVat' => $ReceiptProduct->getPriceExVat(), 'amount' => $ReceiptProduct->getAmount(), 'totalPriceInVat' => $ReceiptProduct->getTotalPriceInVat(), 'totalPriceExVat' => $ReceiptProduct->getTotalPriceExVat()); } } }
/** * @return \yii\db\ActiveQuery */ public function getReceiptProducts() { return $this->hasMany(ReceiptProduct::className(), ['product_id' => 'id']); }