/**
  * @param Request $request
  * @return mixed
  * @return Response
  */
 public function setPriceInRangeForRoomType(Request $request)
 {
     $room_type = $request['room_type'];
     $price = $request['price'];
     $start_dt = $request['start_dt'];
     $end_dt = $request['end_dt'];
     $date = date("Y-m-d", strtotime($start_dt));
     $base_room = RoomType::find($room_type);
     $i = 0;
     while (strtotime($date) <= strtotime($end_dt)) {
         $room_day = RoomCalendar::firstOrNew(array('room_type_id' => $room_type, 'day' => $date));
         if (!$room_day->id) {
             $room_day->availability = $base_room->base_availability;
         }
         $room_day->rate = $price;
         $room_day->save();
         $date = date("Y-m-d", strtotime("+1 day", strtotime($date)));
         $i++;
     }
     return response("Success updated " . $i . " dates", 200);
 }
Example #2
0
		$hotel = $hotel->find($hotel_id);
		if(!$hotel){ die(header('Location: ' . DOMAIN . '404')); }

		$memberId = $hotel->member_id;
		if(!isset($_SESSION['user']['id']) || ($memberId != $_SESSION['user']['id'])){
			die(header('Location: ' . DOMAIN . 'dashboard/add-hotel/step-01'));
		}

		$toRemove = new Room();
		$roomType = new RoomType();
		$roomImage = new RoomImage();

		$toRemove = $toRemove->find($prop);
		if(!$toRemove){ die(header('Location: ' . $_SESSION['page_url'])); }
		if($toRemove->hotel_id != $hotel_id){ die(header('Location: ' . $_SESSION['page_url'])); }
		$remRoomType = $roomType->find($toRemove->room_type_id);
		$remRoomType->delete();
		$remRoomImage = $roomImage->where('hotel_id', '=', $hotel_id)
			->where('room_id', '=', $toRemove->id)
			->get();
		$delImageIds = [];
		$delImages = [];
		foreach($remRoomImage as $remImage){
			$delImageIds[] = $remImage->id;
			$delImages[] = $remImage->image;
		}
		$delImageIds = array_filter($delImageIds);
		$delImages = array_filter($delImages);
		$roomImage->whereIn('id', $delImageIds)->delete();
		foreach($delImages as $delImage){
			if((strlen($delImage) > 32) && file_exists(DOC_ROOT . 'uploads/room-photos/' . $delImage)){