Create a gist now

Instantly share code, notes, and snippets.

//using on patientDashboard - from today
public function nextAppointment($patient_id) {
$start = Time::now()->toDateString(); // today
$event = $this->Events->findByPatientId($patient_id)
->contain(['Facilities', 'Providers' => ['Users']])
->where(['Events.start >= :now'])
->bind(':now', $start, 'time')->first();
$this->set(compact('event'));
}
//using on patientDashboard - last recent appointment
public function lastAppointment($patient_id) {
$start = Time::now()->toDateString(); // today
$event = $this->Events->findByPatientId($patient_id)
->contain(['Facilities', 'Providers' => ['Users']])
->where(['Events.start < :now'])
->order(['Events.id' => 'DESC'])
->bind(':now', $start, 'time')
->first();
$this->set(compact('event'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment