123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/3/4
- * Time: 上午9:28
- */
- namespace common\models;
- //use yii\db\ActiveRecord;
- //use yii\behaviors\TimestampBehavior;
- /*
- * type = 2 表示建筑类别
- * */
- class CategoryLabel extends Common
- {
- public function rules()
- {
- return [
- ['name','required','message'=>'不能为空'],
- ['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->()
- }
- }
|