AppointmentTicket.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. ])->count();
  21. }
  22. //afternoon_use
  23. public function getAfternoonUseAttr($value, $data)
  24. {
  25. return (new AppointmentApplication())->where([
  26. 'appointment_period' => AppointmentApplication::APPOINTMENT_PERIOD_AFTERNOON,
  27. 'appointment_ticket_id' => $this->id,
  28. ])->count();
  29. }
  30. //night_use
  31. public function getNightUseAttr($value, $data)
  32. {
  33. return (new AppointmentApplication())->where([
  34. 'appointment_period' => AppointmentApplication::APPOINTMENT_PERIOD_NIGHT,
  35. 'appointment_ticket_id' => $this->id,
  36. ])->count();
  37. }
  38. //关联专家
  39. public function specialist()
  40. {
  41. return $this->belongsTo('Specialist', 'provider_id');
  42. }
  43. //关联放号配置
  44. public function appointment()
  45. {
  46. return $this->belongsTo('Appointment');
  47. }
  48. //关联地址
  49. public function address()
  50. {
  51. return $this->belongsTo('Address');
  52. }
  53. }