Skip to content

Commit

Permalink
feat: 🎸 Apply useWritePdo() to all createOrFirst impls
Browse files Browse the repository at this point in the history
  • Loading branch information
mpyw committed Aug 25, 2023
1 parent fdf6dfe commit 1f0e298
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ public function createOrFirst(array $attributes = [], array $values = [])
try {
return $this->withSavepointIfNeeded(fn () => $this->create(array_merge($attributes, $values)));
} catch (UniqueConstraintViolationException $exception) {
return $this->where($attributes)->first();
return $this->useWritePdo()->where($attributes)->first();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ public function createOrFirst(array $attributes = [], array $values = [], array
$this->getQuery()->withSavepointIfNeeded(fn () => $this->attach($instance, $joining, $touch));
});
} catch (UniqueConstraintViolationException $exception) {
return (clone $this)->where($attributes)->first();
return (clone $this)->useWritePdo()->where($attributes)->first();
}
}

Expand Down

0 comments on commit 1f0e298

Please sign in to comment.