public static function toBePrescribe($patientId) { $app = appointment::join('prescription', 'appointment.appointmentId', '=', 'prescription.appointmentId')->join('schedule', 'appointment.scheduleId', '=', 'schedule.scheduleId')->where('appointment.patientId', '=', $patientId)->where('schedule.diagDate', '>', Carbon::now())->whereNull('prescription.pharmacistId')->orderBy('diagDate', 'asc')->orderBy('diagTime', 'asc')->first(); return $app; }