'common\models\PushCity','on'=>['add'],'message'=>'该楼盘已存在','filter'=>function($query){ // return $query->andWhere(['del'=>$this->setDel]); // }], // ['city_id','number','message'=>'请选择区域'], ['city_id','each','rule'=>['integer'],'message'=>'请输入正确的区域信息'], ['sort','number','message'=>'排序只能是数字'], ['sort','number','max'=>10000], ]; } public function attributeLabels() { return [ 'hid'=>'楼盘名称', 'sort'=>'排序', ]; } public function Authenticator($input) { $this->load($input,''); if(!$this->validate()) return $this->errors; return $this; } public function FindById($id) { return self::findOne($id); } public function getList($input) { $query = self::find(); $query->select(['pfg_category_city.id','pfg_category_city.city_name','pfg_push_city.create_at','pfg_push_city.is_show','pfg_push_city.sort']); $query->andWhere(['pfg_push_city.del'=>$this->setDel]); if(!empty($input['city_name'])) { $query->andWhere(['like','pfg_category_city.city_name',$input['city_name']]); } if(!empty($input['city_id'])) { $query->andWhere(['pfg_push_city.city_id'=>$input['city_id']]); } $query->leftJoin('pfg_category_city','pfg_push_city.city_id=pfg_category_city.id'); if(!empty($input['page'])) { $query->limit = $input['limit']; $query->offset = ($input['page']-1 )* $input['limit']; } return $query->orderBy(['pfg_push_city.create_at'=>SORT_DESC])->asArray()->all(); } public function WhereColumn($query) { } public function Total() { $query = self::find(); $query->andWhere(['pfg_push_city.del'=>$this->setDel]); $query->leftJoin('pfg_category_city','pfg_push_city.city_id=pfg_category_city.id'); return $query->count(); } public function Homegetlist() { // $query = self::find(); // $query->select(['pfg_category_city.id','pfg_category_city.city_name','pfg_push_city.create_at','pfg_push_city.is_show','pfg_push_city.sort']); // $query->andWhere(['pfg_push_city.del'=>$this->setDel]); // if(!empty($input['city_name'])) // { // $query->andWhere(['like','pfg_category_city.city_name',$input['city_name']]); // } // if(!empty($input['city_id'])) // { // $query->andWhere(['pfg_push_city.city_id'=>$input['city_id']]); // } // $query->leftJoin('pfg_category_city','pfg_push_city.city_id=pfg_category_city.id'); // if(!empty($input['page'])) // { // $query->limit = $input['limit']; // $query->offset = ($input['page']-1 )* $input['limit']; // } // return $query->orderBy(['pfg_push_city.create_at'=>SORT_DESC])->asArray()->all(); $query = self::find(); $query->select(['pfg_category_city.id','pfg_category_city.city_name','pfg_push_city.create_at','pfg_push_city.is_show','pfg_push_city.sort']); $query->andWhere(['pfg_push_city.del'=>$this->setDel]); $query->andWhere(['pfg_push_city.is_show'=>1]); $query->leftJoin('pfg_category_city','pfg_push_city.city_id=pfg_category_city.id'); $query->orderBy(['pfg_push_city.sort'=>SORT_ASC]); $query->limit = 18; return $query->asArray()->all(); } }