Let's say I have these relationships
class Invitation
{
public function invitedPeople()
{
return $this->belongsTo('App\Person', 'personID');
}
}
class Person
{
public function apartments()
{
return $this->belongsToMany('App\Apartment', 'apartment_person', 'personID', 'apartmentID');
}
}
class Apartment
{
public function city()
{
return $this->belongsTo('App\City', 'cityID');
}
}
My question here is, how many nested levels can we have when using Laravel eager loading? I've tried this query and it's not working, can someone suggest a work around for this?
return Invitation::with(['invitedPeople', 'invitedPeople.apartments', 'invitedPeople.apartments.city'])