100], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => Yii::t('common', 'ID'), 'name' => Yii::t('common', 'Name'), 'parent_id' => Yii::t('common', 'Parent ID'), 'level' => Yii::t('common', 'Level'), ]; } /** * @inheritdoc * @return \common\models\query\RegionQuery the active query used by this AR class. */ public static function find() { return new \common\models\query\RegionQuery(get_called_class()); } public static function getRegion($parentId = 0) { $result = static::find()->where(['parent_id' => $parentId])->asArray()->all(); return ArrayHelper::map($result, 'id', 'name'); } public static function getNameById($id = 0) { $name = ''; $result = static::findOne(['id'=>$id]); if($result){ $name = $result->name; } return $name; } }