Esempio n. 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;
 }
Esempio n. 2
0
 /**
  * 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()]);
     }
 }