コード例 #1
1
ファイル: DoctorTime.php プロジェクト: phizaz/se2015-backend
 public static function refreshDoctorTime($doctor_id)
 {
     $appointments = Appointment::where('emp_id', $doctor_id)->get();
     $doctorTimes = DoctorTime::where('doctor_id', $doctor_id)->get();
     foreach ($appointments as $appointment) {
         $aptime = new DateTime($appointment->time);
         $del = true;
         foreach ($doctorTimes as $doctorTime) {
             $begin = new DateTime($doctorTime->doctorTime_begin);
             $end = new DateTime($doctorTime->doctorTime_end);
             if ($aptime >= $begin && $aptime < $end) {
                 $del = false;
             }
         }
         if ($del) {
             // find a new appointment
             Appointment::createNextAppointment($doctor_id, $appointment);
             // delete the old one
             Appointment::deleteAppointment($appointment->appointment_id);
         }
     }
     $docTime = DoctorTime::orderBy('doctorTime_begin', 'asc')->where('doctor_id', $doctor_id)->get();
     return ["success" => true, "new doctorTime" => $docTime];
 }
コード例 #2
0
 public function deleteDoctorTime($doctor_time_id)
 {
     if (!HospitalEmployee::isDoctor()) {
         return response()->json(["success" => false, "messages" => ['notlogin or notvalid']]);
     }
     // if(!HospitalEmployee::isDoctor())
     //     return response()->json(["success" = false];
     $doctorTime = DoctorTime::where('doctorTime_id', $doctor_time_id)->first();
     if ($doctorTime) {
         $doctorTime->delete();
     }
     return response()->json(["success" => true]);
 }