We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Describe the bug According to the docs, this is eager loading. Post::withTranslation()->get(); It actually is. But when do the foreach
Post::withTranslation()->get();
foreach ($rows as $key => $row) { echo '<pre>', print_r($row->translation->name, 1), "</pre>"; }
It does the sql query for every row. If 10 rows, it's 1 sql for my product table, 10 sql for product_relations table
But if I use laravel's default's with() Product::with('translation')->get(); It's really eager loading.
Product::with('translation')->get();
So, maybe there is something wrong with the function withTranslation() ?
To Reproduce
//$products = (new Product)->with('translation')->get(); $products = (new Product)->withTranslation()->get(); // echo '<pre>', print_r($products, 1), "</pre>"; // This is always eager loading. foreach ($products as $key => $row) { echo '<pre>', print_r($row->translation->name, 1), "</pre>"; // This depends. }
The text was updated successfully, but these errors were encountered:
It doesn't load the translation relationship but filtered translations.
translation
translations
laravel-translatable/src/Translatable/Traits/Scopes.php
Lines 109 to 124 in a030356
Sorry, something went wrong.
Gummibeer
No branches or pull requests
Describe the bug
According to the docs, this is eager loading.
Post::withTranslation()->get();
It actually is. But when do the foreach
It does the sql query for every row. If 10 rows, it's 1 sql for my product table, 10 sql for product_relations table
But if I use laravel's default's with()
Product::with('translation')->get();
It's really eager loading.
So, maybe there is something wrong with the function withTranslation() ?
To Reproduce
The text was updated successfully, but these errors were encountered: