Skip to content

Commit 52ca85a

Browse files
authored
Support to throw exception when read null from Model::createOrFirst.
1 parent 02ee7e6 commit 52ca85a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Model/Builder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,8 @@ public function createOrFirst(array $attributes = [], array $values = [])
575575
{
576576
try {
577577
return $this->create(array_merge($attributes, $values));
578-
} catch (UniqueConstraintViolationException $exception) {
579-
return $this->where($attributes)->first();
578+
} catch (UniqueConstraintViolationException $e) {
579+
return $this->where($attributes)->first() ?? throw $e;
580580
}
581581
}
582582

0 commit comments

Comments
 (0)