Skip to content

Commit

Permalink
Add setTranslations fallback to support nova-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarpsvo committed Jan 17, 2020
1 parent e57d8ca commit e05f1a0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/FieldServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ public function boot()
});

$this->fillUsing(function ($request, $model, $attribute, $requestAttribute) {
$realAttribute = $this->meta['translatable']['original_attribute'];
$realAttribute = $this->meta['translatable']['original_attribute'] ?? $attribute;
$value = $request->{$realAttribute};
$translations = is_string($value) ? (array) json_decode($value) : $value;
$model->setTranslations($realAttribute, $translations);
if (method_exists($model, 'setTranslations')) $model->setTranslations($realAttribute, $translations);
else $model->{$realAttribute} = $translations;
});

return $this;
Expand Down

0 comments on commit e05f1a0

Please # to comment.