123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <?php
- namespace common\models;
- class MiniRotation extends Common
- {
- public function rules()
- {
- return [
- // ['url', 'url', 'defaultScheme' => 'https','message'=>'请输入正确的地址'],
- ['url','string','max'=>255],
- ['title','string','max'=>50],
- ['img','string','max'=>50],
- ['hid','number','message'=>'请选择楼盘'],
- ['sort','number','message'=>'排序只能是数字'],
- ['city','default','value'=>0],
- ['city','number'],
- ['sort','number','max'=>10000],
- ['type','number'],
- ['expiration_date','string'],
- ];
- }
- public function attributeLabels()
- {
- return [
- 'hid'=>'楼盘名称',
- 'url'=>'地址',
- 'title'=>'标题',
- 'city'=>'区域',
- ];
- }
- 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.city_name','pfg_house.name','pfg_mini_rotation.id','pfg_mini_rotation.hid',
- 'pfg_mini_rotation.img','pfg_mini_rotation.url','pfg_mini_rotation.title','pfg_mini_rotation.create_at',
- 'pfg_mini_rotation.is_show','pfg_mini_rotation.expiration_date']);
- $query->andWhere(['pfg_mini_rotation.del'=>$this->setDel]);
- $query->leftJoin('pfg_house','pfg_mini_rotation.hid=pfg_house.id');
- $query->leftJoin('pfg_category_city','pfg_mini_rotation.city=pfg_category_city.id');
- if (!empty($input['type'])) {
- $query->andWhere(['pfg_mini_rotation.type'=>$input['type']]);
- }
- if(!empty($input['city']))
- {
- $query->andFilterWhere(['pfg_mini_rotation.city'=>$input['city']]);
- }
- if(!empty($input['page']))
- {
- $query->limit = $input['limit'];
- $query->offset = ($input['page']-1 )* $input['limit'];
- }
- return $query->orderBy(['pfg_mini_rotation.is_show'=>SORT_ASC,'pfg_mini_rotation.sort'=>SORT_DESC,'pfg_mini_rotation.create_at'=>SORT_DESC])->asArray()->all();
- }
- public function WhereColumn($query)
- {
- }
- public function Total($input)
- {
- $query = self::find();
- $query->andWhere(['pfg_mini_rotation.del'=>$this->setDel]);
- if (!empty($input['type'])) {
- $query->andWhere(['pfg_mini_rotation.type'=>$input['type']]);
- }
- if(!empty($input['city']))
- {
- $query->andFilterWhere(['pfg_mini_rotation.city'=>$input['city']]);
- }
- $query->leftJoin('pfg_house','pfg_mini_rotation.hid=pfg_house.id');
- return $query->count();
- }
- public function HomeGetList()
- {
- $query = self::find();
- $query->select(['img','url','title']);
- $query->andWhere(['del'=>$this->setDel]);
- $query->andFilterWhere(['city'=>$this->city]);
- $query->andWhere(['is_show'=>1,'type'=>1]);
- $query->orderBy(['sort'=>SORT_DESC]);
- $query->limit = 5;
- return $query->all();
- }
- /**不分地区读取全部*/
- public function GetAllList()
- {
- $query = self::find();
- $query->select(['img','url','title']);
- $query->andWhere(['del'=>$this->setDel]);
- $query->andWhere(['is_show'=>1,'type'=>1]);
- $query->orderBy(['sort'=>SORT_DESC]);
- $query->limit = 5;
- return $query->all();
- }
- public function getAll($limit,$type)
- {
- $query = self::find();
- $query->select(['img','url','title','expiration_date']);
- $query->andWhere(['del'=>$this->setDel]);
- $query->andWhere(['is_show'=>1,'type'=>$type]);
- $query->orderBy(['sort'=>SORT_DESC]);
- $query->limit = $limit;
- return $query->asArray()->all();
- }
- }
|