HomeBanner.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace app\admin\model;
  3. use support\Model;
  4. class HomeBanner extends Model
  5. {
  6. const IS_DEL_YES = 1;
  7. const IS_DEL_NO = 0;
  8. /**
  9. * 居家banner
  10. * The table associated with the model.
  11. *
  12. * @var string
  13. */
  14. protected $table = 'home_banner';
  15. public $timestamps = false;
  16. /**
  17. * Notes:获取顶部图
  18. * @param int $banner_category_id
  19. * @return array
  20. * User: YCP
  21. * Date: 2022/11/1
  22. */
  23. public static function getBannerInfo(int $banner_category_id)
  24. {
  25. return static::where(['banner_category_id' => $banner_category_id,'banner_is_del'=>0])
  26. ->get()->toArray();
  27. }
  28. /**
  29. * Notes:获取banner列表
  30. * @return array
  31. * User: YCP
  32. * Date: 2022/11/1
  33. */
  34. public static function getBannerList()
  35. {
  36. $list = static::select('*')
  37. ->where(['banner_is_del'=>static::IS_DEL_NO])
  38. ->get();
  39. $count = static::where(['banner_is_del'=>static::IS_DEL_NO])
  40. ->count();
  41. return [$list, $count];
  42. }
  43. //时间格式
  44. public function getBannerCreateTimeAttribute($value)
  45. {
  46. if($value == 0 || $value == ''){
  47. return 0;
  48. }else{
  49. return date('Y-m-d H:i:s', $value);
  50. }
  51. }
  52. //时间格式
  53. public function getBannerUpdateTimeAttribute($value)
  54. {
  55. if($value == 0 || $value == ''){
  56. return 0;
  57. }else{
  58. return date('Y-m-d H:i:s', $value);
  59. }
  60. }
  61. }