Exemplo n.º 1
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Booking::create([]);
     }
 }
Exemplo n.º 2
0
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['arrive_date' => 'required|date', 'leave_date' => 'required|date', 'personal_ids' => 'required|string', 'room_id' => 'required|numeric']);
     if ($validator->fails()) {
         return $validator->errors()->all();
     }
     $newBooking = Booking::create($request->all());
     return $newBooking;
 }
Exemplo n.º 3
0
 /**
  * Store a newly created resource in storage.
  * POST /bookings
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make(Input::all(), Booking::$rules, Booking::$messages);
     if (Input::get('year') <= 1974) {
         return Redirect::route('too-old');
     }
     if ($validator->fails()) {
         return Redirect::route('bookings', array(Input::get('id'), Input::get('tour_date')))->withErrors($validator)->withInput(Input::except('captcha'));
     }
     //Store into database
     $booking = Booking::create(Input::all());
     //redirect to final confirmation page
     return Redirect::route('bookings.confirm', array($booking->_id));
     //redirect to NABTransact
     //Add in additional NAB Token to database result $booking->id
     //Email management with new booking details
     //Return user to Thank You page
 }
Exemplo n.º 4
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     // $this->call('UserTableSeeder');
     DB::table('bookings')->delete();
     DB::table('registrations')->delete();
     // Church bookings
     Booking::create(array('first' => 'Spencer', 'last' => 'Kaur', 'tickets' => 1, 'source' => 'Church', 'numbers' => '1'));
     Booking::create(array('first' => 'Molly', 'last' => 'Sharpe', 'tickets' => 2, 'source' => 'Church', 'numbers' => '2,3'));
     Booking::create(array('first' => 'Zara', 'last' => 'Sharp', 'tickets' => 4, 'source' => 'Church', 'numbers' => '32,34,36,38'));
     Booking::create(array('first' => 'Archie', 'last' => 'Field', 'tickets' => 8, 'source' => 'Church', 'numbers' => '32,33,34,35,36,37,38,39'));
     Booking::create(array('first' => 'Charles', 'last' => 'Dennis', 'tickets' => 12, 'source' => 'Church', 'numbers' => '132,133,134,135,136,137,138,139,140,141,142'));
     Booking::create(array('first' => 'Jack', 'last' => 'Ryan', 'tickets' => 1, 'source' => 'Church', 'numbers' => '501'));
     Booking::create(array('first' => 'Charlotte', 'last' => 'Crawford', 'tickets' => 2, 'source' => 'Church', 'numbers' => '503,504'));
     Booking::create(array('first' => 'Rebecca', 'last' => 'Atkinson', 'tickets' => 2, 'source' => 'Church', 'numbers' => '505,506'));
     Booking::create(array('first' => 'Lara', 'last' => 'Douglas', 'tickets' => 2, 'source' => 'Church', 'numbers' => '602,605'));
     Booking::create(array('first' => 'Harriet', 'last' => 'Tucker', 'tickets' => 1, 'source' => 'Church'));
     Booking::create(array('first' => 'Lilly', 'last' => 'Charlton', 'tickets' => 1, 'source' => 'Church'));
     Booking::create(array('first' => 'Logan', 'last' => 'Clements', 'tickets' => 2, 'source' => 'Church'));
     $booking = Booking::create(array('first' => 'Evie', 'last' => 'Pritchard', 'tickets' => 1, 'source' => 'Church'));
     $booking->registrations()->save(new Registration(array('tickets' => 2)));
     $booking = Booking::create(array('first' => 'Lara', 'last' => 'Armstrong', 'tickets' => 2, 'source' => 'Church'));
     $booking->registrations()->save(new Registration(array('tickets' => 2)));
     $booking = Booking::create(array('first' => 'Charlie', 'last' => 'Slater', 'tickets' => 6, 'source' => 'Church'));
     $booking->registrations()->save(new Registration(array('tickets' => 2)));
     $booking = Booking::create(array('first' => 'Rachel', 'last' => 'Whittaker', 'tickets' => 1, 'source' => 'Church'));
     $booking->registrations()->save(new Registration(array('tickets' => 1)));
     // EventBrite bookings
     Booking::create(array('first' => 'Lauren', 'last' => 'Conway', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Emily', 'last' => 'Henderson', 'tickets' => 2, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Sienna', 'last' => 'Yates', 'tickets' => 3, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Harrison', 'last' => 'Carroll', 'tickets' => 4, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Taylor', 'last' => 'Palmer', 'tickets' => 8, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Maya', 'last' => 'Marsh', 'tickets' => 10, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Riley', 'last' => 'Farmer', 'tickets' => 7, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Amelia', 'last' => 'Ashton', 'tickets' => 2, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Jonathan', 'last' => 'Riley', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Anthony', 'last' => 'Moss', 'tickets' => 2, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Ellie', 'last' => 'Henry', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Sofia', 'last' => 'Phillips', 'tickets' => 2, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Owen', 'last' => 'Bartlett', 'tickets' => 2, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Alicia', 'last' => 'Jordan', 'tickets' => 4, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Peter', 'last' => 'Hancock', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Aidan', 'last' => 'Walker', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Jennifer', 'last' => 'Sinclair', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Georgina', 'last' => 'Henry', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Jonathan', 'last' => 'Barber', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Francesca', 'last' => 'Rice', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Scott', 'last' => 'Rowe', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Nathan', 'last' => 'Gould', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Harley', 'last' => 'May', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Brandon', 'last' => 'Riley', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Brandon', 'last' => 'Richardson', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Adam', 'last' => 'Little', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Matthew', 'last' => 'Duncan', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Daisy', 'last' => 'Wall', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Louis', 'last' => 'Potts', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Amelie', 'last' => 'Bentley', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Harriet', 'last' => 'Cameron', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Jude', 'last' => 'Fraser', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Aidan', 'last' => 'Farmer', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Rebecca', 'last' => 'Wallace', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Lucas', 'last' => 'Kaur', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Faith', 'last' => 'Bartlett', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Luke', 'last' => 'Cooke', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Lilly', 'last' => 'Farrell', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Peter', 'last' => 'Boyle', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'James', 'last' => 'Kay', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Nicholas', 'last' => 'Morley', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Mason', 'last' => 'Kent', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Sofia', 'last' => 'Freeman', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Isobel', 'last' => 'Watts', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Andrew', 'last' => 'Garner', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Henry', 'last' => 'Farmer', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Louie', 'last' => 'Fowler', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Amy', 'last' => 'Doyle', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Rhys', 'last' => 'Buckley', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Bradley', 'last' => 'Warren', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Sean', 'last' => 'Dennis', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Muhammad', 'last' => 'Murphy', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Nicole', 'last' => 'Robertson', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Aidan', 'last' => 'Hicks', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Abigail', 'last' => 'Page', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Kieran', 'last' => 'Swift', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Isobel', 'last' => 'Austin', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Jake', 'last' => 'Bradley', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Yasmin', 'last' => 'Davey', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Alice', 'last' => 'Shepherd', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Taylor', 'last' => 'Bradshaw', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Kian', 'last' => 'Payne', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Sienna', 'last' => 'Wilkins', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Eleanor', 'last' => 'Collier', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Bradley', 'last' => 'Griffiths', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Jay', 'last' => 'Black', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Rachel', 'last' => 'Duncan', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Harriet', 'last' => 'Chadwick', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Michael', 'last' => 'Hardy', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Courtney', 'last' => 'Kennedy', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Jacob', 'last' => 'North', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Tyler', 'last' => 'Woods', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Isabelle', 'last' => 'Smart', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Aaron', 'last' => 'Norman', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Lydia', 'last' => 'Newman', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Joe', 'last' => 'Richards', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Zoe', 'last' => 'Pollard', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Sam', 'last' => 'Burke', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Isabel', 'last' => 'Winter', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Francesca', 'last' => 'Alexander', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Lily', 'last' => 'Wall', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Cameron', 'last' => 'Miah', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Summer', 'last' => 'Khan', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Rebecca', 'last' => 'Cooke', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Matthew', 'last' => 'Davey', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Daisy', 'last' => 'Khan', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Nathan', 'last' => 'Gough', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Phoebe', 'last' => 'Shaw', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Connor', 'last' => 'Thomas', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Abby', 'last' => 'Hurst', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Toby', 'last' => 'Simmons', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Brooke', 'last' => 'Shah', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Mia', 'last' => 'Anderson', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Luca', 'last' => "O'Sullivan", 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Zachary', 'last' => 'Welch', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Alex', 'last' => 'Baker', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Eve', 'last' => 'Wilkinson', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Oscar', 'last' => 'Parkinson', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Alex', 'last' => 'Butcher', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Zara', 'last' => 'Miller', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Rosie', 'last' => 'Smith', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Aaliyah', 'last' => 'Morrison', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Adam', 'last' => 'Fisher', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Louise', 'last' => 'Francis', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Riley', 'last' => 'James', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Gabriel', 'last' => 'Andrews', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Millie', 'last' => 'Fry', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Patrick', 'last' => 'Carr', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Sofia', 'last' => 'Gould', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Ethan', 'last' => 'Humphries', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Liam', 'last' => 'Douglas', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Taylor', 'last' => 'Brady', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Yasmin', 'last' => 'Hurst', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Rosie', 'last' => "O'Neill", 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Demi', 'last' => 'Pickering', 'tickets' => 1, 'source' => 'EventBrite'));
     Booking::create(array('first' => 'Shannon', 'last' => 'Shaw', 'tickets' => 1, 'source' => 'EventBrite'));
     // "On the day" registrations that couldn't be matched to bookings
     Registration::create(array('tickets' => 1, 'name' => 'Joseph Brown'));
     Registration::create(array('tickets' => 1, 'name' => 'Mark Black'));
 }
 /**
  * Display a listing of the resource.
  * GET /reservations
  *
  * @return Response
  */
 public function getIndex()
 {
     $execResult = ['updated' => 0, 'created' => 0, 'bookings' => 0, 'cancelled' => 0, 'not_mapped' => 0];
     $propertiesChannels = PropertiesChannel::where('property_id', Property::getLoggedId())->get();
     foreach ($propertiesChannels as $channelSettings) {
         Log::debug($channelSettings);
         $channel = ChannelFactory::create($channelSettings);
         $result = $channel->getReservations();
         Log::debug($result);
         if ($result['reservations']) {
             foreach ($result['reservations'] as $reservation) {
                 $reservation['channel_id'] = $channelSettings->channel_id;
                 $reservation['property_id'] = $channelSettings->property_id;
                 $resModel = Reservation::getByKeys($channelSettings->channel_id, $channelSettings->property_id)->where('res_id', $reservation['res_id'])->first();
                 if (isset($reservation['cc_details']) && !empty($reservation['cc_details'])) {
                     $reservation['cc_details'] = Crypt::encrypt($reservation['cc_details']);
                 }
                 switch ($reservation['status']) {
                     case 'cancelled':
                         if ($resModel) {
                             $resModel->status = 'cancelled';
                             if ($reservation['res_cancel_fee']) {
                                 $resModel->res_cancel_fee = $reservation['res_cancel_fee'];
                             }
                             $resModel->cancelled_at = $resModel->freshTimestamp();
                             $resModel->save();
                             $execResult['cancelled']++;
                             //TODO: send email about cancellation
                         }
                         break;
                     case 'booked':
                         $needAddRooms = true;
                         if ($resModel) {
                             if (isset($reservation['modified']) && $reservation['modified']) {
                                 $resModel->update($reservation);
                                 $execResult['updated']++;
                                 $resModel->bookings()->delete();
                                 //TODO: send email about modification
                             } else {
                                 $needAddRooms = false;
                             }
                         } else {
                             $resModel = Reservation::create($reservation);
                             $execResult['created']++;
                         }
                         if ($reservation['rooms'] && $needAddRooms) {
                             foreach ($reservation['rooms'] as $room) {
                                 $room['reservation_id'] = $resModel->id;
                                 $room['channel_id'] = $reservation['channel_id'];
                                 $room['property_id'] = $reservation['property_id'];
                                 $mapping = InventoryMap::getMappedRoom($channelSettings->channel_id, $channelSettings->property_id, $room['inventory'], isset($room['plan']) ? $room['plan'] : null)->first();
                                 if ($mapping) {
                                     $room['room_id'] = $mapping->room_id;
                                 } else {
                                     $execResult['not_mapped']++;
                                     //TODO: send email about NOT MAPPED ROOM
                                 }
                                 Booking::create($room);
                                 $execResult['bookings']++;
                             }
                         }
                         break;
                 }
                 if ($resModel && $resModel->id) {
                     $type = $resModel->status;
                     if ($type != 'cancelled' && $resModel->modified) {
                         $type = 'modify';
                     }
                     $channel->setReservationConfirmation($resModel->id, $resModel->res_id, $type);
                 }
             }
         }
     }
     return View::make('index', compact('execResult'));
 }
Exemplo n.º 6
0
 public function storeAllData()
 {
     $data = Session::pull('MyBookingData');
     if (Session::has('rate_box_details') || Session::has('transport_cart_box') || Session::has('predefined_transport') || Session::has('excursion_cart_details')) {
         if ($booking = Booking::create($data)) {
             $ehi_users = User::getEhiUsers();
             if (Auth::check()) {
                 //DB::table('booking_user')->insert(array('booking_id' => $booking->id, 'user_id' => $user->id));
                 if (Session::has('client-list')) {
                     $clients = Session::pull('client-list');
                     foreach ($clients as $client) {
                         $client['booking_id'] = $booking->id;
                         $client['gender'] === 'male' ? $client['gender'] = 1 : ($client['gender'] = 0);
                         Client::create($client);
                     }
                 }
                 $flight_data = [];
                 $flight_data['booking_id'] = $booking->id;
                 $flight_data['date'] = $data['date_arrival'];
                 $flight_data['time'] = $data['arrival_time'];
                 $flight_data['flight'] = $data['arrival_flight'];
                 $flight_data['flight_type'] = 1;
                 FlightDetail::create($flight_data);
                 //departure flight data
                 $flight_data['date'] = $data['date_departure'];
                 $flight_data['time'] = $data['departure_time'];
                 $flight_data['flight'] = $data['departure_flight'];
                 $flight_data['flight_type'] = 0;
                 FlightDetail::create($flight_data);
             }
             /**
              *  transport - custom trips
              */
             $a = 0;
             if (Session::has('transport_cart_box')) {
                 $custom_trips = Session::pull('transport_cart_box');
                 $a++;
                 $x = 1;
                 foreach ($custom_trips as $custom_trip) {
                     $custom_trip['from'] = date('Y-m-d H:i', strtotime($custom_trip['pick_up_date'] . ' ' . $custom_trip['pick_up_time_hour'] . ':' . $custom_trip['pick_up_time_minutes']));
                     $custom_trip['to'] = date('Y-m-d H:i', strtotime($custom_trip['drop_off_date'] . ' ' . $custom_trip['drop_off_time_hour'] . ':' . $custom_trip['drop_off_time_minutes']));
                     $custom_trip['reference_number'] = 'TR' . ($booking->reference_number * 1000 + $x++);
                     $custom_trip['booking_id'] = $booking->id;
                     $custom_trip['locations'] = $custom_trip['destination_1'] . ',' . $custom_trip['destination_2'] or '' . ',' . $custom_trip['destination_3'];
                     $custom_trip['amount'] = rand(100, 200);
                     CustomTrip::create($custom_trip);
                 }
             }
             /**
              *  predefined package bookings
              */
             if (Session::has('predefined_transport')) {
                 $a++;
                 $predefined_packages = Session::pull('predefined_transport');
                 foreach ($predefined_packages as $predefined_package) {
                     $package = [];
                     $package['transport_package_id'] = $predefined_package['predefine_id'];
                     $package['booking_id'] = $booking->id;
                     $package['pick_up_date_time'] = $predefined_package['check_in_date'];
                     $package['amount'] = TransportPackage::find($predefined_package['predefine_id'])->rate;
                     PredefinedTrip::create($package);
                 }
             }
             /**
              * Send Transportation Email to All EHI users
              */
             $pdf = PDF::loadView('emails/transport', array('booking' => $booking));
             $pdf->save('public/temp-files/transport' . $booking->id . '.pdf');
             //                if ($a > 0) {
             //                    Mail::send('emails/transport-mail', array(
             //                        'booking' => Booking::find($booking->id)
             //                    ), function ($message) use ($booking, $ehi_users) {
             //                        $message->attach('public/temp-files/transport.pdf')
             //                            ->subject('New Transfer : ' . $booking->reference_number)
             //                            ->from('*****@*****.**', 'SriLankaHotels.Travel')
             //                            ->bcc('*****@*****.**');
             //                        if (!empty($ehi_users))
             //                            foreach ($ehi_users as $ehi_user) {
             //                                $message->to($ehi_user->email, $ehi_user->first_name);
             //                            }
             //                    });
             //                }
             /**
              * Excursions
              */
             if (Session::has('excursion_cart_details')) {
                 $excursions = Session::pull('excursion_cart_details');
                 $x = 1;
                 foreach ($excursions as $excursion) {
                     $excursionBooking = ExcursionRate::with(array('city', 'excursion', 'excursionTransportType'))->where('city_id', $excursion['city_id'])->where('excursion_transport_type_id', $excursion['excursion_transport_type'])->where('excursion_id', $excursion['excursion'])->first();
                     $excursionBookingData = array('booking_id' => $booking->id, 'city_id' => $excursionBooking->city_id, 'excursion_transport_type_id' => $excursionBooking->excursion_transport_type_id, 'excursion_id' => $excursionBooking->excursion_id, 'unit_price' => $excursionBooking->rate, 'pax' => $excursion['excursion_pax'], 'date' => $excursion['excursion_date'], 'reference_number' => 'EX' . ($booking->reference_number * 1000 + $x++));
                     ExcursionBooking::create($excursionBookingData);
                 }
                 $pdf = PDF::loadView('emails/excursion', array('booking' => $booking));
                 $pdf->save('public/temp-files/excursions.pdf');
                 //                    Mail::send('emails/excursion-mail', array(
                 //                        'booking' => $booking
                 //                    ), function ($message) use ($booking, $ehi_users) {
                 //                        $message->attach('public/temp-files/excursions.pdf')
                 //                            ->subject('New Excursions : ' . $booking->reference_number)
                 //                            ->from('*****@*****.**', 'SriLankaHotels.Travel');
                 //
                 //                        $message->to('*****@*****.**', 'Excursions');
                 //                        $message->bcc('*****@*****.**', 'Admin');
                 //                        if (!empty($ehi_users))
                 //                            foreach ($ehi_users as $ehi_user) {
                 //                                $message->to($ehi_user->email, $ehi_user->first_name);
                 //                            }
                 //                    });
             }
             /**
              *  hotel bookings
              */
             if (Session::has('rate_box_details')) {
                 $bookings = Session::pull('rate_box_details');
                 $vouchers = Voucher::arrangeHotelBookingsVoucherwise($bookings, $booking->id);
                 foreach ($vouchers as $voucher) {
                     $created_voucher = Voucher::create($voucher);
                     for ($c = 0; $c < count($voucher) - 6; $c++) {
                         $voucher[$c]['voucher_id'] = $created_voucher->id;
                         $RoomBooking = RoomBooking::create($voucher[$c]);
                     }
                     // voucher
                     $pdf = PDF::loadView('emails/voucher', array('voucher' => $created_voucher));
                     $pdf->save('public/temp-files/voucher' . $created_voucher->id . '.pdf');
                     //                        $hotel_users = DB::table('users')->leftJoin('hotel_user', 'users.id', '=', 'hotel_user.user_id')
                     //                            ->where('hotel_user.hotel_id', $created_voucher->hotel_id)
                     //                            ->get();
                     //
                     //                        Mail::send('emails/voucher-mail', array(
                     //                            'voucher' => Voucher::find($created_voucher->id)
                     //                        ), function ($message) use ($booking, $hotel_users,$created_voucher) {
                     //                            $message->attach('public/temp-files/voucher'.$created_voucher->id.'.pdf')
                     //                                ->subject('Booking Voucher : ' . $booking->reference_number)
                     //                                ->from('*****@*****.**', 'SriLankaHotels.Travel')
                     //                                ->bcc('*****@*****.**', 'SriLankaHotels.Travel');
                     //                            if (!empty($hotel_users))
                     //                                foreach ($hotel_users as $hotel_user) {
                     //                                    $message->to($hotel_user->email, $hotel_user->first_name);
                     //                                }
                     //                        });
                 }
             }
             //Booking details
             //                $pdf = PDF::loadView('emails/booking', array('booking' => $booking));
             //                $pdf->save('public/temp-files/booking'.$booking->id.'.pdf');
             //
             $ehi_users = User::getEhiUsers();
             //
             $emails = array('*****@*****.**', '*****@*****.**', '*****@*****.**');
             //
             //                Mail::send('emails/booking-mail', array(
             //                    'booking' => Booking::getBookingData($booking->id)
             //                ), function ($message) use ($booking, $emails, $ehi_users) {
             //                    $message->attach('public/temp-files/booking'.$booking->id.'.pdf')
             //                        ->subject('New Booking: ' . $booking->reference_number)
             //                        ->from('*****@*****.**', 'SriLankaHotels.Travel')
             //                        ->bcc('*****@*****.**', 'Admin');
             //                    foreach ($emails as $emailaddress) {
             //                        $message->to($emailaddress, 'Admin');
             //                    }
             //
             //                    if (!empty($ehi_users)) {
             //                        foreach ($ehi_users as $ehi_user) {
             //                            $message->to($ehi_user->email, $ehi_user->first_name);
             //                        }
             //                    }
             //                });
             Invoice::create(array('booking_id' => $booking->id, 'amount' => Booking::getTotalBookingAmount($booking), 'count' => 1));
             //Invoice
             $pdf = PDF::loadView('emails/invoice', array('booking' => $booking));
             $pdf->save('public/temp-files/invoice' . $booking->id . '.pdf');
             $pdf = PDF::loadView('emails/service-voucher', array('booking' => $booking));
             $pdf->save('public/temp-files/service-voucher.pdf');
             //                if ($user = $booking->user) {
             //                    Mail::send('emails/invoice-mail', array(
             //                        'booking' => Booking::getBookingData($booking->id)
             //                    ), function ($message) use ($user, $booking, $emails) {
             //                        $message->subject('Booking Invoice : ' . $booking->reference_number)
             //                            ->attach('public/temp-files/invoice'.$booking->id.'.pdf');
             //                        $message->to($user->email, $user->first_name . ' ' . $user->last_name);
             //                        $message->to('*****@*****.**', 'Accounts');
             //                        if (!empty($ehi_users)) {
             //                            foreach ($ehi_users as $ehi_user) {
             //                                $message->to($ehi_user->email, $ehi_user->first_name);
             //                            }
             //                        }
             //
             //                    });
             //
             //                } else {
             //
             //                    Mail::send('emails/invoice-mail', array(
             //                        'booking' => Booking::getBookingData($booking->id)
             //                    ), function ($message) use ($booking, $emails) {
             //                        $message->to($booking->email, $booking->name)
             //                            ->subject('Booking Created : ' . $booking->reference_number)
             //                            ->attach('public/temp-files/invoice'.$booking->id.'.pdf');
             //                        $message->to('*****@*****.**', 'Accounts');
             //                        if (!empty($ehi_users)) {
             //                            foreach ($ehi_users as $ehi_user) {
             //                                $message->to($ehi_user->email, $ehi_user->first_name);
             //                            }
             //                        }
             //                    });
             //                }
             if (!Auth::check()) {
                 Session::flash('global', 'Emails have been sent to the Respective parties');
                 return View::make('pages.message');
             }
         }
         return $booking;
     } else {
         return Redirect::back();
     }
     return Redirect::route('bookings.index');
 }
Exemplo n.º 7
0
 /**
  * Store a newly created payment in storage.
  *
  * @return Response
  */
 public function store()
 {
     $data = Input::all();
     $user_id = Auth::id();
     $validator = Validator::make(Input::all(), array('amount' => 'required|numeric'));
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     /**
      * Payments are starting from "BK" numbers
      */
     if ($x = Payment::find(Payment::max('id'))) {
         $y = (int) substr($x->reference_number, 2);
         $data['reference_number'] = 'BK' . ++$y;
     } else {
         $data['reference_number'] = 'BK10000000';
     }
     $data['agent_id'] = User::getAgentOfUser(Auth::id());
     if (Entrust::hasRole('Agent')) {
         $agent_id = $data['agent_id']->user_id;
         $name = User::where('id', $user_id)->first()->first_name . ' ' . User::where('id', $user_id)->first()->last_name;
         $email = User::where('id', $user_id)->first()->email;
         $phone = Agent::where('user_id', $user_id)->first()->phone;
         $amount = Input::get('amount');
         $details = Input::get('details');
         $data = array('details' => $name, 'ip_address' => $_SERVER['REMOTE_ADDR'], 'amount' => $amount, 'payment_status' => 0, 'my_booking' => 2);
         $reserv_id = Payment::create($data);
         $data_tab_HSBC_payment = array('currency' => 'USD');
         $tab_HSBC_payment_id = HsbcPayment::create($data_tab_HSBC_payment);
         $stamp = strtotime("now");
         $payment_id = Payment::orderBy('created_at', 'desc')->first()->id;
         $orderid = "{$stamp}" . 'AP' . "{$payment_id}";
         $last_res_resid = str_replace(".", "", $orderid);
         $hsbc_id = HsbcPayment::orderBy('created_at', 'desc')->first()->id;
         $hsbc_payment_id_pre = "{$stamp}" . 'HSBC' . "{$hsbc_id}";
         $hsbc_payment_id = str_replace(".", "", $hsbc_payment_id_pre);
         if ($last_res_resid) {
             $payment = DB::table('payments')->where('id', $payment_id)->update(array('reference_number' => $last_res_resid, 'HSBC_payment_id' => $hsbc_payment_id));
             $data_tab_HSBC_payment = DB::table('hsbc_payments')->where('id', $hsbc_id)->update(array('HSBC_payment_id' => $hsbc_payment_id));
             $client = array('booking_name' => $name, 'email' => $email, 'phone' => $phone, 'remarks' => $details, 'val' => 0, 'payment_reference_number' => $last_res_resid);
             $client_payment_id = Booking::create($client);
         }
         $currency = 'USD';
         $x = $amount * 1.037;
         $total_price_all_hsbc = round($x, 2) * 100;
         //dd($hsbc_payment_id . '/' . $currency . '/' . $total_price_all_hsbc . '/' . $last_res_resid);
         HsbcPayment::goto_hsbc_gateway($hsbc_payment_id, $currency, $total_price_all_hsbc, $last_res_resid);
         //  return $this->storeAllDataAndSendEmails();
     }
     //Payment::create($data);
     return Redirect::route('accounts.payments.index');
 }