Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested Eager Loading - Not Supported #72

Open
NeoMarine opened this issue Jul 13, 2019 · 1 comment
Open

Nested Eager Loading - Not Supported #72

NeoMarine opened this issue Jul 13, 2019 · 1 comment

Comments

@NeoMarine
Copy link

I tried to use the cache with nested eager loading, but didn't cache that part of the query:

$query->with(['feedback.profile' => function ($query) {
	//Cache
	$cacheTime = 60;
	$query->remember($cacheTime);
}]);

It does however work with a simple eager loading:

$query->with(['feedback' => function ($query) {
	//Cache
	$cacheTime = 60;
	$query->remember($cacheTime);
}]);
@craigwileman
Copy link

When you say "didn't cache that part of the query" are you specifically referring to feedback?

The easiest solution is just to cache it separately and only requires one additional line:

$query->with([
    'feedback => function ($query) { $query->remember(60); }
    'feedback.profile' => function ($query) { $query->remember(60); }
]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants