eloquent-driver
eloquent-driver copied to clipboard
How to eager load relations?
I try to load a page and the associated taxonomies terms of it but the problem is that extra queries are being done. I am using Statamic multisite. I would like to be able to eager load only those associated with that specific entry. So I have a tags taxonomy and I want something like:
$queryBuilder = Entry::with(['tags'])->query()
->where('collection','pages')
->where('slug', 'my-page')
->where('site', 'en');
->where('published', true)->get();
Many thanks
At the moment with()
doesn't do anything in the Eloquent Entry Query builder.
See: https://github.com/statamic/eloquent-driver/blob/83d461614d1967036e0d0ec1dd069e3ce3d82e42/src/Entries/EntryQueryBuilder.php#L84
I thought so... this takes away one of the greatest advantages of using Laravel, the fact that I can load related content basically on the fly.