ActiveTime.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. *
  4. * @copyright ©2020 点小铺
  5. * @author hanj
  6. * @link: https://dyuit.com
  7. * Created by VSCode
  8. */
  9. namespace app\common\model\sharp;
  10. use app\common\model\BaseModel;
  11. /**
  12. * 整点秒杀-活动会场场次模型
  13. * Class ActiveTime
  14. * @package app\common\model\sharp
  15. */
  16. class ActiveTime extends BaseModel
  17. {
  18. protected $name = 'sharp_active_time';
  19. /**
  20. * 关联活动会场表
  21. * @return \think\model\relation\BelongsTo
  22. */
  23. public function active()
  24. {
  25. return $this->belongsTo('Active', 'active_id');
  26. }
  27. /**
  28. * 当前场次下秒杀商品的数量
  29. * @return \think\model\relation\HasMany
  30. */
  31. public function goods()
  32. {
  33. return $this->hasMany('ActiveGoods', 'active_time_id');
  34. }
  35. /**
  36. * 获取器:活动场次时间
  37. * @param $value
  38. * @return string
  39. */
  40. public function getActiveTimeAttr($value)
  41. {
  42. return \pad_left($value) . ':00';
  43. }
  44. /**
  45. * 活动会场场次详情
  46. * @param $activeTimeId
  47. * @param array $with
  48. * @return static|null
  49. * @throws \think\exception\DbException
  50. */
  51. public static function detail($activeTimeId, $with = [])
  52. {
  53. return static::get($activeTimeId, $with);
  54. }
  55. }