function run() { $booking_cat = []; $booking_cat = ['practice', 'social', 'ladder', 'block']; foreach ($booking_cat as $key => $value) { Bookings_category::create(array('category_description' => $value)); } }
/** * 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; }