Appointment.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace app\model;
  3. use DateTimeInterface;
  4. use support\Model;
  5. class Appointment extends Model
  6. {
  7. protected $table = 'appointment';
  8. protected $primaryKey = 'appointment_id';
  9. protected $keyType = 'string';
  10. protected $dateFormat = 'U';
  11. const CREATED_AT = 'appointment_addtimes';
  12. const UPDATED_AT = 'null';
  13. protected function serializeDate(DateTimeInterface $date)
  14. {
  15. return $date->format('Y-m-d H:i:s');
  16. }
  17. /**
  18. * @Desc 关联用户
  19. * @Author Gorden
  20. * @Date 2024/3/29 10:59
  21. *
  22. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  23. */
  24. public function member()
  25. {
  26. return $this->hasOne(Member::class, 'member_id', 'join_appointment_member_id');
  27. }
  28. /**
  29. * @Desc 关联商品
  30. * @Author Gorden
  31. * @Date 2024/3/29 10:58
  32. *
  33. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  34. */
  35. public function goods()
  36. {
  37. return $this->hasOne(Goods::class, 'goods_id', 'join_appointment_goods_id');
  38. }
  39. /**
  40. * @Desc 关联订单
  41. * @Author Gorden
  42. * @Date 2024/3/29 10:58
  43. *
  44. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  45. */
  46. public function order()
  47. {
  48. return $this->hasOne(Order::class, 'order_id', 'join_appointment_order_id');
  49. }
  50. /**
  51. * @Desc 关联权益
  52. * @Author Gorden
  53. * @Date 2024/3/29 10:58
  54. *
  55. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  56. */
  57. public function benefit()
  58. {
  59. return $this->hasOne(MemberBenefit::class, 'member_benefit_id', 'join_appointment_member_benefit_id');
  60. }
  61. }