Example #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;
 }
Example #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMemberCity()
 {
     return $this->hasOne(Mtcities::className(), ['city_id' => 'member_city_id']);
 }
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMtcities()
 {
     return $this->hasMany(Mtcities::className(), ['city_province_id' => 'province_id']);
 }
Example #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMtcities()
 {
     return $this->hasMany(Mtcities::className(), ['city_country_id' => 'country_id']);
 }
Example #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCompanyCity()
 {
     return $this->hasOne(Mtcities::className(), ['city_id' => 'company_city_id']);
 }
 /**
  * Finds the Mtcities model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Mtcities the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Mtcities::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }