hope you all doing great.
I just moved to Laravel recently from CI.
I have two tables - Bookings - Booked_Rooms
What i want is if all the rooms are checked_out which i will decide by using Booked_Rooms.checkout_at is null then parent record should exclude from data set.
I tried google and did little bit research but couldn't find what i am actually looking.
I also tried Booking:with(array('rooms',function($q){ // where query }))
but it is still fetching the parent record. I don't want to traverse every single record by loop and then excluding the records because it doesn't looks good for performance measurement. I also know that i can do this by using join but can i do this using Eloquent ORM
Summary : If all the checkout_at columns of all booked_rooms are not null then the parent booking record is considered as completed and shouldn't be in pending bookings.
HtlBooking Model Class
public function rooms()
{
return $this->hasMany('App\BookedRoom','booking_id');
}
Controller Function
$bookings = HtlBooking::with ( 'rooms' )->with ( 'user' )
->get ();