mardi 4 février 2020

add conditon on whereNotIn() laravel

I am try to do is check if the booking is b/n request check_in and check_out date. if so exclude the booking with booked status =1.


$room->bookings()->where(function ($query) use ($check_in, $check_out, $statusCollect) {
                       $query->where('check_in','<=',$check_out) 
                             ->where('check_out','>=',$check_in)
                       ->whereNotIn('book_status_id', $statusCollect)
 });

but the problem is this query filter all inside table. how I can I use if statement in whereNotIn() or is there is other method.

what I need is if the check_in<=$check_in and $check_out >=check_out then give me booking table row then check the bookstatus, if it pass get me the row.

I hope I don't make it complicated:). thanks

Aucun commentaire:

Enregistrer un commentaire