From cad797d8bf1576743efbb98afdafc18c9b787d9c Mon Sep 17 00:00:00 2001 From: A1Gard Date: Sat, 19 Oct 2024 04:49:19 +0330 Subject: [PATCH] fixed multi-lang problem --- app/Helpers/Helper.php | 7 ++++--- app/Http/Controllers/Admin/SettingController.php | 1 + .../migrations/2024_05_07_133136_create_settings_table.php | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index b101baf..b53cc50 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -680,9 +680,10 @@ function getSetting($key) // $a = new \stdClass(); return ''; } - if (config('app.xlang') && ($x->type == 'group' || $x->type == 'category')) { - $defLang = config('app.xlang_main'); - return $x->getTranslations('value')[$defLang]; + + $txtType = ['TEXT','LONGTEXT','EDITOR']; + if (config('app.xlang') && !in_array($x->type, $txtType)) { + return $x->raw; } return $x->value; } diff --git a/app/Http/Controllers/Admin/SettingController.php b/app/Http/Controllers/Admin/SettingController.php index 16adcb3..7e57ac7 100644 --- a/app/Http/Controllers/Admin/SettingController.php +++ b/app/Http/Controllers/Admin/SettingController.php @@ -80,6 +80,7 @@ class SettingController extends Controller if ($set != null && !$request->hasFile($key)) { $set->value = validateSettingRequest($set,$val); + $set->raw = validateSettingRequest($set,$val); // need to test if (config('app.xlang.active') && config('app.xlang.main') != 'en' && ( $set->type != 'TEXT' && $set->type != 'EDITOR' && $set->type != 'LONGTEXT')){ diff --git a/database/migrations/2024_05_07_133136_create_settings_table.php b/database/migrations/2024_05_07_133136_create_settings_table.php index 6d03780..935609f 100644 --- a/database/migrations/2024_05_07_133136_create_settings_table.php +++ b/database/migrations/2024_05_07_133136_create_settings_table.php @@ -19,6 +19,7 @@ return new class extends Migration $table->boolean('active')->default(true); $table->string('key')->unique(); $table->text('value')->nullable(); + $table->text('raw')->nullable(); $table->boolean('ltr')->default(false); $table->boolean('is_basic')->default(false); $table->boolean('size')->default('12');