Closed camohub closed 1 week ago
Hi, @camohub. Please, provide your code example for the problem.
Because, if you need to use translations from nested models, in general, case you need to load translations too, for example:
Post::with('postCategories.translation')->get();
// or
Post::with([
'postCategories' => fn ($query) => $query->withTranslation(),
])
And you say you use Spatie/Querybuilder, explicitly include them, or modify the query how you need:
QueryBuilder::for(Post::class)
->with('postCategories.translation')
->get();
I am not sure if it is a bug. Hope it is not. The problem is that if I load relations through $with the relation translations are not lazy loaded. It generates huge amount of sql requests one for each relation entity.
We use this package with Spatie/Querybuilder package. But it should be irelevant.
I hope there is a way to set up lazy loading also on relations entities.![lazy](https://github.com/Astrotomic/laravel-translatable/assets/8393426/a1b375a2-2de5-48aa-baf8-20b565b6f7c6)