public function getFreeSlotByDoctor($doctor_id) { if (!Patient::isPatient() && !HospitalEmployee::isDoctor() && !HospitalEmployee::isStaff()) { return response()->json(["success" => false, "error" => 'notlogin or notvalid']); } return response()->json(["success" => true, "data" => DoctorTime::getFreeSlotByDoctor($doctor_id)]); }
public static function createNextAppointment($doctor_id, $appointment) { $freeSlots = DoctorTime::getFreeSlotByDoctor($doctor_id); foreach ($freeSlots as $freeSlot) { $datetime = $freeSlot['datetime']; if ($datetime < new \DateTime($appointment->time)) { continue; } return Appointment::makeAppointment($doctor_id, $appointment->patient_id, $datetime); } }