static function findCityById($id) { $model = new City(); $record = $model->findOne($id); if (!empty($record)) { return $record->s_name; } return NULL; }
/** * @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; }