Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function checkAvailability($arrival, $departure, $roomTypeId, $amount)
- {
- $period = $this->createPeriod($arrival, $departure);
- $availableRooms = Room::where('room_type_id', $roomTypeId)->where('is_available', 1)->lists('id');
- $occupancyArray = Night::where('date', '>=', $arrival)->where('date', '<=', $departure)->get()->toArray();
- foreach ($occupancyArray as $night) {
- foreach ($period as $key => $date) {
- $dateFormatted = $date->format('Y-m-d H:i:s');
- if (in_array($dateFormatted, $night)) {
- unset($availableRooms[array_search($night['room_id'], $availableRooms)]);
- }
- }
- }
- return $availableRooms;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement