123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/5/21
- * Time: 下午5:18
- */
- namespace common\models;
- class PushmMenu extends Common
- {
- public function rules()
- {
- return [
- ['title','string','max'=>50],
- ['city','number'],
- ['menu','number'],
- ['sort','number','max'=>10000],
- ];
- }
- public function attributeLabels()
- {
- return [
- 'menu'=>'菜单',
- '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_pushm_menu.id','pfg_frontend.name','pfg_pushm_menu.city','pfg_pushm_menu.menu','pfg_pushm_menu.create_at']);
- $query->andWhere(['pfg_pushm_menu.del'=>$this->setDel]);
- $query->leftJoin('pfg_category_city','pfg_pushm_menu.city=pfg_category_city.id');
- $query->leftJoin('pfg_frontend','pfg_pushm_menu.menu=pfg_frontend.id');
- if(!empty($input['page']))
- {
- $query->limit = $input['limit'];
- $query->offset = ($input['page']-1 )* $input['limit'];
- }
- return $query->orderBy(['pfg_pushm_menu.create_at'=>SORT_DESC])->asArray()->all();
- }
- public function WhereColumn($query)
- {
- }
- public function Total()
- {
- $query = self::find();
- $query->andWhere(['pfg_pushm_menu.del'=>$this->setDel]);
- $query->leftJoin('pfg_house','pfg_pushm_menu.hid=pfg_house.id');
- return $query->count();
- }
- public function HomeGetList($limit = 10)
- {
- $query = self::find();
- $query->select(['img','url','title']);
- $query->andWhere(['del'=>$this->setDel]);
- //$query->andFilterWhere(['city'=>$this->city]);
- $query->andWhere(['is_show'=>1]);
- $query->orderBy(['sort'=>SORT_ASC]);
- $query->limit = $limit;
- return $query->all();
- }
- /**不分地区读取全部*/
- public function GetAllList()
- {
- $query = self::find();
- $query->select(['img','url','title']);
- $query->andWhere(['del'=>$this->setDel]);
- $query->andWhere(['is_show'=>1]);
- $query->orderBy(['sort'=>SORT_ASC]);
- $query->limit = 5;
- return $query->all();
- }
- public function SysmenuList($city,$limit,$select = [])
- {
- $query = self::find();
- $query->select(['pfg_frontend.id','pfg_frontend.name','pfg_frontend.url','pfg_frontend.function','pfg_frontend.icon','pfg_pushm_menu.menu']);
- $query->andWhere(['pfg_pushm_menu.del'=>$this->setDel]);
- $query->andWhere(['pfg_pushm_menu.city'=>$city]);
- $query->innerJoin('pfg_frontend','pfg_pushm_menu.menu=pfg_frontend.id and pfg_frontend.status=1 and pfg_frontend.del =1');
- $row = $query->one();
- if($row)
- {
- $q = new Frontend();
- $q->pid = $row['id'];
- return $q->SonList($limit,$select);
- }
- return false;
- // $query->limit = $limit;
- // return $query->orderBy(['pfg_frontend.sort'=>SORT_DESC])->asArray()->all();
- }
- }
|