What is the relationship type to the User? How does the cars table look? Are you leveraging Carbon for those date columns?
Please use Github code formatting.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
$pickupDate = 2017-10-23 $returnDate = 2017-10-23 $pickupTime = "9:00:00" $returnTime = "11:00:00" $cars = Car::where("availability",true)->whereDoesntHave('User', function ($cars) use ($pickupDate,$pickupTime,$returnDate,$returnTime){ $cars->whereBetween('pickup_date',[$pickupDate,$returnDate])>whereBetween('pickup_time',[$pickupTime,$returnTime]) ->whereBetween('return_date',[$pickupDate,$returnDate]) ->whereBetween('return_time',[$pickupTime,$returnTime]); })->get();
but it is not working fine. it give me car that has already reservation it gives me back two cars having reservation 8:00 to 12:00 and 11:00 to 12:00
Please or to participate in this conversation.