12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace backend\controllers;
- use backend\base\CommonController;
- use backend\base\Help;
- use common\models\CategoryCity;
- use Yii;
- class PushmbController extends CommonController
- {
- public function actionCity()
- {
- return $this->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;
- }
- }
|