private function prepare_email_data($booking_data) { $data = []; $emails = []; $data['names']['player1'] = User::find($booking_data->player1_id)->first_name; $data['names']['player2'] = $booking_data->player2_id ? User::find($booking_data->player2_id)->first_name : false; $data['time_slot_id'] = Time_slot::find($booking_data->time_slot_id)->time_slot; $data['booking_date'] = $booking_data->booking_date; $data['court_id'] = $booking_data->court_id; $emails[] = User::find($booking_data->player1_id)->email; $booking_data->player2_id ? $emails[] = User::find($booking_data->player2_id)->email : false; $data['emails'] = $emails; return $data; }
/** * Sort through existing block booking under users name, first combine repeat booking then create one row with the booking details to loop through for view. * @param $bookings * @return array */ private function sortBlockBookingsForView($bookings) { $sorted_bookings = []; foreach ($bookings as $booking) { $time = $booking->time_slot_id; $time > 0 ? $booking['time_slot_id'] = date('g:i A', strtotime(Time_slot::find($time)->time_slot)) : ($booking['time_slot_id'] = 'ALL DAY'); $sorted_bookings[$booking['created_at']->toDateTimeString()][$booking->booking_date][$booking->time_slot_id] = $booking; } $display_data = []; foreach ($sorted_bookings as $data => $value) { $a['id'] = current(current($value))->id; $a['start_date'] = current(current($value))->booking_date; $a['end_date'] = current(end($value))->booking_date; $a['created_at'] = current(current($value))->created_at; $a['court'] = (string) current(current($value))->court_id; $a['player1'] = User::find(current(current($value))->player1_id)->first_name . ' ' . User::find(current(current($value))->player1_id)->last_name; $a['booking_description'] = (string) current(current($value))->booking_description; $times = array_keys(current($value)); $a['start_time'] = reset($times); $end_time = strtotime('+45 minutes', strtotime(end($times))); $a['end_time'] = date('g:i A', $end_time); $display_data[] = $a; } return $display_data; }