Skip to content

Commit d2fa36a

Browse files
authored
fix: delete without condition if cache disabled (#52)
1 parent 6639f0f commit d2fa36a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/cache/CacheHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ class CacheHandler implements CacheHandlerContract
1414
* Cache policies for the given model.
1515
*
1616
* @param Rule $model The model to cache policies for.
17-
* @return Query The cached query or a new query if caching is disabled.
17+
* @return Query|Rule The cached query if caching is disabled, or origin Rule.
1818
*/
19-
public function cachePolicies(Rule $model): Query
19+
public function cachePolicies(Rule $model): Query|Rule
2020
{
2121
if ($this->config('cache.enabled', false)) {
2222
$key = $this->config('cache.key', 'tauthz');
2323
$expire = $this->config('cache.expire', 0);
2424
return $model->cache($key, $expire);
2525
} else {
26-
return $model->newQuery();
26+
return $model;
2727
}
2828
}
2929
}

src/cache/CacheHandlerContract.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77

88
interface CacheHandlerContract
99
{
10-
public function cachePolicies(Rule $model): Query;
10+
public function cachePolicies(Rule $model): Query|Rule;
1111
}

0 commit comments

Comments
 (0)