php - Can I preload belongsTo parent models in Laravel 4? -
I'm getting a big batch of 1000 scenes that I need to loop in my scene, I get them doing something like this I: And in my opinion, I do something like this: The problem is, it executes 1000 queries. Do I have any way of using the relationship with related technique methods without this big loss of skill? Yes, you have To get a $ children = child :: all ();
@forach (children as $ $ children) {$ $ child- & Gt; Mother- & Gt; Name}} @ adverback
with
:
$ Children = child :: with ('parent') - & gt; all ();
original relationship, only one additional query should be started.
Comments
Post a Comment