public function changeRoom(Request $request, $slotId)
 {
     if ($request->session()->has('currentBookingId')) {
         $bookingId = $request->session()->get('currentBookingId');
         //Found Booking ID and Slot Id Both
         //Now Change the booking
         //Get the old slot Id - Update its status to AV
         //Make the status of new slot id as NA
         //Change the slot in the original booking object
         $booking = Booking::where('id', $bookingId)->first();
         $venueRoomSlot = VenueRoomSlot::where('id', $slotId)->first();
         if ($venueRoomSlot->status == "AV") {
             //Change the booking
             $venueRoomSlot->status = "NA";
             $venueRoomSlot->save();
             //Get the old venue slot id and change its status to av
             $oldVenueRoomSlotId = $booking->venue_room_slot_id;
             $oldVenueRoomSlot = VenueRoomSlot::where('id', $oldVenueRoomSlotId)->first();
             if ($oldVenueRoomSlot->status == "NA") {
                 $oldVenueRoomSlot->status = "AV";
                 $oldVenueRoomSlot->save();
                 $booking->venue_room_slot_id = $slotId;
                 $booking->save();
                 return redirect('securitynewbookings');
             }
         }
         dd("NHP");
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //         \DB::table('venue_room_slots')->delete();
     //Things to do here -
     // 1. Seperate the logic of AB5 and NLH
     // 2.
     //Date Format YYYY-MM-DD
     //Add slot start today date here
     $startDate = Carbon::createFromDate(2016, 01, 31, 'Asia/Kolkata');
     //Add slot end date here
     $endDate = Carbon::createFromDate(2016, 03, 01, 'Asia/Kolkata');
     //Fill the slots for NLH first
     $venueRooms = VenueRoom::whereIn('venue_id', [1, 2])->get();
     //        dd($venueRooms->toArray());
     //This should be in minutes
     //5:30 PM in minutes = 1050
     //7:00 PM in minutes = 1140
     $slot_time = [1050];
     //I know logic is not very efficient
     //But running short on time
     while (!$startDate->eq($endDate)) {
         echo "Start Date : " . $startDate . " End Date: " . $endDate;
         foreach ($venueRooms as $venueRoom) {
             foreach ($slot_time as $eachSlotTime) {
                 $slot = new App\VenueRoomSlot();
                 $slot->venue_room_id = $venueRoom->id;
                 $slot->date = $startDate->toDateString();
                 $slot->start_time = $eachSlotTime;
                 $slot->status = 'AV';
                 $slot->save();
             }
         }
         //Till Start Date is not equal to the end date
         $startDate->addDay();
     }
 }
 public function cancelSlot($slot_id)
 {
     if ($slot_id != null) {
         //1. Get user id
         //2. Get venue_slot_id
         //3. Dump all the details as JSON
         //4. Update the details for the particaular slot
         //Update the particular slot status to NA
         $booking = Booking::where('venue_room_slot_id', $slot_id)->first();
         if ($booking->approved_by_fa == 1 && $booking->approved_by_swf == 1 && $booking->approved_by_security == 1) {
             //Can't Cancel Online
             //Go and do it manually
             $msg = 'This is booking can not cancelled online. You will have to do it manually.';
         } else {
             $slot = VenueRoomSlot::find($slot_id);
             if ($slot->status == 'NA') {
                 $slot->status = 'AV';
                 $slot->save();
                 $booking->disapproved_by = 'club';
                 $booking->save();
                 $msg = 'Booking Cancelled Succesfully';
             } else {
                 $msg = 'Error Processing your Request';
                 Redirect::to('clubbookings');
             }
         }
         return view('pages.clubcancelresponse')->with('message', $msg);
     }
 }