mercredi 3 août 2016

Load all relations and their children in Laravel

I have a rather complex structure that contains multiple relations. If my relations are defined this way, how can I load all of them in one call?

Model
    (has many) ChildModels1
        Child1a
        Child1b
        ...
    (has many) ChildModels2
        Child2a
        Child2b
        ...
    (has many) ChildModels3
        Child3a
        Child3a
            Child3aa
            Child3ab
            ...

I'm able to do the following:

$entity = Entity::find($id)->load('ChildModels1', 'ChildModels2', 'ChildModels3');

But I'm not sure how to load all the child relations too.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire