feat: Allow value column in table to be nullable -> can store "0" values

This commit is contained in:
IceToast 2022-01-15 00:49:33 +01:00
parent 1e085982af
commit 4621547c01
8 changed files with 74 additions and 47 deletions

View file

@ -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!'));
}
}

View file

@ -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!'));
}
}

View file

@ -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!'));
}
}

View file

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateSettingsTableAllowNullable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
//allow value column in settings table to be nullable
Schema::table('settings', function (Blueprint $table) {
$table->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();
});
}
}

View file

@ -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);
});
</script>

View file

@ -88,20 +88,19 @@
<div class="form-group mb-3">
<div class="custom-control p-0">
<label for="discord-client-id">{{ __('ReCaptcha Site-Key') }}:</label>
<input x-model="ReCaptcha-client-id" id="ReCaptcha-client-id" name="ReCaptcha-client-id"
<label for="recaptcha-site-key">{{ __('ReCaptcha Site-Key') }}:</label>
<input x-model="recaptcha-site-key" id="recaptcha-site-key" name="recaptcha-site-key"
type="text" value="{{ config('SETTINGS::RECAPTCHA:SITE_KEY') }}"
class="form-control @error('ReCaptcha-client-id') is-invalid @enderror">
class="form-control @error('recaptcha-site-key') is-invalid @enderror">
</div>
</div>
<div class="form-group mb-3">
<div class="custom-control p-0">
<label for="ReCaptcha-client-secret">{{ __('ReCaptcha Secret-Key') }}:</label>
<input x-model="ReCaptcha-client-secret" id="recaptcha-client-secret"
name="ReCaptcha-client-secret" type="text"
value="{{ config('SETTINGS::RECAPTCHA:SECRET_KEY') }}"
class="form-control @error('ReCaptcha-client-secret') is-invalid @enderror">
<label for="recaptcha-secret-key">{{ __('ReCaptcha Secret-Key') }}:</label>
<input x-model="recaptcha-secret-key" id="recaptcha-secret-key" name="recaptcha-secret-key"
type="text" value="{{ config('SETTINGS::RECAPTCHA:SECRET_KEY') }}"
class="form-control @error('recaptcha-secret-key') is-invalid @enderror">
</div>
</div>
</div>

View file

@ -103,14 +103,14 @@
</div>
<div class="custom-control mb-3 p-0">
<label for="server-limit-discord">{{ __('Server Limit Increase - Discord') }}</label>
<input x-model="server-limit-discord" id="server-limit-discord" name="crserver-limit-discord"
<input x-model="server-limit-discord" id="server-limit-discord" name="server-limit-discord"
type="number"
value="{{ config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD') }}"
class="form-control @error('server-limit-discord') is-invalid @enderror" required>
</div>
<div class="custom-control mb-3 p-0">
<label for="server-limit-email">{{ __('Server Limit Increase - E-Mail') }}</label>
<input x-model="server-limit-email" id="server-limit-email" name="crserver-limit-email"
<input x-model="server-limit-email" id="server-limit-email" name="server-limit-email"
type="number"
value="{{ config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL') }}"
class="form-control @error('server-limit-email') is-invalid @enderror" required>

View file

@ -32,6 +32,7 @@
<noscript>
<link rel="stylesheet" href="{{ asset('plugins/fontawesome-free/css/all.min.css') }}">
</noscript>
<script src="{{ asset('js/app.js') }}"></script>
</head>
<body class="sidebar-mini layout-fixed dark-mode" style="height: auto;">
@ -49,8 +50,8 @@
class="fas fa-home mr-2"></i>{{ __('Home') }}</a>
</li>
<li class="nav-item d-none d-sm-inline-block">
<a href="{{ config('SETTINGS::DISCORD:INVITE_URL') }}" class="nav-link"
target="__blank"><i class="fab fa-discord mr-2"></i>{{ __('Discord') }}</a>
<a href="{{ config('SETTINGS::DISCORD:INVITE_URL') }}" class="nav-link" target="__blank"><i
class="fab fa-discord mr-2"></i>{{ __('Discord') }}</a>
</li>
<!-- Language Selection -->
@if (config('SETTINGS::LOCALE:CLIENTS_CAN_CHANGE') == 'true')
@ -390,7 +391,7 @@
{{-- <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> --}}
{{-- <script src="{{ asset('js/adminlte.min.js') }}"></script> --}}
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10.14.1/dist/sweetalert2.all.min.js"></script>
<script src="{{ asset('js/app.js') }}"></script>
<script type="text/javascript" src="https://cdn.datatables.net/v/bs4/dt-1.10.24/datatables.min.js"></script>
<!-- Summernote -->
<script src="{{ asset('plugins/summernote/summernote-bs4.min.js') }}"></script>
@ -404,17 +405,17 @@
<script src="{{ asset('plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js') }}"></script>
<!-- Select2 -->
<script src={{ asset('plugins/select2/js/select2.min.js') }}>
< script >
$(document).ready(function() {
$('[data-toggle="popover"]').popover();
<script src={{ asset('plugins/select2/js/select2.min.js') }}></script>
<script>
$(document).ready(function() {
$('[data-toggle="popover"]').popover();
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
});
</script>
<script>
@if (Session::has('error'))