|
@@ -299,26 +299,12 @@ class Client extends Model
|
|
|
|
|
|
public function nextMcpAppointment()
|
|
|
{
|
|
|
- if ($this->mcp) {
|
|
|
- return Appointment::where('client_id', $this->id)
|
|
|
- ->where('pro_id', $this->mcp->id)
|
|
|
- ->where('start_time', '>=', date('Y-m-d'))
|
|
|
- ->orderBy('start_time', 'asc')
|
|
|
- ->first();
|
|
|
- }
|
|
|
- return false;
|
|
|
+ return $this->hasOne(Appointment::class, 'id', 'next_mcp_appointment_id');
|
|
|
}
|
|
|
|
|
|
public function lastMcpAppointment()
|
|
|
{
|
|
|
- if ($this->mcp) {
|
|
|
- return Appointment::where('client_id', $this->id)
|
|
|
- ->where('pro_id', $this->mcp->id)
|
|
|
- ->where('start_time', '<', date('Y-m-d'))
|
|
|
- ->orderBy('start_time', 'asc')
|
|
|
- ->first();
|
|
|
- }
|
|
|
- return false;
|
|
|
+ return $this->hasOne(Appointment::class, 'id', 'previous_mcp_appointment_id');
|
|
|
}
|
|
|
|
|
|
public function lastMeasurementOfType($_type) {
|