public static function makeAppointment($emp_id, $patient_id, $datetime) { $error = []; if ($datetime == null) { $error[] = 'datetime_not_found'; } if ($patient_id == null) { $error[] = 'patient_id_not_found'; } if ($emp_id == null) { $error[] = 'emp_id_not_found'; } if (Appointment::where('time', $datetime)->where('emp_id', $emp_id)->first()) { $error[] = 'this_time_not_available'; } if (sizeof($error) == 0) { $appointment = new Appointment(); $appointment->time = $datetime; $appointment->emp_id = $emp_id; $appointment->patient_id = $patient_id; $appointment->save(); return ["success" => true, "data" => $appointment->toArray()]; } else { return ["success" => false, "message" => $error]; } }