public function bookeddaysAction() { $model = new Practitioners(); $bookingModel = new Bookings(); $request = $this->getRequest(); if ($request->isPost() && $request->getPost('user') != null) { $api = new Api(); $api_url = $this->getServiceLocator()->get('config')['api_url']['value']; $user_id = $request->getPost('user'); $service_duration = $request->getPost('service_duration', 15); $address_id = $request->getPost('address_id'); $data = array('bookedDates' => array()); // Fetching service providers bookings $bookings = $bookingModel->getBookings($api_url, $user_id); if (isset($bookings['results']) && count($bookings['results']) > 0) { foreach ($bookings['results'] as $booking) { $availableSlots = $bookingModel->getAvailableSlots($api_url, $user_id, date('Y-m-d', strtotime($booking['booked_date'])), $service_duration); if (count($availableSlots) == 0 && !in_array(date('Y-m-d', strtotime($booking['booked_date'])), $data['bookedDates'])) { $data['bookedDates'][] = date('Y-m-d', strtotime($booking['booked_date'])); } } } $data['workdays'] = explode(', ', $model->getSPWorkdays($user_id, $api_url, $address_id)); echo json_encode($data); } exit; }