PushmRecommend.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 PushmRecommend extends Common
  10. {
  11. public function rules()
  12. {
  13. return [
  14. [['url','title'],'required','message'=>'{attribute}不能为空'],
  15. ['url', 'url', 'defaultScheme' => 'http','message'=>'请输入正确的地址'],
  16. ['title','string','max'=>50],
  17. ['url','string','max'=>255],
  18. ['hid','number','message'=>'请选择楼盘'],
  19. ['sort','number','message'=>'排序只能是数字'],
  20. ['sort','number','max'=>10000],
  21. ];
  22. }
  23. public function attributeLabels()
  24. {
  25. return [
  26. 'hid'=>'楼盘名称',
  27. 'url'=>'地址',
  28. ];
  29. }
  30. public function Authenticator($input)
  31. {
  32. $this->load($input,'');
  33. if(!$this->validate()) return $this->errors;
  34. return $this;
  35. }
  36. public function FindById($id)
  37. {
  38. return self::findOne($id);
  39. }
  40. public function getList($input)
  41. {
  42. $query = self::find();
  43. $query->select(['id','title','create_at','is_show','url']);
  44. $query->andWhere(['del'=>$this->setDel]);
  45. if(!empty($input['page']))
  46. {
  47. $query->limit = $input['limit'];
  48. $query->offset = ($input['page']-1 )* $input['limit'];
  49. }
  50. return $query->orderBy(['create_at'=>SORT_DESC])->asArray()->all();
  51. }
  52. public function WhereColumn($query)
  53. {
  54. }
  55. public function Total()
  56. {
  57. $query = self::find();
  58. $query->andWhere(['del'=>$this->setDel]);
  59. return $query->count();
  60. }
  61. public function Homegetlist($limit)
  62. {
  63. $query = self::find();
  64. $query->select(['url','title']);
  65. $query->andWhere(['del'=>$this->setDel]);
  66. $query->andWhere(['is_show'=>1]);
  67. $query->orderBy(['sort'=>SORT_ASC]);
  68. $query->limit = $limit;
  69. return $query->all();
  70. }
  71. }