Skip to content

Commit 440bc22

Browse files
authored
perf: using the connection of the current model when open the transaction.
1 parent 5de36c5 commit 440bc22

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Adapters/DatabaseAdapter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public function removePolicy(string $sec, string $ptype, array $rule): void
186186
*/
187187
public function removePolicies(string $sec, string $ptype, array $rules): void
188188
{
189-
DB::transaction(function () use ($sec, $rules, $ptype) {
189+
$this->eloquent->getConnection()->transaction(function () use ($sec, $rules, $ptype) {
190190
foreach ($rules as $rule) {
191191
$this->removePolicy($sec, $ptype, $rule);
192192
}
@@ -276,7 +276,7 @@ public function updatePolicy(string $sec, string $ptype, array $oldRule, array $
276276
*/
277277
public function updatePolicies(string $sec, string $ptype, array $oldRules, array $newRules): void
278278
{
279-
DB::transaction(function () use ($sec, $ptype, $oldRules, $newRules) {
279+
$this->eloquent->getConnection()->transaction(function () use ($sec, $ptype, $oldRules, $newRules) {
280280
foreach ($oldRules as $i => $oldRule) {
281281
$this->updatePolicy($sec, $ptype, $oldRule, $newRules[$i]);
282282
}
@@ -296,7 +296,7 @@ public function updatePolicies(string $sec, string $ptype, array $oldRules, arra
296296
public function updateFilteredPolicies(string $sec, string $ptype, array $newPolicies, int $fieldIndex, string ...$fieldValues): array
297297
{
298298
$oldRules = [];
299-
DB::transaction(function () use ($sec, $ptype, $fieldIndex, $fieldValues, $newPolicies, &$oldRules) {
299+
$this->eloquent->getConnection()->transaction(function () use ($sec, $ptype, $fieldIndex, $fieldValues, $newPolicies, &$oldRules) {
300300
$oldRules = $this->_removeFilteredPolicy($sec, $ptype, $fieldIndex, ...$fieldValues);
301301
$this->addPolicies($sec, $ptype, $newPolicies);
302302
});

0 commit comments

Comments
 (0)