Skip to content

Commit 2cccd09

Browse files
committed
fix:LaravelDatabaseAdapter removePolicies errorA facade root has not been set
1 parent ec825f0 commit 2cccd09

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Adapter/LaravelDatabaseAdapter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use Casbin\WebmanPermission\Model\LaravelRuleModel;
2222
use Illuminate\Database\Eloquent\Builder;
2323
use Illuminate\Database\Eloquent\Collection;
24-
use Illuminate\Support\Facades\DB;
24+
use support\Db;
2525
use Throwable;
2626

2727
/**
@@ -208,7 +208,7 @@ public function _removeFilteredPolicy(string $sec, string $ptype, int $fieldInde
208208
*/
209209
public function removePolicies(string $sec, string $ptype, array $rules): void
210210
{
211-
DB::transaction(function () use ($sec, $ptype, $rules) {
211+
Db::transaction(function () use ($sec, $ptype, $rules) {
212212
foreach ($rules as $rule) {
213213
$this->removePolicy($sec, $ptype, $rule);
214214
}
@@ -269,7 +269,7 @@ public function updatePolicy(string $sec, string $ptype, array $oldRule, array $
269269
*/
270270
public function updatePolicies(string $sec, string $ptype, array $oldRules, array $newRules): void
271271
{
272-
DB::transaction(function () use ($sec, $ptype, $oldRules, $newRules) {
272+
Db::transaction(function () use ($sec, $ptype, $oldRules, $newRules) {
273273
foreach ($oldRules as $i => $oldRule) {
274274
$this->updatePolicy($sec, $ptype, $oldRule, $newRules[$i]);
275275
}
@@ -289,7 +289,7 @@ public function updatePolicies(string $sec, string $ptype, array $oldRules, arra
289289
public function updateFilteredPolicies(string $sec, string $ptype, array $newPolicies, int $fieldIndex, string ...$fieldValues): array
290290
{
291291
$oldRules = [];
292-
DB::transaction(function () use ($sec, $ptype, $fieldIndex, $fieldValues, $newPolicies, &$oldRules) {
292+
Db::transaction(function () use ($sec, $ptype, $fieldIndex, $fieldValues, $newPolicies, &$oldRules) {
293293
$oldRules = $this->_removeFilteredPolicy($sec, $ptype, $fieldIndex, ...$fieldValues);
294294
$this->addPolicies($sec, $ptype, $newPolicies);
295295
});

0 commit comments

Comments
 (0)