According to this article two where clauses is allowed
https://www.paulmarkquinn.co.uk/laravel-wheredoesnthave/
i think that on end of state miss
->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I need to exclude records (hotel rooms) from Eloquent query that have booked any day between Check In and Check Out date URL parameters. When I try this raw query in phpMyadmin everything works fine and found all rooms that have any booked day between these two dates:
SELECT *
FROM jos_estateagentreservations
AND '2016-05-21' < date_to
AND '2016-07-17' > date_from
But, when I use this in Eloquent as a part with whereDoesntHave it shows rooms as a availiable even if they are not. Works only if Check In and Check Out dates are in the range of any of these booking records:
->whereDoesntHave('unitCalendar.unitReservation', function($query) use ($checkInDate, $checkOutDate){ $query->where('date_to','>',$checkInDate) ->where('date_from','<',$checkOutDate) ; })
Does anybody knows if whereDoesntHave not working with 2 WHERE clauses or is something else wrong? Thanks and sorry for bad english....
Please or to participate in this conversation.