diff --git a/src/Cache/PolicyCache.php b/src/Cache/PolicyCache.php index d41bf67a..53fde5e4 100644 --- a/src/Cache/PolicyCache.php +++ b/src/Cache/PolicyCache.php @@ -32,6 +32,10 @@ public static function keyForPolicyMethods(string $repositoryKey, string $policy public static function resolve(string $key, callable|Closure $data): mixed { + if (! static::enabled()) { + return $data(); + } + if (Cache::has($key)) { return Cache::get($key); } diff --git a/src/Traits/AuthorizableModels.php b/src/Traits/AuthorizableModels.php index dcbae8db..d55b4842 100644 --- a/src/Traits/AuthorizableModels.php +++ b/src/Traits/AuthorizableModels.php @@ -35,13 +35,7 @@ public static function authorizedToUseRepository(Request $request): bool : false; }; - if (! PolicyCache::enabled()) { - return $resolver(); - } - - $key = PolicyCache::keyForAllowRestify(static::uriKey()); - - return PolicyCache::resolve($key, $resolver); + return PolicyCache::resolve(PolicyCache::keyForAllowRestify(static::uriKey()), $resolver); } /**