Card.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. namespace app\model;
  3. use DateTimeInterface;
  4. use support\Model;
  5. class Card extends Model
  6. {
  7. public $table = 'card';
  8. public $primaryKey = 'card_id';
  9. public $keyType = 'string';
  10. protected $dateFormat = 'U';
  11. const CREATED_AT = 'card_addtimes';
  12. const UPDATED_AT = null;
  13. public 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/11/15 14:39
  21. *
  22. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  23. */
  24. public function member()
  25. {
  26. return $this->hasOne(Member::class, 'member_id', 'join_card_member_id');
  27. }
  28. /**
  29. * @Desc 关联会员详情表
  30. * @Author Gorden
  31. * @Date 2024/11/15 15:57
  32. *
  33. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  34. */
  35. public function info()
  36. {
  37. return $this->hasOne(MemberInfo::class, 'join_info_member_id', 'join_card_member_id')
  38. ->select('join_info_member_id', 'member_info_nickname', 'member_info_headimg');
  39. }
  40. /**
  41. * @Desc 关联会员认证表
  42. * @Author Gorden
  43. * @Date 2024/11/15 14:39
  44. *
  45. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  46. */
  47. public function cert()
  48. {
  49. return $this->hasOne(MemberCert::class, 'join_cert_member_id', 'join_card_member_id')
  50. ->select('join_cert_member_id', 'member_cert_name');
  51. }
  52. /**
  53. * @Desc 关联部门
  54. * @Author Gorden
  55. * @Date 2024/11/15 14:43
  56. *
  57. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  58. */
  59. public function dept()
  60. {
  61. return $this->hasOne(SysDept::class, 'dept_id', 'join_card_dept_id')->select('dept_id', 'dept_name');
  62. }
  63. /**
  64. * @Desc 关联后台用户
  65. * @Author Gorden
  66. * @Date 2024/11/15 14:44
  67. *
  68. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  69. */
  70. public function user()
  71. {
  72. return $this->hasOne(SysUser::class, 'user_id', 'join_card_user_id')->select('user_id', 'user_name');
  73. }
  74. /**
  75. * @Desc 关联卡主表
  76. * @Author Gorden
  77. * @Date 2024/11/15 14:55
  78. *
  79. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  80. */
  81. public function main()
  82. {
  83. return $this->hasOne(CardMain::class, 'card_main_id', 'join_card_main_id');
  84. }
  85. /**
  86. * @Desc 关联发行表
  87. * @Author Gorden
  88. * @Date 2024/11/15 14:56
  89. *
  90. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  91. */
  92. public function issue()
  93. {
  94. return $this->hasOne(CardIssue::class, 'card_issue_id', 'join_card_issue_id');
  95. }
  96. }