Skip to content

Commit 7fe91c4

Browse files
committed
fix: return null when is not available
1 parent bfee0ea commit 7fe91c4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/DbTranslatable/IsDbTranslatable.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ public function getTranslation(?string $locale = null): ?static
7171

7272
$defaultTranslation = $this->isDefaultTranslation() ? $this : $this->defaultTranslation;
7373

74+
// Return fast if there is no default translation
75+
if ( ! $defaultTranslation) {
76+
return null;
77+
}
78+
7479
// If the requested locale is the same as the default translation's lang, return the default translation
7580
if ($defaultTranslation->lang === $locale) {
7681
return $defaultTranslation;

0 commit comments

Comments
 (0)