Example #1
0
 /**
  * get catList
  * @author Cangzhou Wu<*****@*****.**>
  * @param $cat_id
  * @param bool $city  city list flag
  * @return array
  */
 public function getList($cat_id, $city = true)
 {
     $cities = Area::find()->where(['parent_id' => $cat_id])->all();
     $catList = [];
     if ($city) {
         foreach ($cities as $s) {
             $catList[] = ['id' => $s->area_id, 'name' => $s->name];
         }
     } else {
         foreach ($cities as $s) {
             $catList['out'][] = ['id' => $s->area_id, 'name' => $s->name];
         }
         $catList['selected'] = $s->area_id;
     }
     return $catList;
 }
Example #2
0
 public function getDistrictArea()
 {
     return $this->hasOne(Area::className(), ['area_id' => 'district']);
 }