コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Mtcities::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->joinWith('cityProvince');
     $query->joinWith('cityCountry');
     $query->andFilterWhere(['city_id' => $this->city_id, 'city_created' => $this->city_created, 'city_updated' => $this->city_updated, 'city_status' => 'ACTIVE']);
     $query->andFilterWhere(['like', 'city_name', $this->city_name])->andFilterWhere(['like', 'city_status', $this->city_status])->andFilterWhere(['like', 'mtcountries.country_name', $this->city_country_id])->andFilterWhere(['like', 'mtprovinces.province_name', $this->city_province_id]);
     return $dataProvider;
 }
コード例 #2
0
 public function actionRestore($id)
 {
     $request = Yii::$app->request;
     if ($request->isGet) {
         $model = $this->findModel($id);
         $model->city_updated = date("Y-m-d");
         $model->city_status = 'ACTIVE';
         Yii::$app->session->setFlash('success', 'di Restore');
         $model->save();
     } else {
         die('cheating huh ?');
     }
     //$this->findModel($id)->delete();
     $model = Mtcities::find()->where(['city_status' => 'INACTIVE'])->all();
     if (sizeof($model) == 0) {
         return $this->redirect(['index']);
     } else {
         return $this->redirect(['trash']);
     }
 }