diff --git a/app/Classes/Settings/Invoices.php b/app/Classes/Settings/Invoices.php index 4cca06b5..b19bb6e3 100644 --- a/app/Classes/Settings/Invoices.php +++ b/app/Classes/Settings/Invoices.php @@ -33,9 +33,7 @@ class Invoices foreach ($values as $key => $value) { $param = $request->get($value); - if (!$param) { - $param = ""; - } + Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]); Cache::forget("setting" . ':' . $key); } @@ -46,6 +44,6 @@ class Invoices } - return redirect(route('admin.settings.index') . '#invoices')->with('success', 'Invoice settings updated!'); + return redirect(route('admin.settings.index') . '#invoices')->with('success', __('Invoice settings updated!')); } } diff --git a/app/Classes/Settings/Language.php b/app/Classes/Settings/Language.php index 55818b1d..1d59614a 100644 --- a/app/Classes/Settings/Language.php +++ b/app/Classes/Settings/Language.php @@ -30,15 +30,13 @@ class Language foreach ($values as $key => $value) { $param = $request->get($value); - if (!$param) { - $param = "false"; - } + Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]); Cache::forget("setting" . ':' . $key); Session::remove("locale"); } - return redirect(route('admin.settings.index') . '#language')->with('success', 'Language settings updated!'); + return redirect(route('admin.settings.index') . '#language')->with('success', __('Language settings updated!')); } } diff --git a/app/Classes/Settings/Payments.php b/app/Classes/Settings/Payments.php index 7442f2b8..2accf807 100644 --- a/app/Classes/Settings/Payments.php +++ b/app/Classes/Settings/Payments.php @@ -35,14 +35,12 @@ class Payments foreach ($values as $key => $value) { $param = $request->get($value); - if (!$param) { - $param = ""; - } + Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]); Cache::forget("setting" . ':' . $key); } - return redirect(route('admin.settings.index') . '#payment')->with('success', 'Payment settings updated!'); + return redirect(route('admin.settings.index') . '#payment')->with('success', __('Payment settings updated!')); } } diff --git a/database/migrations/2022_01_14_234418_update_settings_table_allow_nullable.php b/database/migrations/2022_01_14_234418_update_settings_table_allow_nullable.php new file mode 100644 index 00000000..20d5a0c9 --- /dev/null +++ b/database/migrations/2022_01_14_234418_update_settings_table_allow_nullable.php @@ -0,0 +1,34 @@ +string('value')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + //disallow value column in settings table to be nullable + Schema::table('settings', function (Blueprint $table) { + $table->string('value')->nullable(false)->change(); + }); + } +} diff --git a/resources/views/admin/settings/index.blade.php b/resources/views/admin/settings/index.blade.php index 54c17954..5941c483 100644 --- a/resources/views/admin/settings/index.blade.php +++ b/resources/views/admin/settings/index.blade.php @@ -73,20 +73,19 @@ var fileName = $(this).val().split("\\").pop(); $(this).siblings(".custom-file-label").addClass("selected").html(fileName); }); - - const tabPaneHash = window.location.hash; - if (tabPaneHash) { - $('.nav-tabs a[href="' + tabPaneHash + '"]').tab('show'); - } - - $('.nav-tabs a').click(function(e) { - $(this).tab('show'); - const scrollmem = $('body').scrollTop(); - window.location.hash = this.hash; - $('html,body').scrollTop(scrollmem); - }); - }) + + const tabPaneHash = window.location.hash; + if (tabPaneHash) { + $('.nav-tabs a[href="' + tabPaneHash + '"]').tab('show'); + } + + $('.nav-tabs a').click(function(e) { + $(this).tab('show'); + const scrollmem = $('body').scrollTop(); + window.location.hash = this.hash; + $('html,body').scrollTop(scrollmem); + }); diff --git a/resources/views/admin/settings/tabs/misc.blade.php b/resources/views/admin/settings/tabs/misc.blade.php index 74ba7aee..623ef94b 100644 --- a/resources/views/admin/settings/tabs/misc.blade.php +++ b/resources/views/admin/settings/tabs/misc.blade.php @@ -88,20 +88,19 @@