diff --git a/src/cache/CacheHandler.php b/src/cache/CacheHandler.php index a26dc84..29890c1 100644 --- a/src/cache/CacheHandler.php +++ b/src/cache/CacheHandler.php @@ -14,16 +14,16 @@ class CacheHandler implements CacheHandlerContract * Cache policies for the given model. * * @param Rule $model The model to cache policies for. - * @return Query The cached query or a new query if caching is disabled. + * @return Query|Rule The cached query if caching is disabled, or origin Rule. */ - public function cachePolicies(Rule $model): Query + public function cachePolicies(Rule $model): Query|Rule { if ($this->config('cache.enabled', false)) { $key = $this->config('cache.key', 'tauthz'); $expire = $this->config('cache.expire', 0); return $model->cache($key, $expire); } else { - return $model->newQuery(); + return $model; } } } diff --git a/src/cache/CacheHandlerContract.php b/src/cache/CacheHandlerContract.php index 6b505fe..f8db7a8 100644 --- a/src/cache/CacheHandlerContract.php +++ b/src/cache/CacheHandlerContract.php @@ -7,5 +7,5 @@ interface CacheHandlerContract { - public function cachePolicies(Rule $model): Query; + public function cachePolicies(Rule $model): Query|Rule; } \ No newline at end of file