File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -63,15 +63,16 @@ public function getTranslationRelationKey(): string
6363
6464 public function translation (): HasOne
6565 {
66- if ($ this ->useFallback () && ! $ this ->translations ()->where ('locale ' , $ this ->locale ())->exists ()) {
67- return $ this
68- ->hasOne ($ this ->getTranslationModelName (), $ this ->getTranslationRelationKey ())
69- ->where ('locale ' , $ this ->getFallbackLocale ());
70- }
71-
7266 return $ this
7367 ->hasOne ($ this ->getTranslationModelName (), $ this ->getTranslationRelationKey ())
74- ->where ('locale ' , $ this ->locale ());
68+ ->where ('locale ' , $ this ->localeOrFallback ());
69+ }
70+
71+ public function localeOrFallback ()
72+ {
73+ return $ this ->useFallback () && ! $ this ->translations ()->where ('locale ' , $ this ->locale ())->exists ()
74+ ? $ this ->getFallbackLocale ()
75+ : $ this ->locale ();
7576 }
7677
7778 public function translations (): HasMany
You can’t perform that action at this time.
0 commit comments