AppointmentTicket.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class AppointmentTicket extends Model
  5. {
  6. protected $autoWriteTimestamp = false;
  7. const STATUS_OPEN = 1;
  8. const STATUS_CLOSE = 0;
  9. //appointment_daytime
  10. public function getAppointmentDaytimeAttr($value, $data)
  11. {
  12. return $value ? date('Y-m-d', $value) : '';
  13. }
  14. //morning_use
  15. public function getMorningUseAttr($value, $data)
  16. {
  17. return (new AppointmentApplication())->where([
  18. 'appointment_period' => AppointmentApplication::APPOINTMENT_PERIOD_MORNING,
  19. 'appointment_ticket_id' => $this->id,
  20. 'status' => ['<>', AppointmentApplication::STATUS_CANCEL]
  21. ])->count();
  22. }
  23. //afternoon_use
  24. public function getAfternoonUseAttr($value, $data)
  25. {
  26. return (new AppointmentApplication())->where([
  27. 'appointment_period' => AppointmentApplication::APPOINTMENT_PERIOD_AFTERNOON,
  28. 'appointment_ticket_id' => $this->id,
  29. 'status' => ['<>', AppointmentApplication::STATUS_CANCEL]
  30. ])->count();
  31. }
  32. //night_use
  33. public function getNightUseAttr($value, $data)
  34. {
  35. return (new AppointmentApplication())->where([
  36. 'appointment_period' => AppointmentApplication::APPOINTMENT_PERIOD_NIGHT,
  37. 'appointment_ticket_id' => $this->id,
  38. 'status' => ['<>', AppointmentApplication::STATUS_CANCEL]
  39. ])->count();
  40. }
  41. //关联专家
  42. public function specialist()
  43. {
  44. return $this->belongsTo('Specialist', 'provider_id');
  45. }
  46. //关联放号配置
  47. public function appointment()
  48. {
  49. return $this->belongsTo('Appointment');
  50. }
  51. //关联地址
  52. public function address()
  53. {
  54. return $this->belongsTo('Address');
  55. }
  56. }