diff --git a/src/FlushQueryCacheObserver.php b/src/FlushQueryCacheObserver.php index ba049ff..7ca7ce2 100644 --- a/src/FlushQueryCacheObserver.php +++ b/src/FlushQueryCacheObserver.php @@ -154,12 +154,12 @@ protected function invalidateCache(Model $model, $relation = null, $pivotedModel { $class = get_class($model); - if (! $model->getCacheTagsToInvalidateOnUpdate($relation, $pivotedModels)) { + $tags = $model->getCacheTagsToInvalidateOnUpdate($relation, $pivotedModels); + + if (! $tags) { throw new Exception('Automatic invalidation for '.$class.' works only if at least one tag to be invalidated is specified.'); } - $class::flushQueryCache( - $model->getCacheTagsToInvalidateOnUpdate($relation, $pivotedModels) - ); + $class::flushQueryCache($tags); } }