CardIssue.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\model;
  3. use DateTimeInterface;
  4. use support\Model;
  5. class CardIssue extends Model
  6. {
  7. protected $table = 'card_issue';
  8. protected $primaryKey = 'card_issue_id';
  9. protected $dateFormat = 'U';
  10. const CREATED_AT = 'card_issue_addtimes';
  11. const UPDATED_AT = null;
  12. public function serializeDate(DateTimeInterface $date)
  13. {
  14. return $date->format('Y-m-d H:i:s');
  15. }
  16. /**
  17. * @Desc 关联卡主表
  18. * @Author Gorden
  19. * @Date 2024/11/18 11:15
  20. *
  21. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  22. */
  23. public function main()
  24. {
  25. return $this->hasOne(CardMain::class, 'card_main_id', 'join_issue_card_main_id');
  26. }
  27. /**
  28. * @Desc 关联后台用户
  29. * @Author Gorden
  30. * @Date 2024/11/18 11:15
  31. *
  32. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  33. */
  34. public function user()
  35. {
  36. return $this->hasOne(SysUser::class, 'user_id', 'card_issue_creator_user_id')->select('user_id', 'user_name');
  37. }
  38. }