Exemplo n.º 1
0
 static function findCityById($id)
 {
     $model = new City();
     $record = $model->findOne($id);
     if (!empty($record)) {
         return $record->s_name;
     }
     return NULL;
 }
Exemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function validateCity()
 {
     if ($this->city_id !== null) {
         $city = City::findOne($this->city_id);
         if ($city === null) {
             $this->addError('city_id', Yii::t('location', 'City with id {[id]} doesn\'t exist', ['id' => $this->city_id]));
             return false;
         }
         $this->region_id = $city->region_id;
     }
     return true;
 }