/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = InvoiceCharges::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['invoice_id' => $this->invoice_id, 'diskaun' => $this->diskaun, 'shipping' => $this->shipping, 'gst' => $this->gst]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getInvoiceCharges() { return $this->hasOne(InvoiceCharges::className(), ['invoice_id' => 'id']); }
public function actionAddcharges($entrepreneur_user_id, $invoice_id) { $model = new InvoiceCharges(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->invoice_id]); } else { $model = $this->findModel($entrepreneur_user_id, $invoice_id); //$model2 = $this->findProfile($entrepreneur_user_id); //$query = $model->getInvoice(); //$dataProvider = new ActiveDataProvider(['query'=>$query]); return $this->render('charges', ['model' => $model]); } }
/** * Finds the InvoiceCharges model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return InvoiceCharges the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = InvoiceCharges::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }