Skip to content

Commit

Permalink
Change default value from null to empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrijsmihailovs committed Jan 2, 2018
1 parent 1c7f49a commit b245a27
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Traits/SyncTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function storeTranslations($values)
$array[$lang]['locale'] = $lang;

foreach ($this->translatedAttributes as $attribute) {
$array[$lang][$attribute] = isset($values[$lang][$attribute]) ? $values[$lang][$attribute] : null;
$array[$lang][$attribute] = isset($values[$lang][$attribute]) ? $values[$lang][$attribute] : '';
}
}

Expand All @@ -38,16 +38,16 @@ public function updateTranslations(array $values)
$array['locale'] = $lang;

foreach ($this->translatedAttributes as $key => $attribute) {
$array[$attribute] = isset($values[$lang][$attribute]) ? $values[$lang][$attribute] : null;
$array[$attribute] = isset($values[$lang][$attribute]) ? $values[$lang][$attribute] : '';
}

$translation = $this->translations()->where('locale', $lang)->first();

// Make sure we can translate Stapler files as well
$staplerConfig = (array) object_get($translation, 'staplerConfig', []);
$staplerConfig = (array)object_get($translation, 'staplerConfig', []);
$staplerFields = array_keys($staplerConfig);
foreach($staplerFields as $staplerField) {
$array = collect($array)->filter(function($value, $key) use ($staplerField) {
foreach ($staplerFields as $staplerField) {
$array = collect($array)->filter(function ($value, $key) use ($staplerField) {

$removable = [
$staplerField . '_file_name',
Expand All @@ -56,15 +56,15 @@ public function updateTranslations(array $values)
$staplerField . '_updated_at'
];

if(in_array($key, $removable)) {
if (in_array($key, $removable)) {
return false;
}

return true;
})->toArray();
}

if (!$translation) {
if (! $translation) {
$this->translations()->create($array);
} else {
$translation->update($array);
Expand Down

0 comments on commit b245a27

Please sign in to comment.