public function doDragAndDrop(Request $request) { $appointment = Appointment::findOrFail($request->input('appointment_id')); $start_date = $appointment->start_date; $start_time_exploded = explode(":", $request->input('new_start_time')); $start_date->hour = $start_time_exploded[0]; $start_date->minute = $start_time_exploded[1]; $start_date->second = 0; $duration = $appointment->getDuration(); $end_date = $start_date->copy()->addMinutes($duration); if (!Appointment::checkClashingAppointment($request->input('dentist_id'), $start_date, $end_date, $appointment->id)) { $appointment->changeDentist($request->input('dentist_id')); $response = array(); if ($appointment->moveTime($request->input('new_start_time'))) { $response['status'] = 'success'; } else { $response['status'] = 'failure'; $response['message'] = 'The appointment was moved to a position where it clashed with another, please try again.'; } } else { $response['status'] = 'failure'; $response['message'] = 'The appointment was moved to a position where it clashed with another, please try again.'; } die(json_encode($response)); }
public function schedule($date, $start, $end) { $start_date = Carbon::createFromFormat("d-m-Y", $date); $start_time = explode(":", $start); $start_date->hour = $start_time[0]; $start_date->minute = $start_time[1]; $end_date = Carbon::createFromFormat("d-m-Y", $date); $end_time = explode(":", $end); $end_date->hour = $end_time[0]; $end_date->minute = $end_time[1]; if (Appointment::checkClashingAppointment($this->dentist->id, $start_date, $end_date)) { die('An error has occured. This appointment clashes with another. Please try again.'); } $this->start_date = $start_date; $this->end_date = $end_date; $this->booked = 1; Appointment::incrementBookingStats(); $this->save(); }