From ae80fa17029dfa48719c9ebf46d3306296860ad5 Mon Sep 17 00:00:00 2001 From: Mohammed Rajab Date: Wed, 9 Oct 2019 10:45:39 +0300 Subject: [PATCH] Update Database.php --- src/Drivers/Database.php | 46 ++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/Drivers/Database.php b/src/Drivers/Database.php index 149c7d6..7578d5c 100644 --- a/src/Drivers/Database.php +++ b/src/Drivers/Database.php @@ -103,17 +103,24 @@ public function addGroupTranslation($language, $group, $key, $value = '') $this->addLanguage($language); } - Language::where('language', $language) - ->first() - ->translations() - ->updateOrCreate([ - 'group' => $group, - 'key' => $key, - ], [ + $translation=Translation::whereGroup($group)->whereKey($key)->first(); + if(!$translation) + Translation::create([ 'group' => $group, 'key' => $key, 'value' => $value, ]); +// Language::where('language', $language) +// ->first() +// ->translations() +// ->updateOrCreate([ +// 'group' => $group, +// 'key' => $key, +// ], [ +// 'group' => $group, +// 'key' => $key, +// 'value' => $value, +// ]); } /** @@ -129,17 +136,24 @@ public function addSingleTranslation($language, $vendor, $key, $value = '') if (! $this->languageExists($language)) { $this->addLanguage($language); } - - Language::where('language', $language) - ->first() - ->translations() - ->updateOrCreate([ - 'group' => $vendor, - 'key' => $key, - ], [ + + $translation=Translation::whereNull('group')->whereKey($key)->first(); + if(!$translation) + Translation::create([ 'key' => $key, 'value' => $value, - ]); + ]); + +// Language::where('language', $language) +// ->first() +// ->translations() +// ->updateOrCreate([ +// 'group' => $vendor, +// 'key' => $key, +// ], [ +// 'key' => $key, +// 'value' => $value, +// ]); } /**