Appointment.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. public function memberInfo()
  29. {
  30. return $this->hasOne(MemberInfo::class, 'join_info_member_id', 'join_appointment_member_id')
  31. ->select('join_info_member_id', 'member_info_nickname');
  32. }
  33. public function cert()
  34. {
  35. return $this->hasOne(MemberCert::class, 'join_cert_member_id', 'join_appointment_member_id')
  36. ->select('join_cert_member_id', 'member_cert_name');
  37. }
  38. /**
  39. * @Desc 关联商品
  40. * @Author Gorden
  41. * @Date 2024/3/29 10:58
  42. *
  43. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  44. */
  45. public function goods()
  46. {
  47. return $this->hasOne(Goods::class, 'goods_id', 'join_appointment_goods_id');
  48. }
  49. /**
  50. * @Desc 关联订单
  51. * @Author Gorden
  52. * @Date 2024/3/29 10:58
  53. *
  54. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  55. */
  56. public function order()
  57. {
  58. return $this->hasOne(Order::class, 'order_id', 'join_appointment_order_id');
  59. }
  60. public function running()
  61. {
  62. return $this->hasOne(GoodsRunning::class, 'join_running_goods_id', 'join_appointment_goods_id')
  63. ->select('join_running_goods_id', 'goods_running_storage', 'goods_running_sale');
  64. }
  65. /**
  66. * @Desc 关联权益
  67. * @Author Gorden
  68. * @Date 2024/3/29 10:58
  69. *
  70. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  71. */
  72. public function benefit()
  73. {
  74. return $this->hasOne(MemberBenefit::class, 'member_benefit_id', 'join_appointment_member_benefit_id');
  75. }
  76. public function sku(){
  77. return $this->hasMany(GoodsSku::class,'join_sku_goods_id','join_appointment_goods_id')
  78. ->select('goods_sku_id','goods_sku_specs_json','goods_sku_sales_price');
  79. }
  80. }