This is my current relationships
I -> belongsTo -> S //in model I
S -> belongsTo -> C //in model S
C -> belongsTo -> T //in model C
T -> hasMany -> C //in model T
C -> hasMany -> S //in model C
S -> hasMany -> I //in model S
Right now, I am able to eager load until C
from I
but how do I eager load until T
also from I
? I have tried several ways such as I::with(['S.c'=>function($query){ $query->with('C.t') }])
but they all spit out errors.
You can eager load the descendant tables by using dot notation:
I::with(['S', 'S.C', 'S.C.T'])->get();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With