123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/3/4
- * Time: 上午9:40
- */
- namespace common\models;
- class Lookhouse extends Common
- {
- public function rules()
- {
- return [
- [['title','hid','odiscount','recommend'],'required','message'=>'{attribute}不能为空'],
- ['is_show','default','value'=>2],
- ['is_show','in','range'=>[1,2]],
- ['del','in','range'=>[1,2]],
- ['is_num','in','range'=>[1,2]],
- ['type','in','range'=>[1,2]],
- ['img','string','max'=>40],
- ['tel','string','max'=>15],
- [['uid','click','click_true','attend_num'],'number'],
- ['introduce','string'],
- ['satisfaction','number'],
- [['start_at','end_at'],'date', 'format'=>'yyyy-mm-dd HH:mm:ss','message'=>'时间格式为:1990-01-01 00:00:00'],
- ];
- }
- public function attributeLabels()
- {
- return [
- 'title'=>'标题',
- // 'description'=>'描述',
- 'author'=>'作者',
- 'odiscount'=>'优惠说明',
- 'recommend'=>'推荐理由',
- 'start_at'=>'开始时间',
- 'end_at'=>'结束时间',
- 'tel'=>'电话',
- 'hid'=>'楼盘',
- 'img'=>'缩略图',
- 'attend_num'=>'参团人数',
- 'type'=>'标签',
- 'is_num'=>'标识',//标识单个楼盘还是多个楼盘
- 'click'=>'点击数',
- 'click_true'=>'真实点击数',
- 'uid'=>'添加人',
- ];
- }
- 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($data)
- {
- $query = $this->QueryFind();
- $query->select(['pfg_link.*','pfg_category_city.city_name','pfg_sysmenu_q.name as sys_name']);
- $query = $this->LeftJoinWhere($query);
- $query = $this->LeftJoinTable($query);
- if(!empty($data['page']))
- {
- $query->offset = ($data['page'] - 1) * $data['limit'];
- $query->limit = $data['limit'];
- }
- return $query->orderBy('create_at')->asArray()->all();
- }
- public function Total()
- {
- $query = $this->QueryFind();
- $query = $this->LeftJoinWhere($query);
- $query = $this->LeftJoinTable($query);
- return $query->count();
- }
- private function LeftJoinWhere($query)
- {
- $query->andWhere(['pfg_link.del'=>$this->setDel]);
- return $query;
- }
- private function LeftJoinTable($query)
- {
- $query->leftJoin('pfg_category_city','pfg_link.city = pfg_category_city.id');
- $query->leftJoin('pfg_sysmenu_q','pfg_link.linktype = pfg_sysmenu_q.id');
- return $query;
- }
- private function QueryFind()
- {
- return self::find();
- }
- }
|