ActiveTime.php 1.1 KB

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