简体   繁体   中英

Hotel Room Listing in Laravel

I am trying to build hotel room booking management system using Laravel.

Problem in retrieving room available based on the user search in the portal

Hotel has many rooms and rooms has many tariff based on the date. I need all the room tarrif based on the check in and check out date. But i am getting all the records which are there in database between that days. I want only the room which are available on all the days.

Example: User is searching hotel from 19-11-2019 to 22-11-2019. But some hotel inventory are not there on 21-11-2019. But i am getting that records.I want the records which are available on all the days.(ie 19-11-2019,20-11-2019,21-11-2019,22-11-2019)

HotelPriceDetail::where('room_id',$value->room_id)
                  ->whereBetween('hotel_price_details.date',[$check_in,$check_out])
                  ->where('hotel_price_details.inventory','>=',$total_adults)
                  ->get();

Can any one suggest me what i need to change in my code.

Can you dump your $check_in and $check_out variables? I'm not sure if your date format is correct. It should be something like this

$from = date('2019-11-19');
$to = date('2019-11-22');

HotelPriceDetail::whereBetween('hotel_price_details.date', [$from, $to])->get();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM