123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/3/4
- * Time: 上午9:42
- */
- namespace common\models;
- class NewsRenovationcontent extends Common
- {
- public function rules()
- {
- return [
- ['label_id', 'unique', 'targetClass' => 'common\models\NewsRenovationcontent','on'=>['add'],'message'=>'该栏目已存在','filter'=>function($query){
- $query->andWhere(['del'=>$this->setDel]);
- $query->andWhere(['label_id'=>$this->label_id]);
- $query->andWhere(['nid'=>$this->nid]);
- return $query;
- }],
- [['nid','content','label_id'],'required','message'=>'{attribute}不能为空'],
- ['sort','number'],
- ['is_show','in','range'=>[1,2]],
- ['del','in','range'=>[1,2]],
- ];
- }
- public function attributeLabels()
- {
- return [
- 'nid'=>'装修品鉴标题',
- 'label_id'=>'栏目',
- 'content'=>'内容',
- ];
- }
- public function FindById($id)
- {
- return self::findOne($id);
- }
- public function Authenticator($input)
- {
- $this->load($input,'');
- if($this->validate()) return $this;
- return $this->errors;
- }
- public function getList($page)
- {
- $query = self::find();
- $query->select(['pfg_category_label.name','pfg_news_renovationcontent.sort','pfg_news_renovationcontent.create_at','pfg_news_renovationcontent.is_show','pfg_news_renovationcontent.id']);
- $query->andWhere(['pfg_news_renovationcontent.del'=>$this->setDel]);
- $query->andWhere(['pfg_news_renovationcontent.nid'=>$this->nid]);
- if(!empty($page['page']))
- {
- $query->offset = ($page['page'] - 1) * $page['limit'];
- $query->limit = $page['limit'];
- }
- $query->leftJoin('pfg_category_label','pfg_news_renovationcontent.label_id = pfg_category_label.id');
- return $query->orderBy(['pfg_news_renovationcontent.sort'=>SORT_DESC])->asArray()->all();
- }
- public function PcLabel()
- {
- $query = self::find();
- $query->select(['pfg_news_renovationcontent.id','pfg_category_label.name','pfg_category_label.img','pfg_category_label.img1','pfg_news_renovationcontent']);
- $query->andWhere(['pfg_news_renovationcontent.del'=>1]);
- $query->andWhere(['pfg_news_renovationcontent.is_show'=>1]);
- $query->andWhere(['pfg_category_label.del'=>1]);
- $query->andWhere(['pfg_news_renovationcontent.nid'=>$this->nid]);
- $query->leftJoin('pfg_category_label','pfg_news_renovationcontent.label_id = pfg_category_label.id');
- $query->orderBy(['pfg_category_label.sort'=>SORT_DESC]);
- return $query->asArray()->all();
- }
- public function getListTotal()
- {
- $query = self::find();
- $query->andWhere(['pfg_news_renovationcontent.del'=>$this->setDel]);
- $query->andWhere(['pfg_news_renovationcontent.nid'=>$this->nid]);
- return $query->count();
- }
- public function MLabel()
- {
- $query = self::find();
- $query->select(['pfg_news_renovationcontent.id','pfg_category_label.name','pfg_category_label.img','pfg_category_label.img1','pfg_news_renovationcontent.content']);
- $query->andWhere(['pfg_news_renovationcontent.del'=>1]);
- $query->andWhere(['pfg_news_renovationcontent.is_show'=>1]);
- $query->andWhere(['pfg_category_label.del'=>1]);
- $query->andWhere(['pfg_news_renovationcontent.nid'=>$this->nid]);
- $query->leftJoin('pfg_category_label','pfg_news_renovationcontent.label_id = pfg_category_label.id');
- $query->orderBy(['pfg_category_label.sort'=>SORT_DESC]);
- return $query->asArray()->all();
- }
- public function Total()
- {
- $query = self::find();
- $query->andWhere(['nid'=>$this->nid]);
- $query->andWhere(['del'=>$this->setDel]);
- return $query->count();
- }
- /**
- *
- */
- public function RecordClick()
- {
- }
- }
|