Skip to content

Commit

Permalink
fix: use model database connection for transaction (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
riesjart authored Nov 9, 2020
1 parent d28079f commit 32b9c60
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/Traits/Sequenceable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 32b9c60

Please sign in to comment.