I have some trouble with getting the correct output of a Eloquent Query.
$checkIn = date(request()->checkin);
$checkOut = date(request()->checkout);
$bookedRooms = App\Booking::whereBetween('checkin', [$checkin, $checkout])->whereBetween('checkout', [$checkin, $checkout])->pluck('room_id');
$availabileRooms = App\Room::whereNotIn('id', $bookedRooms->toArray())->sum('number_of_rooms');
What I have is a checkin and checkout date.
It is a database for a Hotel. The Hotel has Rooms. There a different types of Rooms, and each Room can exist multiple times. That is set in the Room-table with an integer value of the rooms available in column number_of_rooms
What I want, it the output of the percentage that is still available of a specific Room and the total availability of Rooms in the date range.
I thought that it can be achieved with the code given before, but that can be not.
Can someone help me out? Probably it's simpler then I can think of now..
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire