fix: 🚑️ Added more improved validation & Fixed Language Settings
This commit is contained in:
parent
4621547c01
commit
7ca6438f35
8 changed files with 83 additions and 27 deletions
|
@ -6,6 +6,8 @@ use App\Models\Settings;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
|
||||
class Language
|
||||
{
|
||||
|
@ -17,6 +19,19 @@ class Language
|
|||
|
||||
public function updateSettings(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'autotranslate' => 'string',
|
||||
'canClientChangeLanguage' => 'boolean',
|
||||
'defaultLanguage' => 'required|string',
|
||||
'languages' => 'required|array',
|
||||
'languages.*' => 'required|string',
|
||||
'datatable-language' => 'required|string',
|
||||
]);
|
||||
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect(route('admin.settings.index') . '#language')->with('error', __('Language settings have not been updated!'))->withErrors($validator);
|
||||
}
|
||||
|
||||
$values = [
|
||||
//SETTINGS::VALUE => REQUEST-VALUE (coming from the html-form)
|
||||
|
@ -31,6 +46,10 @@ class Language
|
|||
foreach ($values as $key => $value) {
|
||||
$param = $request->get($value);
|
||||
|
||||
if (is_array($param)) {
|
||||
$param = implode(",", $param);
|
||||
}
|
||||
|
||||
Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]);
|
||||
Cache::forget("setting" . ':' . $key);
|
||||
Session::remove("locale");
|
||||
|
|
|
@ -6,7 +6,7 @@ use App\Models\Settings;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class Misc
|
||||
{
|
||||
|
@ -19,21 +19,33 @@ class Misc
|
|||
|
||||
public function updateSettings(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
$validator = Validator::make($request->all(), [
|
||||
'icon' => 'nullable|max:10000|mimes:jpg,png,jpeg',
|
||||
'favicon' => 'nullable|max:10000|mimes:ico',
|
||||
'discord-bot-token' => 'nullable|string',
|
||||
'discord-client-id' => 'nullable|string',
|
||||
'discord-client-secret' => 'nullable|string',
|
||||
'discord-guild-id' => 'nullable|string',
|
||||
'discord-invite-url' => 'nullable|string',
|
||||
'discord-role-id' => 'nullable|string',
|
||||
'recaptcha-site-key' => 'nullable|string',
|
||||
'recaptcha-secret-key' => 'nullable|string',
|
||||
'enable-recaptcha' => 'nullable|boolean',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect(route('admin.settings.index') . '#misc')->with('error', __('Misc settings have not been updated!'))->withErrors($validator)
|
||||
->withInput();
|
||||
}
|
||||
|
||||
if ($request->hasFile('icon')) {
|
||||
$request->file('icon')->storeAs('public', 'icon.png');
|
||||
}
|
||||
|
||||
if ($request->hasFile('favicon')) {
|
||||
$request->file('favicon')->storeAs('public', 'favicon.ico');
|
||||
}
|
||||
|
||||
$values = [
|
||||
//SETTINGS::VALUE => REQUEST-VALUE (coming from the html-form)
|
||||
"SETTINGS::DISCORD:BOT_TOKEN" => "discord-bot-token",
|
||||
"SETTINGS::DISCORD:CLIENT_ID" => "discord-client-id",
|
||||
"SETTINGS::DISCORD:CLIENT_SECRET" => "discord-client-secret",
|
||||
|
|
|
@ -5,7 +5,8 @@ namespace App\Classes\Settings;
|
|||
use App\Models\Settings;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
|
||||
class Payments
|
||||
{
|
||||
|
@ -17,6 +18,22 @@ class Payments
|
|||
|
||||
public function updateSettings(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
"paypal-client_id" => "nullable|string",
|
||||
"paypal-client-secret" => "nullable|string",
|
||||
"paypal-sandbox-secret" => "nullable|string",
|
||||
"stripe-secret-key" => "nullable|string",
|
||||
"stripe-endpoint-secret" => "nullable|string",
|
||||
"stripe-test-secret-key" => "nullable|string",
|
||||
"stripe-test-endpoint-secret" => "nullable|string",
|
||||
"stripe-methods" => "nullable|string",
|
||||
"sales-tax" => "nullable|numeric",
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect(route('admin.settings.index') . '#payment')->with('error', __('Payment settings have not been updated!'))->withErrors($validator)
|
||||
->withInput();
|
||||
}
|
||||
|
||||
$values = [
|
||||
//SETTINGS::VALUE => REQUEST-VALUE (coming from the html-form)
|
||||
|
|
|
@ -37,7 +37,7 @@ class System
|
|||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect(route('admin.settings.index') . '#system')->with('error', __('System settings not updated!'))->withErrors($validator)
|
||||
return redirect(route('admin.settings.index') . '#system')->with('error', __('System settings have not been updated!'))->withErrors($validator)
|
||||
->withInput();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,17 +22,16 @@ class SetLocale
|
|||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (Session::has('locale')) {
|
||||
$locale = Session::get('locale', Settings::getValueByKey("SETTINGS::LOCALE:DEFAULT"));
|
||||
$locale = Session::get('locale', config("SETTINGS::LOCALE:DEFAULT"));
|
||||
} else {
|
||||
if (Settings::getValueByKey("SETTINGS::LOCALE:DYNAMIC")!=="true") {
|
||||
$locale = Settings::getValueByKey("SETTINGS::LOCALE:DEFAULT");
|
||||
if (config("SETTINGS::LOCALE:DYNAMIC") !== "true") {
|
||||
$locale = config("SETTINGS::LOCALE:DEFAULT");
|
||||
} else {
|
||||
$locale = substr($request->server('HTTP_ACCEPT_LANGUAGE'), 0, 2);
|
||||
|
||||
if (!in_array($locale, json_decode(Settings::getValueByKey("SETTINGS::LOCALE:AVAILABLE")))) {
|
||||
$locale = Settings::getValueByKey("SETTINGS::LOCALE:DEFAULT");
|
||||
if (!in_array($locale, explode(',', config("SETTINGS::LOCALE:AVAILABLE")))) {
|
||||
$locale = config("SETTINGS::LOCALE:DEFAULT");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
App::setLocale($locale);
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
"User ID": "User-ID",
|
||||
"Server Creation Error": "Fehler beim erstellen des Servers",
|
||||
"Your servers have been suspended!": "Deine Server wurden pausiert",
|
||||
"To automatically re-enable your server\/s, you need to purchase more credits.": "Um deine Server zu reaktivieren, musst du mehr Credits kaufen!",
|
||||
"To automatically re-enable your server/s, you need to purchase more credits.": "Um deine Server zu reaktivieren, musst du mehr Credits kaufen!",
|
||||
"Purchase credits": "Credits kaufen",
|
||||
"If you have any questions please let us know.": "Solltest du weiter fragen haben, melde dich gerne beim Support!",
|
||||
"Regards": "mit freundlichen Grüßen",
|
||||
|
@ -217,7 +217,7 @@
|
|||
"A voucher can only be used one time per user. Uses specifies the number of different users that can use this voucher.": "Ein Gutschein kann von einem User nur einmal eingelöst werden. \"Benutzungen\" setzt die Anzahl an Usern die diesen Gutschein einlösen können.",
|
||||
"Max": "Max",
|
||||
"Expires at": "Läuft ab am",
|
||||
"Used \/ Uses": "Benutzungen",
|
||||
"Used / Uses": "Benutzungen",
|
||||
"Expires": "Ablauf",
|
||||
"Sign in to start your session": "Melde dich an um das Dashboard zu benutzen",
|
||||
"Password": "Passwort",
|
||||
|
@ -287,7 +287,7 @@
|
|||
"No nodes have been linked!": "Es wurde keine Nodes verknüpft",
|
||||
"No nests available!": "Keine Nests verfügbar",
|
||||
"No eggs have been linked!": "Es wurde keine Eggs verknüpft",
|
||||
"Software \/ Games": "Software \/ Spiele",
|
||||
"Software / Games": "Software / Spiele",
|
||||
"Please select software ...": "Bitte Software auswählen",
|
||||
"---": "---",
|
||||
"Specification ": "Spezifikation",
|
||||
|
@ -352,5 +352,12 @@
|
|||
"Please pay until": "Zahlbar bis",
|
||||
"Account already exists on Pterodactyl. Please contact the Support!": "Der Account existiert bereits bei Pterodactyl. Kontaktiere den Support!",
|
||||
"de": "Deutsch",
|
||||
"en": "Englisch"
|
||||
"en": "Englisch",
|
||||
"fr": "Französisch",
|
||||
"cs": "Tschechisch",
|
||||
"es": "Spanisch",
|
||||
"hi": "Hindi",
|
||||
"it": "Italienisch",
|
||||
"pl": "Polnisch",
|
||||
"zh": "Chinesisch"
|
||||
}
|
||||
|
|
|
@ -11,9 +11,12 @@
|
|||
<div class="custom-control mb-3 p-0">
|
||||
<label for="languages">{{ __('Available languages') }}:</label>
|
||||
<select id="languages" style="width:100%" class="custom-select" name="languages[]" required
|
||||
multiple="multiple" autocomplete="off">
|
||||
multiple="multiple" autocomplete="off" @error('defaultLanguage') is-invalid @enderror>
|
||||
|
||||
@foreach (config('app.available_locales') as $lang)
|
||||
<option value="{{ $lang }}">{{ __($lang) }}</option>
|
||||
<option value="{{ $lang }}" @if (str_contains(config('SETTINGS::LOCALE:AVAILABLE'), $lang)) selected @endif>
|
||||
{{ __($lang) }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
@ -28,11 +31,10 @@
|
|||
</label>
|
||||
|
||||
<select id="defaultLanguage" style="width:100%" class="custom-select" name="defaultLanguage"
|
||||
required autocomplete="off">
|
||||
<option value="{{ config('SETTINGS::LOCALE:DEFAULT') }}" selected>
|
||||
{{ __(config('SETTINGS::LOCALE:DEFAULT')) }}</option>
|
||||
required autocomplete="off" @error('defaultLanguage') is-invalid @enderror>
|
||||
@foreach (config('app.available_locales') as $lang)
|
||||
<option value="{{ $lang }}">{{ __($lang) }}</option>
|
||||
<option value="{{ $lang }}" @if (config('SETTINGS::LOCALE:DEFAULT') == $lang) selected
|
||||
@endif>{{ __($lang) }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
@ -40,8 +42,8 @@
|
|||
<div class="custom-control mb-3 p-0">
|
||||
<!--DATATABLE LANGUAGE -->
|
||||
<label for="datatable-language">{{ __('Datable language') }} <i data-toggle="popover"
|
||||
data-trigger="hover"
|
||||
data-content="{{ __('The Language of the Datatables. Grab the Language-Codes from here') }} https://datatables.net/plug-ins/i18n/"
|
||||
data-trigger="hover" data-html="true"
|
||||
data-content="{{ __('The datatables lang-code. <br><strong>Example:</strong> en-gb, fr_fr, de_de<br>More Information: ') }} https://datatables.net/plug-ins/i18n/"
|
||||
class="fas fa-info-circle"></i></label>
|
||||
<input x-model="datatable-language" id="datatable-language" name="datatable-language"
|
||||
type="text" required value="{{ config('SETTINGS::LOCALE:DATATABLES') }}"
|
||||
|
|
|
@ -125,14 +125,14 @@
|
|||
<div class="form-group mb-3">
|
||||
<div class="custom-control p-0">
|
||||
<div class="col m-0 p-0 d-flex justify-content-between align-items-center">
|
||||
<label for="sales_tax">{{ __('Tax Value in %') }}:</label>
|
||||
<label for="sales-tax">{{ __('Tax Value in %') }}:</label>
|
||||
<i data-toggle="popover" data-trigger="hover" data-html="true"
|
||||
data-content="Tax Value that will be added to the total price of the order. <br><br> Example: 19 results in (19%)"
|
||||
class="fas fa-info-circle"></i>
|
||||
</div>
|
||||
<input x-model="sales_tax" id="sales_tax" name="sales_tax" type="number"
|
||||
<input x-model="sales-tax" id="sales-tax" name="sales-tax" type="number"
|
||||
value="{{ config('SETTINGS::PAYMENTS:SALES_TAX') }}"
|
||||
class="form-control @error('sales_tax') is-invalid @enderror">
|
||||
class="form-control @error('sales-tax') is-invalid @enderror">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue