'不能为空'], ['type','in','range'=>[1,2,3,4]], ['del','in','range'=>[1,2]], ['sort','number'], // ['name', 'unique', 'targetClass' => 'common\models\CategoryCity','on'=>['add'],'message'=>'该城市名称已经存在'], ]; } public function FindById($id) { return self::findOne($id); } public function getList($page,$select = null) { $query = self::find(); $query->select($select); $query = $this->WhereColumn($query); if(!empty($page['page'])) { $query->offset = ($page['page'] - 1) * $page['limit']; $query->limit = $page['limit']; } return $query->orderBy(['create_at'=>SORT_DESC])->asArray()->all(); } private function WhereColumn($query) { $query->andFilterWhere(['name'=>$this->name]); $query->andFilterWhere(['type'=>$this->type]); $query->andFilterWhere(['id'=>$this->id]); $query->andWhere(['del'=>1]); return $query; } public function Total() { $query = self::find(); $query = $this->WhereColumn($query); return $query->count(); } public function CityAdd() { // $this->() } }