rememberable icon indicating copy to clipboard operation
rememberable copied to clipboard

Nested Eager Loading - Not Supported

Open NeoMarine opened this issue 4 years ago • 1 comments

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);
}]);

NeoMarine avatar Jul 13 '19 04:07 NeoMarine

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); }
]);

craigwileman avatar Jul 14 '19 13:07 craigwileman