File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -26,9 +26,10 @@ protected static function bootTranslatable()
26
26
foreach ((array )with (new self )->translatable as $ item ) {
27
27
if ($ model ->{$ item }) {
28
28
if (is_array ($ model ->{$ item })) {
29
- $ model ->{ $ item } = json_encode ( array_filter ($ model ->{$ item }, function ($ var ) {
29
+ $ translations = array_filter ($ model ->{$ item }, function ($ var ) {
30
30
return strlen (strip_tags (trim ($ var ))) != 0 ;
31
- }));
31
+ });
32
+ $ model ->{$ item } = count ($ translations ) ? json_encode ($ translations ) : '' ;
32
33
} elseif (is_string ($ model ->{$ item }) && !is_array (json_decode ($ model ->{$ item }, true ))) {
33
34
$ model ->{$ item } = json_encode ([config ('app.locale ' ) => $ model ->{$ item }]);
34
35
}
@@ -73,9 +74,10 @@ protected static function bootTranslatable()
73
74
$ original_locales [$ locale ] = $ value ;
74
75
}
75
76
//remove empty translations from array and save as json
76
- $ model ->{ $ item } = json_encode ( array_filter ($ original_locales , function ($ var ) {
77
+ $ translations = array_filter ($ original_locales , function ($ var ) {
77
78
return strlen (strip_tags (trim ($ var ))) != 0 ;
78
- }));
79
+ });
80
+ $ model ->{$ item } = count ($ translations ) ? json_encode ($ translations ) : '' ;
79
81
} else {
80
82
//TODO: update locales in translation model
81
83
//
You can’t perform that action at this time.
0 commit comments