AppointmentTicket.php 1.5 KB

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