Beispiel #1
0
 private function renderChildren($id)
 {
     $data = [];
     if ($house = FiasHouse::findOne(['houseguid' => $id])) {
         $current = null;
         $parent = FiasAddrobj::findOne(['aoguid' => $house->aoguid]);
     } elseif ($landmark = FiasLandmark::findOne(['landguid' => $id])) {
         $current = null;
         $parent = FiasAddrobj::findOne(['aoguid' => $landmark->aoguid]);
     } else {
         $current = FiasAddrobj::find()->andWhere(['aoguid' => $id, 'currstatus' => 0])->one();
         $parent = FiasAddrobj::find()->andWhere(['aoguid' => $current->parentguid, 'currstatus' => 0])->one();
     }
     if ($current) {
         // Улицы
         $query = FiasAddrobj::find();
         $query->andWhere(['parentguid' => $current->aoguid, 'currstatus' => 0]);
         $query->orderBy('formalname');
         $data = ArrayHelper::merge($data, ArrayHelper::map($query->all(), 'aoguid', 'name'));
         // Дома
         $query = FiasHouse::find();
         $query->andWhere(['aoguid' => $current->aoguid]);
         $query->orderBy(new \yii\db\Expression('housenum + 0'));
         $data = ArrayHelper::merge($data, ArrayHelper::map($query->all(), 'houseguid', 'housenum'));
         // Места
         $query = FiasLandmark::find();
         $query->andWhere(['aoguid' => $current->aoguid]);
         $query->orderBy('location');
         $data = ArrayHelper::merge($data, ArrayHelper::map($query->all(), 'landguid', 'location'));
         echo $this->renderDropDownList($data);
     }
 }
Beispiel #2
0
 public static function toString($id, $separator = ", ")
 {
     if ($house = FiasHouse::findOne(['houseguid' => $id])) {
         $parent = FiasAddrobj::findOne(['aoguid' => $house->aoguid]);
         $result = $house->housenum;
     } elseif ($landmark = FiasLandmark::findOne(['landguid' => $id])) {
         $parent = FiasAddrobj::findOne(['aoguid' => $landmark->aoguid]);
         $result = $landmark->location;
     } else {
         $current = FiasAddrobj::find()->andWhere(['aoguid' => $id, 'currstatus' => 0])->one();
         $parent = FiasAddrobj::find()->andWhere(['aoguid' => $current->parentguid, 'currstatus' => 0])->one();
         $result = $current->name;
     }
     if ($parent) {
         $result = static::toString($parent->aoguid, $separator) . $separator . $result;
     }
     return $result;
 }