From 32b9c60bb9ac6f6a5e7782d8fcdb097f1b15d58e Mon Sep 17 00:00:00 2001 From: Richard van Baarsen Date: Mon, 9 Nov 2020 07:31:38 +0100 Subject: [PATCH] fix: use model database connection for transaction (#19) --- src/Traits/Sequenceable.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Traits/Sequenceable.php b/src/Traits/Sequenceable.php index 9376bf8..9ec1646 100644 --- a/src/Traits/Sequenceable.php +++ b/src/Traits/Sequenceable.php @@ -7,7 +7,6 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Collection; -use Illuminate\Support\Facades\DB; trait Sequenceable { @@ -235,7 +234,7 @@ protected function getOriginalSequenceValue(): ?int */ protected static function updateSequenceablesAffectedBy(Model $model): void { - DB::transaction(function () use ($model) { + $model->getConnection()->transaction(function () use ($model) { $modelsToUpdate = $model->getSequence() ->where('id', '!=', $model->id) ->filter(function ($sequenceModel) use ($model) {