PushFreshimg.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 PushFreshimg extends Common
  10. {
  11. public function rules()
  12. {
  13. return [
  14. ['url', 'url', 'defaultScheme' => 'http','message'=>'请输入正确的地址'],
  15. ];
  16. }
  17. public function attributeLabels()
  18. {
  19. return [
  20. 'url'=>'地址',
  21. ];
  22. }
  23. public function Authenticator($input)
  24. {
  25. $this->load($input,'');
  26. if(!$this->validate()) return $this->errors;
  27. return $this;
  28. }
  29. public function FindById($id)
  30. {
  31. return self::findOne($id);
  32. }
  33. public function getList($input)
  34. {
  35. $query = self::find();
  36. $query->select(['url','id','img','create_at','is_show']);
  37. $query->andWhere(['del'=>$this->setDel]);
  38. if(!empty($input['page']))
  39. {
  40. $query->limit = $input['limit'];
  41. $query->offset = ($input['page']-1 )* $input['limit'];
  42. }
  43. return $query->orderBy(['create_at'=>SORT_DESC])->asArray()->all();
  44. }
  45. public function WhereColumn($query)
  46. {
  47. }
  48. public function Total()
  49. {
  50. $query = self::find();
  51. $query->andWhere(['del'=>$this->setDel]);
  52. return $query->count();
  53. }
  54. public function Oneinfo()
  55. {
  56. $query = self::find();
  57. $query->select(['img','url']);
  58. $query->andWhere(['del'=>$this->setDel]);
  59. $query->andWhere(['is_show'=>1]);
  60. $query->limit = 1;
  61. return $query->asArray()->one();
  62. }
  63. }