We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 664d073 commit 72c6c70Copy full SHA for 72c6c70
src/Translatable.php
@@ -52,8 +52,13 @@ public static function bootTranslatable()
52
// SAVED
53
static::saved(function (Model $model) {
54
if ($model->wasRecentlyCreated)
55
- foreach ($model->translations as $translation)
56
- $translation->{$model->getTranslatableField()} = $model->getKey();
+ foreach ($model->translations as $locale => &$translation) {
+ if (is_array($translation)) {
57
+ $translation = $model->translateOrNew($locale);
58
+ } else {
59
+ $translation->{$model->getTranslatableField()} = $model->getKey();
60
+ }
61
62
63
$model->saveTranslations();
64
});
0 commit comments