| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 | <?phpnamespace app\common\model;use think\Model;class AppointmentTicket extends Model{    protected $autoWriteTimestamp = false;    public function getAppointmentDaytimeAttr($value, $data)    {        return $value ? date('Y-m-d', $value) : '';    }    //morning_use    public function getMorningUseAttr($value, $data)    {        return (new AppointmentApplication())->where([            'appointment_period' => AppointmentApplication::APPOINTMENT_PERIOD_MORNING,            'appointment_ticket_id' => $this->id,        ])->count();    }    //afternoon_use    public function getAfternoonUseAttr($value, $data)    {        return (new AppointmentApplication())->where([            'appointment_period' => AppointmentApplication::APPOINTMENT_PERIOD_AFTERNOON,            'appointment_ticket_id' => $this->id,        ])->count();    }    //night_use    public function getNightUseAttr($value, $data)    {        return (new AppointmentApplication())->where([            'appointment_period' => AppointmentApplication::APPOINTMENT_PERIOD_NIGHT,            'appointment_ticket_id' => $this->id,        ])->count();    }    //关联专家    public function specialist()    {        return $this->belongsTo('Specialist', 'provider_id');    }    //关联放号配置    public function appointment()    {        return $this->belongsTo('Appointment');    }    //关联地址    public function address()    {        return $this->belongsTo('Address');    }}
 |