public function saveReservation(Request $request)
 {
     $reservation = new Reservation();
     if (!$request->input('locator_id') || !Locator::find($request->input('locator_id'))) {
         return response('Lokator nie został sprecyzowany', 500)->header('Content-Type', 'text/html; charset=utf-8');
     }
     if (!$request->input('rooms')) {
         return response('Pokoje nie zostały sprecyzowane', 500)->header('Content-Type', 'text/html; charset=utf-8');
     }
     foreach ($request->input('rooms') as $room) {
         if (!Room::find($room)) {
             return response('Pokój o numerze ' . $room . ' nie jest zdefiniowany w bazie danych.', 500)->header('Content-Type', 'text/html; charset=utf-8');
         }
     }
     $reservation->locator_id = $request->input('locator_id');
     $reservation->reservation_time = date('Y-m-d H:i:sZ', time());
     $reservation->since = $request->input('since');
     $reservation->till = $request->input('till');
     $reservation->is_paid = $request->input('is_paid');
     $reservation->dinners_count = $request->input('dinners_count');
     $reservation->people_count = $request->input('people_count');
     $reservation->save();
     $reservation->rooms()->sync($request->input('rooms'));
     $reservation->save();
     return response()->json($reservation);
 }
 /**
  * Store and check a newly created reservations in storage,
  * and send an email to administrators for information.
  *
  * @param ReservationRequest|Request $request
  * @return array
  */
 public function store(ReservationRequest $request)
 {
     $reservation = new Reservation($request->all());
     $reservation->is_valid = false;
     $reservation->save();
     $dest = explode(',', env('MAIL_ADMIN'));
     $this->sendMail('emails.new', $reservation->toArray(), $dest);
     return compact('reservation');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(UCreateReservationRequest $request)
 {
     $user = Auth::user();
     $reservation = new Reservation();
     $reservation->fill(['forwho' => $user->full_name, 'whoid' => $user->id, 'status' => 'created']);
     $reservation->fill($request->all());
     $reservation->save();
     return redirect()->route('user.reservations.index');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     $guests = Guest::All();
     for ($i = 1; $i <= 20; $i++) {
         $guest = $guests->random();
         $startDate = $faker->dateTimeBetween("now", "+12 days");
         $endDate = $faker->dateTimeBetween($startDate, "+ 1 month");
         $reservation = new Reservation();
         $reservation->date_in = $startDate;
         $reservation->date_out = $endDate;
         $reservation->made_by = "Faker";
         $reservation->guest_id = $guest->id;
         $reservation->save();
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $nbRes = Reservation::where('user_id', '=', Auth::user()->id)->where('valide', '<=', 1)->count();
     if ($nbRes < 3) {
         $velo = Velo::findOrFail($request->input('idVelo'));
         // Création d'une nouvelle reservation
         $reservation = new Reservation(['valide' => 0]);
         $reservation->user()->associate(Auth::user());
         $reservation->velo()->associate($velo);
         $reservation->save();
         // Création des demi journéées choisies
         $values = $request->all();
         $keys = array_keys($values);
         $newDJ = array();
         unset($keys[0]);
         //on retire le token
         for ($i = 1; $i < sizeof($values) - 2; $i += 2) {
             // -2 pour retirer le veloId
             //control des champs
             $regles = array($keys[$i] => 'required', $keys[$i + 1] => 'required');
             $validation = Validator::make($values, $regles);
             if ($validation->fails()) {
                 Session::flash('info', 'Le formulaire envoyé comportait des champs vides !');
                 $reservation->delete();
                 foreach ($newDJ as $dj) {
                     $dj->delete();
                 }
                 return redirect()->back();
             } else {
                 //formattage de la date
                 $date = explode('-', $values[$keys[$i]]);
                 $date = $date[2] . '-' . $date[1] . '-' . $date[0];
                 $demijournee = new Demijournee(['date' => $date, 'periode' => $values[$keys[$i + 1]]]);
                 $demijournee->reservation()->associate($reservation);
                 $demijournee->save();
                 $newDJ[] = $demijournee;
             }
         }
         return redirect()->route('location.show', ['location' => $reservation->id]);
     } else {
         Session::flash('info', 'Vous ne pouvez pas avoir plus de trois réservations en attente ! Merci de votre compréhension.');
         return redirect()->back();
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $allReservations = DB::table('reservations')->where('artwork_id', '=', Input::get('artwork-id'))->get();
     $reservation = new Reservation();
     $reservation->user_id = Auth::user()->id;
     $reservation->artwork_id = Input::get('artwork-id');
     $reservation->from_date = Input::get('from-date');
     $reservation->to_date = Input::get('to-date');
     $reservation->delivery_adress = Input::get('delivery_adress');
     $artwork = Artwork::findOrFail(Input::get('artwork-id'));
     $overlap = false;
     foreach ($allReservations as $key) {
         if (Input::get('from-date') < $key->to_date && Input::get('from-date') > $key->from_date) {
             $overlap = true;
         } elseif (Input::get('to-date') > $key->from_date && Input::get('to-date') < $key->to_date) {
             $overlap = true;
         } elseif (Input::get('from-date') == $key->from_date) {
             $overlap = true;
         }
     }
     if (!$overlap) {
         $artwork->reserved += 1;
         $reservation->save();
         $artwork->update(['reserved' => $artwork->reserved]);
         return Response::json([0 => 'Reservering geslaagd. Klik <a href="/gallery">hier</a> om terug te gaan'], HttpCode::Ok);
     } else {
         $latest = "";
         foreach ($allReservations as $key) {
             if (is_null($latest)) {
                 $latest = $key->to_date;
             } elseif ($key->to_date > $latest) {
                 $latest = $key->to_date;
             }
         }
         return Response::json([0 => 'Het kunstwerk is al gereserveerd op deze datum.'], HttpCode::Conflict);
     }
 }
 public function success(Request $request, Reservation $reservation)
 {
     //change reservation status to complete
     $payment_id = Session::get('paypal_payment_id');
     $reservation->status = 1;
     $reservation->payment_id = $payment_id;
     $cruise = Cruise::find($reservation->cruise_id);
     $cabin = Cabin::find($reservation->cabin_id);
     //deduct cabin number in the cruise
     DB::table('cruises_cabins')->where('cruise_id', $reservation->cruise_id)->where('cabin_id', $reservation->cabin_id)->increment('cabin_booked');
     $reservation->save();
     Session::forget('paypal_payment_id');
     $full = 0;
     foreach ($cruise->cabins as $cabin) {
         if ($cabin->pivot->cabin_number == $cabin->pivot->cabin_booked) {
             $full++;
         }
     }
     if ($full == Cabin::all()->count()) {
         $cruise->status = 1;
         $cruise->save();
     }
     return view('user.reservation', ['cruise' => $cruise, 'cabin' => $cabin, 'amenities' => $reservation->amenities()->get(), 'reservation' => $reservation])->with('status', 'Payment succcess!');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $input = $request->only(['reservationDate', 'patient_id', 'medic_id', 'atention_id', 'comment']);
     $data = $request->only(['reservationDate', 'room', 'patient_id', 'medic_id', 'atention_id', 'block_id']);
     $atention = Atention::find($input['atention_id']);
     $rules = ['reservationDate' => 'required', 'patient_id' => 'required', 'medic_id' => 'required', 'atention_id' => 'required'];
     $validation = \Validator::make($input, $rules);
     if ($validation->passes()) {
         $reservation = new Reservation($input);
         $reservation->save();
         $id_reservation = $reservation->id;
         $numberOfBlocks = $atention->block_numbers;
         for ($i = 0; $i < $numberOfBlocks; $i++) {
             $nextBlock = $data['block_id'] + $i;
             $insertData = ['reservationDate' => $data['reservationDate'], 'room' => $data['room'], 'block_id' => $nextBlock, 'reservation_id' => $id_reservation];
             $info = new ReservationInfo($insertData);
             $info->save();
         }
         return response()->json(["respuesta" => "Guardado"]);
     }
     $messages = $validation->errors();
     return response()->json($messages);
     //return $input;
 }
 public function createReservations()
 {
     if (Auth::admin()->check()) {
         $reservation_roomno = Request::get('reservationRegisterroomno');
         $reservation_guestno = Request::get('reservationRegisterguestno');
         $reservation_checkin = Request::get('reservationRegistercheckin');
         $reservation_checkout = Request::get('reservationRegistercheckout');
         $reservation_nochildguest = Request::get('reservationRegisternochildguest');
         $reservation_nooldguest = Request::get('reservationRegisternooldguest');
         $reservation_norooms = Request::get('reservationRegisternorooms');
         $reservation_status = Request::get('reservationRegisterstatus');
         $reservation = new Reservation();
         $reservation->Room_No = $reservation_roomno;
         $reservation->Guest_No = $reservation_guestno;
         $reservation->checkin = $reservation_checkin;
         $reservation->checkout = $reservation_checkout;
         $reservation->No_ChildGuest = $reservation_nochildguest;
         $reservation->No_OldGuest = $reservation_nooldguest;
         $reservation->No_Rooms = $reservation_norooms;
         $reservation->status = $reservation_status;
         $reservation->save();
         Session::flash('flash_message', 'Reservation successfully added!');
         return redirect('/auth/databasereservation');
     } else {
         return redirect()->back();
     }
 }
 public function confirmReservation()
 {
     $checkin = Request::get('temporaryCheckIn');
     $checkout = Request::get('temporaryCheckOut');
     $adults = Request::get('temporaryAdults');
     $children = Request::get('temporaryChildren');
     $roomtype = Request::get('temporaryRoomType');
     $roomcapacity = Request::get('temporaryRoomCapacity');
     $roomrate = Request::get('temporaryRoomRate');
     $roomname = Request::get('temporaryRoomName');
     $roomno = Request::get('temporaryRoomNo');
     $guestFirstName = Request::get('temporaryguestFirstName');
     $guestLastName = Request::get('temporaryguestLastName');
     $email = Request::get('temporaryguestEmail');
     $contact = Request::get('temporaryguestContact');
     if (Auth::user()->guest()) {
         $guest = new guest();
         $guest->username = rand(0, 9999);
         $guest->password = rand(0, 9999);
         $guest->first_name = $guestFirstName;
         $guest->last_name = $guestLastName;
         $guest->email = $email;
         $guest->contactNo = $contact;
         $guest->guestRegistration = 'Unregistered';
         $guest->save();
         $reservation = new Reservation();
         $reservation->Room_No = $roomno;
         $reservation->Guest_No = $guest->guest_No;
         $reservation->checkin = date_create($checkin);
         $reservation->checkout = date_create($checkout);
         $reservation->No_ChildGuest = $children;
         $reservation->No_OldGuest = $adults;
         $reservation->status = 'Reserved';
         $reservation->save();
     } else {
     }
     return view('pages.reservation.message');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $input = \Request::all();
     $passenger = new Passenger();
     $passenger->title = $input['passenger_title'];
     $passenger->name = $input['passenger_name'];
     $passenger->sex = $input['passenger_sex'];
     $passenger->age = $input['passenger_age'];
     $passenger->address_line_1 = $input['passenger_address1'];
     $passenger->address_line_2 = $input['passenger_address2'];
     $passenger->address_line_3 = $input['passenger_address3'];
     $passenger->state = $input['passenger_state'];
     $passenger->country = $input['passenger_country'];
     $passenger->occupation = $input['passenger_occupation'];
     $passenger->cabin_id = $input['cabin_form'];
     $passenger->save();
     $reservation = new Reservation();
     $reservation->cruise_id = $input['cruise_form'];
     $reservation->cabin_id = $input['cabin_form'];
     $reservation->customer_id = \Auth::User()->id;
     $reservation->save();
     $cabin = Cabin::where('id', $input['cabin_form'])->first();
     $cabin->occupied = false;
     $cabin->save();
     return view('pages.index')->with('title', 'Welcome');
 }
 /**
  * @param Request $request
  * @param int $id
  * @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\JsonResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function storeReservations(Request $request, $id)
 {
     $hours = $request->json()->all();
     try {
         foreach ($hours as $hour) {
             $reservation = new Reservation();
             $reservation->starts_at = new \DateTime($hour . ":00");
             $reservation->field_id = $id;
             $reservation->save();
         }
     } catch (\Exception $e) {
         return response($e->getMessage(), 501);
     }
     return response()->json("success");
 }
Exemple #13
0
 public static function saveCustomerReservationDetails($data)
 {
     //dd($data->all());
     $getReferenceNumber = new Reservation();
     $rooms = explode(',', $data->get('rooms'));
     $customer = Customer::whereEmail($data->get('email'))->first();
     $total_capacity = 0;
     $total_person = $data->get('no_of_adult') + $data->get('no_of_child');
     foreach ((array) $rooms as $rm) {
         $rms = Room::find($rm);
         $categories = Category::find($rms->category_id);
         if (count($categories) > 0) {
             $total_capacity += $categories->max_capacity;
         }
     }
     if ($total_capacity < $total_person) {
         return redirect()->back()->with('message', 'You exceeded the max capacity of the rooms');
     } else {
         if (count($customer) == 0) {
             $customer = new Customer();
             $customer->name = ucfirst(strtolower($data->get('first_name'))) . ' ' . ucfirst(strtolower($data->get('last_name')));
             $customer->address = $data->get('address');
             $customer->email = $data->get('email');
             $customer->contact_number = $data->get('contact');
             if ($customer->save()) {
                 $reservation = new Reservation();
                 $reservation->customer_id = $customer->id;
                 $reservation->reference_number = $getReferenceNumber->getReservationId();
                 $reservation->no_of_child = $data->get('no_of_child');
                 $reservation->no_of_adult = $data->get('no_of_adult');
                 $reservation->period = $data->get('period');
                 $reservation->status = 'RESERVED';
                 if ($reservation->save()) {
                     foreach ((array) $rooms as $room) {
                         $start_date = $data->get('start_date');
                         $end_date = $data->get('end_date');
                         # ROOM VISITOR
                         $start_date = date("Y-m-d", strtotime($start_date));
                         while (strtotime($start_date) < strtotime($end_date)) {
                             $reservation_room = new ReservationRoom();
                             $reservation_room->reservation_id = $reservation->id;
                             $reservation_room->room_id = $room;
                             $reservation_room->date_reserved = $start_date;
                             $reservation_room->save();
                             $start_date = date("Y-m-d", strtotime("+1 day", strtotime($start_date)));
                         }
                     }
                 }
             }
             Mail::send('emails.reservation_reference', ['customer' => $customer, 'reservation' => $reservation], function ($m) use($customer) {
                 $m->from('*****@*****.**', 'Overlook Resort (noreply)');
                 $m->to($customer->email, $customer->full_name())->subject('Here\'s your RESERVATION ID');
             });
             return redirect()->back()->with('message', 'Reservation was successful. We sent your reservation reference in your e-mail');
         }
         $reservation = new Reservation();
         $reservation->customer_id = $customer->id;
         $reservation->reference_number = $reservation->getReservationId();
         $reservation->no_of_child = $data->get('no_of_child');
         $reservation->no_of_adult = $data->get('no_of_adult');
         $reservation->period = $data->get('period');
         $reservation->status = 'Not Paid';
         if ($reservation->save()) {
             foreach ((array) $rooms as $room) {
                 $start_date = $data->get('start_date');
                 $end_date = $data->get('end_date');
                 # ROOM VISITOR
                 $start_date = date("Y-m-d", strtotime($start_date));
                 while (strtotime($start_date) < strtotime($end_date)) {
                     $reservation_room = new ReservationRoom();
                     $reservation_room->reservation_id = $reservation->id;
                     $reservation_room->room_id = $room;
                     $reservation_room->date_reserved = $start_date;
                     $reservation_room->save();
                     $start_date = date("Y-m-d", strtotime("+1 day", strtotime($start_date)));
                 }
             }
         }
         Mail::send('emails.reservation_reference', ['customer' => $customer, 'reservation' => $reservation], function ($m) use($customer) {
             $m->from('*****@*****.**', 'Overlook Resort (noreply)');
             $m->to($customer->email, $customer->full_name())->subject('Here\'s your RESERVATION ID');
         });
         return redirect()->back()->with('message', 'Reservation was successful. We sent your reservation reference in your e-mail');
     }
 }
 public function check_out(Reservation $reservation)
 {
     foreach ($reservation->rooms as $room) {
         $room->status = 0;
         $room->save();
     }
     $reservation->status = 2;
     $reservation->save();
     return redirect('/reservation');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $input = $request->all();
     $currentOccupants = [];
     $rooms = Room::all();
     $reservations_count = Reservation::where('room_id', $input['room_id'])->where('status', 'accepted')->where('start_date', '<=', [$input['start_date']])->where('end_date', '>=', [$input['end_date']])->count();
     $room = Room::find($input['room_id']);
     foreach ($rooms as $index => $roomz) {
         $currentOccupants[$index] = Reservation::where('room_id', $roomz->id)->where('status', 'accepted')->where('start_date', '<=', [$input['start_date']])->where('end_date', '>=', [$input['end_date']])->count();
     }
     $all_table = Room::where('availability', 'vacant')->get();
     if ($reservations_count == $room->pax) {
         return view('reservations.error')->with(compact('input', 'all_table', 'currentOccupants'));
     }
     $person = new Person();
     $person->unique_id = $this->quickRandom();
     $person->first_name = $request->input('first_name');
     $person->last_name = $request->input('last_name');
     $person->address = $request->input('address');
     $person->email = $request->input('email');
     $person->phone = $request->input('phone');
     if ($person->save()) {
         $reservation = new Reservation();
         $reservation->person_id = $person->id;
         $reservation->status = Reservation::STATUS_PENDING;
         $reservation->price = Room::find((int) $request->input('room_id'))->price;
         $reservation->notes = $request->input('notes');
         $reservation->start_date = $request->input('start_date');
         $reservation->end_date = $request->input('end_date');
         $reservation->room_id = (int) $request->input('room_id');
         if ($reservation->save()) {
             return view('reservations.confirmation');
             //TODO redirect to a page with success message
         } else {
             return 'Fail reservation';
             //TODO redirect to a page with error message
         }
     } else {
         return 'Fail Person';
         //TODO redirect to a page with error message
     }
 }
 public function storeSessionConfirm(Request $request)
 {
     $request->session()->put('message', $request['f-user_message']);
     $request->session()->put('newsletter', $request['f-newsletter']);
     $request->session()->put('agb', $request['f-agb']);
     $data = $request->session()->all();
     $reservation = new Reservation();
     $reservation->remember_token = $data['_token'];
     $reservation->date = $data['date'];
     $reservation->time = $data['time'];
     $reservation->pax = $data['pax'];
     $reservation->name = $data['name'];
     $reservation->email = $data['email'];
     $reservation->table = $data['table'];
     $reservation->message = $data['message'];
     $reservation->newsletter = $data['newsletter'];
     $reservation->agb = $data['agb'];
     $reservation->save();
 }