Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2015
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1.     public function checkAvailability($arrival, $departure, $roomTypeId, $amount)
  2.     {
  3.         $period = $this->createPeriod($arrival, $departure);
  4.  
  5.         $availableRooms = Room::where('room_type_id', $roomTypeId)->where('is_available', 1)->lists('id');
  6.         $occupancyArray = Night::where('date', '>=', $arrival)->where('date', '<=', $departure)->get()->toArray();
  7.         foreach ($occupancyArray as $night) {
  8.             foreach ($period as $key => $date) {
  9.                 $dateFormatted = $date->format('Y-m-d H:i:s');
  10.                 if (in_array($dateFormatted, $night)) {
  11.                     unset($availableRooms[array_search($night['room_id'], $availableRooms)]);
  12.                 }
  13.             }
  14.         }
  15.  
  16.         return $availableRooms;
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement