Skip to content

Commit e986d4d

Browse files
author
Tihomir Banov
committed
Check if there is no translation return null
1 parent 700a269 commit e986d4d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Despark/LaravelDbLocalization/i18nModelTrait.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,15 @@ public function translate($locale = null)
8686
if (!is_int($locale)) {
8787
$locale = $this->getI18nId($locale);
8888
}
89-
$trans = $translationModel::where($this->translatorField, $this->id)
89+
90+
$translation = null;
91+
92+
if (!isset($this->id)) {
93+
$translation = $translationModel::where($this->translatorField, $this->id)
9094
->where($this->localeField, $locale)->first();
95+
}
9196

92-
return $trans;
97+
return $translation;
9398
}
9499

95100
/**

0 commit comments

Comments
 (0)