PushmMenu.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/5/21
  6. * Time: 下午5:18
  7. */
  8. namespace common\models;
  9. class PushmMenu extends Common
  10. {
  11. public function rules()
  12. {
  13. return [
  14. ['title','string','max'=>50],
  15. ['city','number'],
  16. ['menu','number'],
  17. ['sort','number','max'=>10000],
  18. ];
  19. }
  20. public function attributeLabels()
  21. {
  22. return [
  23. 'menu'=>'菜单',
  24. 'city'=>'城市',
  25. ];
  26. }
  27. public function Authenticator($input)
  28. {
  29. $this->load($input,'');
  30. if(!$this->validate()) return $this->errors;
  31. return $this;
  32. }
  33. public function FindById($id)
  34. {
  35. return self::findOne($id);
  36. }
  37. public function getList($input)
  38. {
  39. $query = self::find();
  40. $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']);
  41. $query->andWhere(['pfg_pushm_menu.del'=>$this->setDel]);
  42. $query->leftJoin('pfg_category_city','pfg_pushm_menu.city=pfg_category_city.id');
  43. $query->leftJoin('pfg_frontend','pfg_pushm_menu.menu=pfg_frontend.id');
  44. if(!empty($input['page']))
  45. {
  46. $query->limit = $input['limit'];
  47. $query->offset = ($input['page']-1 )* $input['limit'];
  48. }
  49. return $query->orderBy(['pfg_pushm_menu.create_at'=>SORT_DESC])->asArray()->all();
  50. }
  51. public function WhereColumn($query)
  52. {
  53. }
  54. public function Total()
  55. {
  56. $query = self::find();
  57. $query->andWhere(['pfg_pushm_menu.del'=>$this->setDel]);
  58. $query->leftJoin('pfg_house','pfg_pushm_menu.hid=pfg_house.id');
  59. return $query->count();
  60. }
  61. public function HomeGetList($limit = 10)
  62. {
  63. $query = self::find();
  64. $query->select(['img','url','title']);
  65. $query->andWhere(['del'=>$this->setDel]);
  66. //$query->andFilterWhere(['city'=>$this->city]);
  67. $query->andWhere(['is_show'=>1]);
  68. $query->orderBy(['sort'=>SORT_ASC]);
  69. $query->limit = $limit;
  70. return $query->all();
  71. }
  72. /**不分地区读取全部*/
  73. public function GetAllList()
  74. {
  75. $query = self::find();
  76. $query->select(['img','url','title']);
  77. $query->andWhere(['del'=>$this->setDel]);
  78. $query->andWhere(['is_show'=>1]);
  79. $query->orderBy(['sort'=>SORT_ASC]);
  80. $query->limit = 5;
  81. return $query->all();
  82. }
  83. public function SysmenuList($city,$limit,$select = [])
  84. {
  85. $query = self::find();
  86. $query->select(['pfg_frontend.id','pfg_frontend.name','pfg_frontend.url','pfg_frontend.function','pfg_frontend.icon','pfg_pushm_menu.menu']);
  87. $query->andWhere(['pfg_pushm_menu.del'=>$this->setDel]);
  88. $query->andWhere(['pfg_pushm_menu.city'=>$city]);
  89. $query->innerJoin('pfg_frontend','pfg_pushm_menu.menu=pfg_frontend.id and pfg_frontend.status=1 and pfg_frontend.del =1');
  90. $row = $query->one();
  91. if($row)
  92. {
  93. $q = new Frontend();
  94. $q->pid = $row['id'];
  95. return $q->SonList($limit,$select);
  96. }
  97. return false;
  98. // $query->limit = $limit;
  99. // return $query->orderBy(['pfg_frontend.sort'=>SORT_DESC])->asArray()->all();
  100. }
  101. }