function run()
 {
     $time_slots = $this->createTimeSlots('7.00am', '10.00pm');
     foreach ($time_slots as $key => $value) {
         Time_slot::create(array('time_slot' => $value));
     }
 }
 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;
 }
 /**
  * Find any existing bookings for a specified date and court. Insert them into the array of time-slots
  * @param  int $court court id
  * @param  string $date date
  * @return array        an array of times-slots and any bookings for a time-slot with the name of user making the booking
  */
 private function getExistingBookings($court, $date)
 {
     $array = $this->makeTimeSlots(Time_slot::all(), $court);
     $bookings = Booking::where('court_id', '=', $court)->where('booking_date', '=', $date)->get();
     foreach ($bookings as $booking) {
         $player1 = $booking->player1_id ? User::withTrashed()->find($booking->player1_id)->first_name . ' ' . User::withTrashed()->find($booking->player1_id)->last_name : false;
         $player2 = $booking->player2_id ? User::withTrashed()->find($booking->player2_id)->first_name . ' ' . User::withTrashed()->find($booking->player2_id)->last_name : false;
         $array[$booking->time_slot_id]['booking_id'] = $booking->id;
         $array[$booking->time_slot_id]['booking_date'] = $booking->booking_date;
         $array[$booking->time_slot_id]['player1'] = $player1;
         $array[$booking->time_slot_id]['player2'] = $player2;
         if (\Auth::user()->user_type == 'administrator' || \Auth::user()->user_type == 'coach') {
             $array[$booking->time_slot_id]['admin'] = true;
         }
         $array[$booking->time_slot_id]['cat_id'] = $booking->booking_cat_id;
         $array[$booking->time_slot_id]['booking_description'] = $booking->booking_description ? strtoupper($booking->booking_description) : strtoupper(Bookings_category::find($booking->booking_cat_id)->category_description);
     }
     return $array;
 }