Skip to content

Commit 70fde6f

Browse files
committed
fix: 🐛 Apply useWritePdo() to all createOrFirst impls
1 parent fdf6dfe commit 70fde6f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Illuminate/Database/Eloquent/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ public function createOrFirst(array $attributes = [], array $values = [])
582582
try {
583583
return $this->withSavepointIfNeeded(fn () => $this->create(array_merge($attributes, $values)));
584584
} catch (UniqueConstraintViolationException $exception) {
585-
return $this->where($attributes)->first();
585+
return $this->useWritePdo()->where($attributes)->first();
586586
}
587587
}
588588

src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ public function createOrFirst(array $attributes = [], array $values = [], array
653653
$this->getQuery()->withSavepointIfNeeded(fn () => $this->attach($instance, $joining, $touch));
654654
});
655655
} catch (UniqueConstraintViolationException $exception) {
656-
return (clone $this)->where($attributes)->first();
656+
return (clone $this)->useWritePdo()->where($attributes)->first();
657657
}
658658
}
659659

0 commit comments

Comments
 (0)