File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,31 +12,21 @@ class AdvObserver extends EntryObserver
1212{
1313 private function translateFixer ($ entryId )
1414 {
15- //TODO:: Use single query
16- $ defaultLocale = setting_value ('streams::default_locale ' );
17- $ translations = DB ::table ('advs_advs_translations ' )
18- ->select (['locale ' , 'name ' ])
15+
16+ //TODO TEMP LANG FIX WITH FATIH.
17+ $ transCount = DB ::table ('advs_advs_translations ' )
18+ ->select ('id ' )
19+ ->whereNull ('name ' )
1920 ->where ('entry_id ' , $ entryId )
20- ->whereNotNull ('locale ' )
21- ->get ();
21+ ->count ();
2222
23- if ($ translations ) {
24- $ name = "" ;
25- foreach ($ translations as $ translation ) {
26- if ($ translation ->locale == $ defaultLocale && !empty ($ translation ->name )) {
27- $ name = $ translation ->name ;
28- break ;
29- } else if (!empty ($ translation ->name )) {
30- $ name = $ translation ->name ;
31- }
32- }
3323
24+ if ($ transCount > 1 ) {
3425 DB ::table ('advs_advs_translations ' )
3526 ->whereNull ('name ' )
3627 ->where ('entry_id ' , $ entryId )
37- ->update ([ ' name ' => $ name ] );
28+ ->delete ( );
3829 }
39-
4030 }
4131
4232 public function created (EntryInterface $ entry )
You can’t perform that action at this time.
0 commit comments