render('city'); } public function actionCityform() { $row = $this->City(); if ($row != null){ return Help::JsonData(0,Yii::t('app','get_success'),0,$row); } return Help::JsonCode(Help::ERROR,Yii::t('app','get_error')); } private function City() { $model = CategoryCity::find() ->select(['id','city_name']) ->andWhere(['pid'=>0,'level'=>1]) ->andWhere(['del'=>1,'abroad'=>1]) ->orderBy(['sort'=>SORT_DESC,'id'=>SORT_DESC]) ->asArray()->all(); $model_haiwai = CategoryCity::find() ->select(['id']) ->andWhere(['pid'=>0,'level'=>1]) ->andWhere(['del'=>1,'abroad'=>2]) ->column(); $haiwai = [ 'id'=>$model_haiwai, 'city_name'=>'海外', ]; $model[] = $haiwai; if ($model != null) { foreach ($model as &$val) { $val['son'] = CategoryCity::find() ->select(['id']) ->andWhere(['pid'=>$val['id'],'level'=>2,'del'=>1]) ->orderBy(['sort'=>SORT_DESC,'id'=>SORT_DESC]) ->column(); } } return $model; } }