/**
  * Email Booking Confirmation
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function booking_confirmation(Request $request)
 {
     $booking_data = session('booking_data');
     $data = $this->prepare_email_data($booking_data);
     $emails = $data['emails'];
     Mail::send('emails.confirmation', ['data' => $data], function ($message) use($emails) {
         $message->to($emails)->subject('Test - Booking Confirmed');
     });
     session()->flash('flash_message', 'Your booking was successful');
     session()->flash('flash_time', Booking::find($booking_data->id)->created_at);
     return redirect('bookings/my-bookings');
 }
 /**
  * Check that losers score is not higher than the winners score.
  */
 public function moreValidation($validator)
 {
     $match = Result::where('match_id', '=', $this->input('match_id'))->first();
     $booking = Booking::find($this->input('match_id'));
     $validator->after(function ($validator) use($match, $booking) {
         if ($this->input('win')) {
             if ($this->input('user_score') < $this->input('opponent_score')) {
                 $validator->errors()->add('user_score', ' Your score must be higher than your opponent');
             }
         } elseif (!$this->input('result_by_default')) {
             if ($this->input('user_score') > $this->input('opponent_score')) {
                 $validator->errors()->add('user_score', ' Your score must be lower than your opponent');
             }
         }
         if ($match->created_at != $match->created_at) {
             $validator->errors()->add('match_id', 'Match score already entered by opponent');
         }
         if ($booking->booking_date > date('Y-m-d')) {
             $validator->errors()->add('match_id', 'Match has not been played yet');
         }
     });
 }
 /**
  * Get a list of no results from the results table and get the related match information (name of opponent, date, court etc) from the booking and users table.
  * @param  array $array An array of no results from the Results Table
  * @return array        An array of results, including the related booking information.
  */
 private function get_no_results($array)
 {
     foreach ($array as $match) {
         $booking = Booking::find($match->match_id);
         $opponent = $booking->player2_id;
         $user = \Auth::user()->id;
         $opponent = $opponent == $user ? User::find($booking->player1_id) : User::find($booking->player2_id);
         $match['opponent'] = $opponent->first_name;
     }
     return $array;
 }
 /**
  * @param Request $request
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function put_booking_in_trash(Request $request)
 {
     if ($request->has('booking_id')) {
         $booking = Booking::find($request->booking_id);
         $booking->delete();
         return redirect()->route('customer_booking_history');
     } else {
         return redirect()->route('customer_booking_history');
     }
 }
Exemple #5
0
     $comment->user_id = $user_id;
     $comment->property_id = $data['property_id'];
     $comment->written_at = date('Y-m-d H:i:s');
     $comment->rating = $data['stars'];
     $comment->comment_text = $data['review'];
     $comment->booking_id = $data['booking_id'];
     $comment->save();
     return redirect(url('/property/' . $data['property_id']));
 }));
 Route::post('bookings/cancel', function (Request $request) {
     $data = $request->all();
     $validator = Validator::make($request->all(), ['booking_id' => 'required|numeric|min:1|integer']);
     if ($validator->fails()) {
         return redirect(url('/property/bookings'))->withInput()->withErrors($validator);
     }
     $booking = \App\Booking::find($data['booking_id']);
     $booking->delete();
     return redirect(url('/bookings'));
 });
 Route::get('/property/add', function () {
     $cities = City::orderBy('name', 'asc')->get();
     return view('addproperty', ['cities' => $cities]);
 });
 Route::get('/bookings', array('middleware' => 'auth', function () {
     $properties = Property::where('owner_id', '<>', Auth::id())->get();
     foreach ($properties as $property) {
         $property->requested_bookings = Booking::where('customer_id', Auth::id())->where('property_id', $property->id)->where('status', 'requested')->get();
         $property->confirmed_bookings = Booking::where('customer_id', Auth::id())->where('property_id', $property->id)->where('status', 'confirmed')->get();
         foreach ($property->confirmed_bookings as $booking) {
             $comment = Comment::where('booking_id', $booking->id)->get();
             if (count($comment) > 0) {
Exemple #6
0
 /**
  * Responds to requests to POST /bookings/edit
  */
 public function postEdit($booking_id, Request $request)
 {
     // get the booking
     $booking = \App\Booking::find($booking_id);
     // check if booking exists
     if (is_null($booking)) {
         \Session::flash('flash_message', 'Booking not found.');
         return redirect('/bookings');
     }
     // check if the hall is booked for the given time
     $startTime = $request->date . 'T08:00:00.000';
     $endTime = $request->date . 'T19:00:00.000';
     $bookings = \App\Booking::where('booking_status_id', '=', '3')->where('id', '!=', $booking->id)->where('booking_time', '>=', $startTime)->where('booking_time', '<=', $endTime)->where('sport_hall_id', '=', $request->hall)->get();
     // selected time for booking
     $currentBookingTime = Carbon::createFromFormat('Y-m-d H:00', $request->date . ' ' . $request->time);
     // hall should be booked atleast 5 hours in advance
     if (Carbon::now()->diffInHours($currentBookingTime, false) <= 5) {
         \Session::flash('flash_message', 'Booking not updated. You have to book a hall atleast 5 hours in advance. Please select an other time slot.');
         return redirect('/bookings');
     }
     // loop through all the booking on this date and check if the hall is reserved
     foreach ($bookings as $bookingInRange) {
         $startTime = Carbon::createFromFormat('Y-m-d H:00:00', $bookingInRange->booking_time);
         $endTime = $startTime->copy();
         $endTime->addHours($bookingInRange->hours);
         if ($currentBookingTime->between($startTime, $endTime) && !($endTime->diffInHours($currentBookingTime) == 0)) {
             \Session::flash('flash_message', 'Booking not updated. Sorry the hall is already reserved for this time slot!');
             return redirect('/bookings');
         }
     }
     // edit the booking
     $booking->sport_hall_id = $request->hall;
     $booking->booking_time = Carbon::createFromFormat('Y-m-d H:00', $request->date . ' ' . $request->time)->toDateTimeString();
     $bookingStatusId = \App\BookingStatus::where('status', '=', 'Reserved')->pluck('id');
     $booking->booking_status_id = $bookingStatusId;
     $booking->hours = $request->hours;
     $booking->save();
     // Done
     \Session::flash('flash_message', 'Your booking was modified!');
     return redirect('/bookings');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Booking::find($id)->delete();
     return redirect('/admin/booking');
 }
 /**
  * Delete block booking
  * @param  Request $request booking id
  */
 public function destroy_block_booking(Request $request)
 {
     $the_booking = Booking::find($request->input('booking_id'));
     $get_booking = Booking::where('created_at', '=', $the_booking->created_at)->groupBy('created_at');
     $get_booking->delete();
     session()->flash('flash_message', 'Your booking has been deleted');
     return redirect('administrator/block-bookings');
 }
 public function update($id, BookingUpdateRequest $request)
 {
     Booking::find($id)->update($request->all());
 }
 function getbooking($id)
 {
     $booking = Booking::find($id);
     return $booking;
 }
 /**
  * Delete a booking form the bookings table.
  * @param  Request $request Input - booking id
  * @return Redirect           Redirect to my-bookings page
  */
 public function destroy_booking(Request $request)
 {
     $booking_id = $request->input('booking_id');
     $booking_info = Booking::find($booking_id);
     Booking::destroy($booking_id);
     session()->flash('booking_data', $booking_info);
     return redirect('email/booking-cancellation');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $booking = Booking::find($id);
     if (!$booking) {
         return "Not Found";
     } else {
         $booking->delete();
         return 1;
     }
 }