From 629a934f695e89a6d890140acec1d2a29bd94d7f Mon Sep 17 00:00:00 2001 From: Moamen Eltouny <16774083+RaggiTech@users.noreply.github.com> Date: Mon, 20 Sep 2021 19:34:01 +0200 Subject: [PATCH] Update Actions.php --- src/Traits/Actions.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Traits/Actions.php b/src/Traits/Actions.php index a279999..0b59cd4 100644 --- a/src/Traits/Actions.php +++ b/src/Traits/Actions.php @@ -42,8 +42,18 @@ protected function getTranslation(?string $locale = null): ?Model $this->hasTranslation($locale); - if (isset($this->translations[$locale])) + if (isset($this->translations[$locale])) { + if (is_array($this->translations[$locale])) { + $item = $this->getTranslatableModel(); + $item = new $item(); + $item->locale = $locale; + $item->{$this->getTranslatableField()} = $this->getKey(); + $item->fill($this->translations[$locale]); + $this->addTranslatableWithLocale($locale, $item); + } + return $this->translations[$locale]; + } return null; }