CouponDetail.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace app\model;
  3. use support\Model;
  4. class CouponDetail extends Model
  5. {
  6. protected $table = 'coupon_detail';
  7. protected $primaryKey = 'coupon_id';
  8. protected $dateFormat = 'U';
  9. const CREATED_AT = 'coupon_detail_addtimes';
  10. const UPDATED_AT = null;
  11. public function serializeDate(\DateTimeInterface $date)
  12. {
  13. return $date->format('Y-m-d H:i:s');
  14. }
  15. public function detail()
  16. {
  17. return $this->hasMany(CouponDetail::class,'join_detail_coupon_id','join_detail_coupon_id');
  18. }
  19. /**
  20. * @Desc 关联会员
  21. * @Author Gorden
  22. * @Date 2024/3/30 13:08
  23. *
  24. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  25. */
  26. public function member()
  27. {
  28. return $this->hasOne(Member::class, 'member_id', 'join_coupon_detail_member_id');
  29. }
  30. /**
  31. * @Desc 关联实名
  32. * @Author Gorden
  33. * @Date 2024/8/21 13:50
  34. *
  35. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  36. */
  37. public function cert()
  38. {
  39. return $this->hasOne(MemberCert::class, 'join_cert_member_id', 'join_coupon_detail_member_id');
  40. }
  41. /**
  42. * @Desc 关联详情
  43. * @Author Gorden
  44. * @Date 2024/8/21 13:51
  45. *
  46. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  47. */
  48. public function info()
  49. {
  50. return $this->hasOne(MemberInfo::class, 'join_info_member_id', 'join_coupon_detail_member_id');
  51. }
  52. /**
  53. * @Desc 关联优惠券
  54. * @Author Gorden
  55. * @Date 2024/3/30 13:08
  56. *
  57. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  58. */
  59. public function coupon()
  60. {
  61. return $this->hasOne(Coupon::class, 'coupon_id', 'join_detail_coupon_id');
  62. }
  63. }