Beispiel #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = DapTerms::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'price' => $this->price, 'discount' => $this->discount, 'status' => $this->status, 'order' => $this->order]);
     $query->andFilterWhere(['like', 'type', $this->type])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'icon', $this->icon]);
     return $dataProvider;
 }
 /**
  * Updates an existing Orders model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $dap = DapTerms::find()->where(['status' => DapTerms::STATUS_ACTIVE])->all();
     $deliveryArray = [];
     $paymentArray = [];
     foreach ($dap as $row) {
         if ($row->type == DapTerms::TYPE_DELIVERY) {
             $deliveryArray[$row->id] = $row->name;
         } elseif ($row->type == DapTerms::TYPE_PAYMENT) {
             $paymentArray[$row->id] = $row->name;
         }
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'paymentArray' => $paymentArray, 'deliveryArray' => $deliveryArray, 'statusArray' => Orders::getStatusArray()]);
     }
 }
 /**
  * Finds the DapTerms model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return DapTerms the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = DapTerms::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #4
0
 public function getPayment()
 {
     return $this->hasOne(DapTerms::className(), ['id' => 'payment_id']);
 }