rememberable
rememberable copied to clipboard
Nested Eager Loading - Not Supported
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);
}]);
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); }
]);