PushmVilla.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 PushmVilla extends Common
  10. {
  11. public function rules()
  12. {
  13. return [
  14. [['title','url'],'required','message'=>'{attribute}不能为空'],
  15. ['url', 'url', 'defaultScheme' => 'http','message'=>'请输入正确的地址'],
  16. ['title','string','max'=>50],
  17. ['city','number'],
  18. ['developers','number'],
  19. ['hid','number','message'=>'请选择楼盘'],
  20. ['sort','number','message'=>'排序只能是数字'],
  21. ['sort','number','max'=>10000],
  22. ];
  23. }
  24. public function attributeLabels()
  25. {
  26. return [
  27. 'hid'=>'楼盘名称',
  28. 'url'=>'地址',
  29. 'title'=>'标题',
  30. ];
  31. }
  32. public function Authenticator($input)
  33. {
  34. $this->load($input,'');
  35. if(!$this->validate()) return $this->errors;
  36. return $this;
  37. }
  38. public function FindById($id)
  39. {
  40. return self::findOne($id);
  41. }
  42. public function getList($input)
  43. {
  44. $query = self::find();
  45. $query->select(['pfg_house.name','pfg_pushm_villa.id','pfg_pushm_villa.hid','pfg_pushm_villa.img','pfg_pushm_villa.url','pfg_pushm_villa.title','pfg_pushm_villa.create_at','pfg_pushm_villa.is_show']);
  46. $query->andWhere(['pfg_pushm_villa.del'=>$this->setDel]);
  47. $query->leftJoin('pfg_house','pfg_pushm_villa.hid=pfg_house.id');
  48. if(!empty($input['page']))
  49. {
  50. $query->limit = $input['limit'];
  51. $query->offset = ($input['page']-1 )* $input['limit'];
  52. }
  53. return $query->orderBy(['pfg_pushm_villa.create_at'=>SORT_DESC])->asArray()->all();
  54. }
  55. public function WhereColumn($query)
  56. {
  57. }
  58. public function Total()
  59. {
  60. $query = self::find();
  61. $query->andWhere(['pfg_pushm_villa.del'=>$this->setDel]);
  62. $query->leftJoin('pfg_house','pfg_pushm_villa.hid=pfg_house.id');
  63. return $query->count();
  64. }
  65. public function HomeGetList($limit = 10)
  66. {
  67. $query = self::find();
  68. $query->select(['img','url','title']);
  69. $query->andWhere(['del'=>$this->setDel]);
  70. $query->andFilterWhere(['city'=>$this->city]);
  71. $query->andWhere(['is_show'=>1]);
  72. $query->orderBy(['sort'=>SORT_ASC]);
  73. $query->limit = $limit;
  74. return $query->all();
  75. }
  76. /**不分地区读取全部*/
  77. public function GetAllList()
  78. {
  79. $query = self::find();
  80. $query->select(['img','url','title']);
  81. $query->andWhere(['del'=>$this->setDel]);
  82. $query->andWhere(['is_show'=>1]);
  83. $query->orderBy(['sort'=>SORT_ASC]);
  84. $query->limit = 5;
  85. return $query->all();
  86. }
  87. }