Level 50
@AlexMunoz you could load all relations with eager loading, lazy eager loading or a mix of both like your code displays.
// Eager loading
$sector = Sector::with('companies.meetings', 'companies.sectors', 'processes')->find('1');
5 likes
Hello,
I'm trying to eager load a couple of nested relationships but I'm unsure on how to do it.
Currently I have this code:
$sector = Sector::with('companies.meetings', 'processes')->find('1');
$sector->companies->load('sectors');
So I'm eager loading one of the companies relationships and lazy eager loading the other one.
Is there a better way to handle this?
@AlexMunoz you could load all relations with eager loading, lazy eager loading or a mix of both like your code displays.
// Eager loading
$sector = Sector::with('companies.meetings', 'companies.sectors', 'processes')->find('1');
Please or to participate in this conversation.