/** * @param $orderId */ public function actionNewInvoice($orderId) { $order = Order::findOne($orderId); $invoice = new Invoice(['order_id' => $order->id, 'due_amount' => $order->due_amount, 'due_datetime' => (new \DateTime('+10 days'))->format('Y-m-d H:i:s'), 'created' => new Expression('NOW()')]); $invoice->save(); $this->redirect(['order/view', 'orderId' => $orderId]); }
/** * #return \yii\db\ActiveRelation */ public function getInvoices() { return $this->hasMany(\app\models\ar\Invoice::className(), ['order_id' => 'id']); }