Task.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace app\model;
  3. use DateTimeInterface;
  4. use support\Model;
  5. class Task extends Model
  6. {
  7. protected $table = 'task';
  8. protected $primaryKey = 'task_id';
  9. protected $dateFormat = 'U';
  10. const CREATED_AT = 'task_addtimes';
  11. const UPDATED_AT = null;
  12. protected 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/4/7 15:24
  20. *
  21. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  22. */
  23. public function member()
  24. {
  25. return $this->hasOne(Member::class, 'member_id', 'join_task_apply_user_id');
  26. }
  27. /**
  28. * @Desc 受理人
  29. * @Author Gorden
  30. * @Date 2024/4/7 15:24
  31. *
  32. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  33. */
  34. public function user()
  35. {
  36. return $this->hasOne(SysUser::class, 'user_id', 'join_task_assign_user_id');
  37. }
  38. /**
  39. * @Desc 关联订单
  40. * @Author Gorden
  41. * @Date 2024/4/7 16:02
  42. *
  43. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  44. */
  45. public function order()
  46. {
  47. return $this->hasOne(Order::class, 'order_id', 'join_task_order_id');
  48. }
  49. public function memberInfo()
  50. {
  51. return $this->hasOne(MemberInfo::class, 'join_info_member_id', 'join_task_apply_user_id')
  52. ->select('join_info_member_id', 'member_info_nickname');
  53. }
  54. public function cert()
  55. {
  56. return $this->hasOne(MemberCert::class, 'join_cert_member_id', 'join_task_apply_user_id')
  57. ->select('join_cert_member_id', 'member_cert_name');
  58. }
  59. /**
  60. * @Desc 关联预约
  61. * @Author Gorden
  62. * @Date 2024/4/7 16:03
  63. *
  64. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  65. */
  66. public function appointment()
  67. {
  68. return $this->hasOne(Appointment::class, 'appointment_id', 'join_task_appointment_id');
  69. }
  70. }