mercredi 19 juin 2019

Eager load multiple levels of records with Laravel

I have the following data structure:

service

service_journey

service_journey_section

A service has many service_journeys. service_journeys has many service_journey_sections.

I want to eager load all services with all children(service_journeys) and grandchildren(service_journey_sections).

What I have so far:

Services::with('service_journeys', 'service_journey_sections')->get();

However I am worried that this assumes service_journeys and service_journey_sections are both direct children of a service rather than parent, child, grandchild.

Can someone please confirm that either, I am doing it correctly, or correct me where I am going wrong.

Many thanks.



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2WSv8TE
via IFTTT

Aucun commentaire:

Enregistrer un commentaire