/** * This function provides the view of the halls page with hall details * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function hallsView() { $this->clearSession(); $halls = HALL::get(); $time_slot1_from = HotelInfo::value('hall_time_slot_1_from'); $time_slot1_to = HotelInfo::value('hall_time_slot_1_to'); $time_slot1 = "" . $time_slot1_from . " - " . $time_slot1_to; $time_slot2_from = HotelInfo::value('hall_time_slot_2_from'); $time_slot2_to = HotelInfo::value('hall_time_slot_2_to'); $time_slot2 = "" . $time_slot2_from . " - " . $time_slot2_to; return view('Website.Halls', ["halls" => $halls, "time_slot1" => $time_slot1, "time_slot2" => $time_slot2]); }
/** * This function add the user selected halls to reserve. * Also this function response with the details of the selected hall. * * @param Request $request * @return \Illuminate\Http\JsonResponse */ function addHallsToReserve(Request $request) { //this is used as a indicator to access the payment page $request->session()->put('CanPay', 'Can'); $inputs = $request->all(); $hall_id = $inputs['hall_id']; $request->session()->put('hall_selected', $hall_id); //retrieve the hall details from the table $hall_detail = HALL::join('HALL_RATES', 'HALL_RATES.hall_id', '=', 'HALLS.hall_id')->where('HALLS.hall_id', '=', $hall_id)->select('HALLS.hall_id', 'HALLS.title', 'HALL_RATES.advance_payment', 'HALL_RATES.refundable_amount')->get(); //retrieve the advance payment of the halls in order to add to the session $advance = DB::table('HALL_RATES')->where('hall_id', '=', $hall_id)->value('advance_payment'); $request->session()->put('total_payable', $advance); return response()->json(['hall_detail' => $hall_detail]); }
/** * This function is to store the reservation details to db. * After storing the details this function redirects to the My Reservation view. * * @return \Illuminate\Http\RedirectResponse */ public function hallReservation() { try { //set the timezone date_default_timezone_set("Asia/Colombo"); $customer_email = Auth::user()->email; $customer_id = Customer::where('email', $customer_email)->value('cus_id'); $customer_name = Customer::where('email', $customer_email)->value('name'); $hall_name = HALL::where('hall_id', session('hall_selected'))->value('title'); $event_date = session('event_date'); //create instance of the HALL_RESERVATION model $hall_reservation = new HALL_RESERVATION(); $hall_reservation->reserve_date = session('event_date'); $hall_reservation->time_slot = session('timeSlot'); $hall_reservation->total_amount = session('total_payable'); $hall_reservation->cus_id = $customer_id; $hall_reservation->hall_id = session('hall_selected'); $hall_reservation->status = 'PENDING'; $hall_reservation->save(); //retrieve the reservation id of the last saved reservation $res_id = $hall_reservation->hall_reservation_id; //delete the reservation details since already stored in the db Session::forget(['event_date', 'total_payable', 'hall_selected', 'CanPay']); //create an array in order to send the mail view with reservation details $data = array('res_id' => $res_id, 'hall_name' => $hall_name, 'event_date' => $event_date, 'name' => $customer_name); $job = new SendEmail($data, $customer_email, "initial_reservation_mail"); $this->dispatch($job); //send a initial mail /* Mail::send('emails.InitialRoomReservationMail', $data, function ($message)use($customer_email) { $message->from(env('MAIL_FROM'), env('MAIL_NAME')); $message->to($customer_email)->subject('Welcome to Amalya Reach!'); });*/ //pusher $newNotification = new Notifications(); $newNotification->notification = "New Reservation"; $newNotification->body = "Room Reservation has been made"; $newNotification->readStatus = '0'; $newNotification->save(); Pusher::trigger('notifications', 'Reservation', ['message' => 'New Hall Reservation has been made']); return redirect('myreserv')->with(['hreserv_status' => 'Reservation has been successfully made']); } catch (\Exception $e) { abort(500, $e->getMessage()); } }
/** * Hall logs page * @param Request $request * @return mixed */ public function admin_hall_logs(Request $request) { $halls = HALL::all(); return view('nilesh.hallLogs')->with('halls', $halls); }
/** * This function checks the hall availability for the admin part. * * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function checkHallAvailability(Request $request) { $inputs = $request->all(); $hall_reservation_id = $inputs['hall_reservation_id']; $hall_reservation_details = HALL_RESERVATION::where('hall_reservation_id', '=', $hall_reservation_id)->first(); //define an array to store the availability of the halls $hall_status = array(); $halls = HALL::get(); $total_halls = 0; //for each halls check whether they are already reserved in a reservation foreach ($halls as $hall) { $row_count = HALL_RESERVATION::where('hall_id', '=', $hall->hall_id)->where('hall_reservation_id', '!=', $hall_reservation_id)->where('reserve_date', '=', $hall_reservation_details->reserve_date)->where('time_slot', '=', $hall_reservation_details->time_slot)->count(); //if the row count is zero means that is not reserved if ($row_count == 0) { $total_halls += 1; $hall_status[$hall->hall_id] = "Available"; } else { $hall_status[$hall->hall_id] = "Not Available"; } } return response()->json(['hall_status' => $hall_status, 'halls' => $halls]); }