public function getAppointments() { $appointments = Appointment::all(); $calendarAppointments = array(); foreach ($appointments as $a) { $customer = Customer::find($a['customer_id']); $customer = $customer->first_name . ' ' . $customer->last_name; $event = array('title' => 'Appointment with ' . $customer, 'start' => $a['appointment_datetime']); array_push($calendarAppointments, $event); } return response()->json($calendarAppointments); }
/** * Retrieves all appointments and returns them * in fullCalendar expected JSON */ public function GetAllAppointments() { $appointments = Appointment::all(); $calendarAppointments = array(); foreach ($appointments as $a) { $customer = Customer::find($a['customer_id']); $customer = $customer->first_name . ' ' . $customer->last_name; $package = Package::find($a['appointment_type']); $startDate = date_create($a['appointment_datetime']); $endDate = date_create($a['appointment_datetime']); $time = (string) $package->package_time . ' hours'; $endDate = date_add($endDate, date_interval_create_from_date_string($time)); $event = array('id' => $a['id'], 'title' => 'Appointment with ' . $customer, 'start' => $startDate->format('Y-m-d\\TH:i:s'), 'end' => $endDate->format('Y-m-d\\TH:i:s')); array_push($calendarAppointments, $event); } return response()->json($calendarAppointments); }