I have 2 tables bookings
and eventDates
.
bookings
table has 2 fields checkIndate
and checkOutDate
which points to eventDates
table.
I setup following relationships
public function eventCheckInDate() {
return $this->belongsTo( 'EventDate', 'checkInDate' );
}
public function eventCheckOutDate() {
return $this->belongsTo( 'EventDate', 'checkOutDate' );
}
How can I combine those relationship so that eloquent only runs single query and get the data?
What happens now is it run 2 queries even if checkInDate
and checkOutDate
are still the same.
Thank you
checkInDate
andcheckOutDate
could be same or different for a booking. – Mike Ross