Пример #1
0
 public function actionDistricts()
 {
     $country = Yii::$app->request->post('country');
     if (empty($country) || $country === 'undefined') {
         return null;
     }
     $province = Yii::$app->request->post('province');
     if (empty($province) || $province === 'undefined') {
         return null;
     }
     $city = Yii::$app->request->post('city');
     if (empty($city) || $city === 'undefined') {
         return null;
     }
     return District::asArray(Country::get($country)->getProvince($province)->getCity($city)->districts);
 }
Пример #2
0
 protected function populateRegion()
 {
     $region = "";
     $country = Country::get($this->model->country);
     if (!$country) {
         return $region;
     }
     $region .= $country->shortname;
     $province = $country->getProvince($this->model->province);
     if (!$province) {
         return $region;
     }
     $region .= " " . $province->localname;
     $city = $province->getCity($this->model->city);
     if (!$city) {
         return $region;
     }
     $region .= " " . $city->localname;
     $district = $city->getDistrict($this->model->district);
     if (!$district) {
         return $region;
     }
     return $region . " " . $district->localname;
 }
Пример #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCountry0()
 {
     return $this->hasOne(Country::className(), ['alpha2' => 'country']);
 }