/** * This function check the hall availability according to the requested date. * This response to a ajax call from the view. * * @param Request $request * @return \Illuminate\Http\JsonResponse */ function checkHallAvailability(Request $request) { //delete the session if already a hall is added for a reservation if (Session::has('hall_selected')) { $request->session()->forget('hall_selected'); } $inputs = $request->all(); $event_date = $inputs['event_date']; $time_slot = $inputs['timeSlot']; $request->session()->put('event_date', $event_date); $request->session()->put('timeSlot', $time_slot); //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('reserve_date', '=', $event_date)->where('time_slot', '=', $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, 'hall_ids' => $halls, 'edate' => $event_date, 'timeSlot' => $time_slot, 'total_halls' => $total_halls]); }
/** * 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 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]); }