You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not really, I add some "tricky" code lines to make it work.
I modified 2 files.
BladeDirective.php : (line 72 to 76)
// Otherwise we'll try to use the item to calculate
// the cache key, itself.
if (is_object($item) && method_exists($item, 'getCacheKey')) {
$version = $key[0]; // Sets multiple cache versions
return $item->getCacheKey($version);
}
Cacheable.php : (line 13)
/**
* Calculate a unique cache key for the model instance.
*/
public function getCacheKey($version)
{
return sprintf("%s-%s/%s-%s",
$version, // Get the required cache version
get_class($this),
$this->getKey(),
$this->updated_at->timestamp
);
}
In your package, i can see that we have a single cached view for a model ?!
It could be great to pass different "versions of card model key" and generate several keys like :
used in blade: @cache($card, ['preview']))
$item->getCacheKey('preview-version')
used in blade: @cache($card, ['full']))
$item->getCacheKey('full-version')
I'm working on your code to use it in my project, because in my case it's impossible to use different design for a same model for the moment.
The text was updated successfully, but these errors were encountered: