File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
src/Despark/LaravelDbLocalization Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -67,11 +67,15 @@ public function getI18nId($locale = null)
67
67
$ locale = \App::getLocale ();
68
68
}
69
69
$ localeModel = Config::get ('laravel-db-localization::locale_class ' );
70
- $ i18n = $ localeModel ::select ('id ' )->where ('locale ' , $ locale )->firstOrFail ();
70
+ $ i18n = $ localeModel ::select ('id ' )->where ('locale ' , $ locale )->first ();
71
71
72
- $ this -> i18nId = $ i18n -> id ;
72
+ $ i18nId = null ;
73
73
74
- return $ this ->i18nId ;
74
+ if (isset ($ i18n ->id )) {
75
+ $ i18nId = $ i18n ->id ;
76
+ }
77
+
78
+ return $ i18nId ;
75
79
}
76
80
77
81
/**
@@ -86,10 +90,9 @@ public function translate($locale = false)
86
90
if (!is_int ($ locale )) {
87
91
$ locale = $ this ->getI18nId ($ locale );
88
92
}
89
-
90
93
$ translation = null ;
91
94
92
- if (isset ($ this ->id ) && ! $ locale ) {
95
+ if (isset ($ this ->id ) && $ locale ) {
93
96
$ translation = $ translationModel ::where ($ this ->translatorField , $ this ->id )
94
97
->where ($ this ->localeField , $ locale )->first ();
95
98
}
You can’t perform that action at this time.
0 commit comments