1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/5/21
- * Time: 下午5:18
- */
- namespace common\models;
- class PushCharacteristic extends Common
- {
- public function rules()
- {
- return [
- // ['city_id', 'unique', 'targetClass' => 'common\models\PushCity','on'=>['add'],'message'=>'该楼盘已存在','filter'=>function($query){
- // return $query->andWhere(['del'=>$this->setDel]);
- // }],
- ['style','string','max'=>30,'message'=>'请输入正确的class'],
- ['cid','required','message'=>'特色类型不能为空'],
- ['cid','number','message'=>'请输入正确的特色类型信息'],
- ['sort','number','message'=>'排序只能是数字'],
- ['sort','number','max'=>10000],
- ];
- }
- public function attributeLabels()
- {
- return [
- 'cid'=>'特色类型名称',
- '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_push_characteristic.img','pfg_push_characteristic.style','pfg_characteristic.name','pfg_push_characteristic.cid','pfg_push_characteristic.id','pfg_push_characteristic.create_at','pfg_push_characteristic.is_show','pfg_push_characteristic.sort']);
- $query->andWhere(['pfg_push_characteristic.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_characteristic','pfg_push_characteristic.cid=pfg_characteristic.id');
- if(!empty($input['page']))
- {
- $query->limit = $input['limit'];
- $query->offset = ($input['page']-1 )* $input['limit'];
- }
- return $query->orderBy(['pfg_push_characteristic.create_at'=>SORT_DESC])->asArray()->all();
- }
- public function WhereColumn($query)
- {
- }
- public function Total()
- {
- $query = self::find();
- $query->andWhere(['pfg_push_characteristic.del'=>$this->setDel]);
- $query->leftJoin('pfg_characteristic','pfg_push_characteristic.cid=pfg_characteristic.id');
- return $query->count();
- }
- public function Homegetlist($limit = 7)
- {
- $query = self::find();
- $query->select(['pfg_push_characteristic.img','pfg_push_characteristic.style','pfg_characteristic.name','pfg_push_characteristic.cid']);
- $query->andWhere(['pfg_push_characteristic.del'=>$this->setDel]);
- $query->andWhere(['pfg_push_characteristic.is_show'=>1]);
- $query->leftJoin('pfg_characteristic','pfg_push_characteristic.cid=pfg_characteristic.id');
- $query->limit = $limit;
- return $query->orderBy(['pfg_push_characteristic.sort'=>SORT_ASC])->asArray()->all();
- }
- }
|