fix: LegacySettingsMigrations (#941)
This commit is contained in:
commit
fa857e8a66
63
app/Classes/LegacySettingsMigration.php
Normal file
63
app/Classes/LegacySettingsMigration.php
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||||
|
|
||||||
|
|
||||||
|
abstract class LegacySettingsMigration extends SettingsMigration
|
||||||
|
{
|
||||||
|
public function getNewValue(string $name, string $group)
|
||||||
|
{
|
||||||
|
$new_value = DB::table('settings')->where([['group', '=', $group], ['name', '=', $name]])->get(['payload'])->first();
|
||||||
|
|
||||||
|
if (is_null($new_value) || is_null($new_value->payload)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some keys returns '""' as a value.
|
||||||
|
if ($new_value->payload === '""') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// remove the quotes from the string
|
||||||
|
if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') {
|
||||||
|
return substr($new_value->payload, 1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $new_value->payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the old value from the settings_old table.
|
||||||
|
* @param string $key The key to get the value from table.
|
||||||
|
* @param int|string|bool|null $default The default value to return if the value is null. If value is not nullable, a default must be provided.
|
||||||
|
*/
|
||||||
|
public function getOldValue(string $key, int|string|bool|null $default = null)
|
||||||
|
{
|
||||||
|
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
||||||
|
|
||||||
|
if (is_null($old_value) || is_null($old_value->value)) {
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($old_value->type) {
|
||||||
|
case 'string':
|
||||||
|
case 'text':
|
||||||
|
// Edgecase: The value is a boolean, but it's stored as a string.
|
||||||
|
if ($old_value->value === "false" || $old_value->value === "true") {
|
||||||
|
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
||||||
|
}
|
||||||
|
return $old_value->value;
|
||||||
|
case 'boolean':
|
||||||
|
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
||||||
|
case 'integer':
|
||||||
|
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
||||||
|
default:
|
||||||
|
throw new Exception("Unknown type: {$old_value->type}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,8 +8,6 @@ use App\Models\Pterodactyl\Nest;
|
||||||
use App\Models\Pterodactyl\Node;
|
use App\Models\Pterodactyl\Node;
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\User;
|
|
||||||
use App\Models\Settings;
|
|
||||||
use App\Notifications\ServerCreationError;
|
use App\Notifications\ServerCreationError;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use App\Settings\UserSettings;
|
use App\Settings\UserSettings;
|
||||||
|
@ -18,7 +16,6 @@ use App\Settings\PterodactylSettings;
|
||||||
use App\Classes\PterodactylClient;
|
use App\Classes\PterodactylClient;
|
||||||
use App\Settings\GeneralSettings;
|
use App\Settings\GeneralSettings;
|
||||||
use Exception;
|
use Exception;
|
||||||
use GuzzleHttp\Promise\Create;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Http\Client\Response;
|
use Illuminate\Http\Client\Response;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use App\Extensions\PaymentGateways\PayPal\PayPalSettings;
|
|
||||||
use App\Models\UsefulLink;
|
use App\Models\UsefulLink;
|
||||||
use App\Settings\GeneralSettings;
|
use App\Settings\GeneralSettings;
|
||||||
use App\Settings\MailSettings;
|
use App\Settings\MailSettings;
|
||||||
|
@ -89,6 +88,8 @@ class AppServiceProvider extends ServiceProvider
|
||||||
Log::error("Couldnt find useful_links. Probably the installation is not completet. " . $e);
|
Log::error("Couldnt find useful_links. Probably the installation is not completet. " . $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
$generalSettings = $this->app->make(GeneralSettings::class);
|
$generalSettings = $this->app->make(GeneralSettings::class);
|
||||||
if (!file_exists(base_path('themes') . "/" . $generalSettings->theme)) {
|
if (!file_exists(base_path('themes') . "/" . $generalSettings->theme)) {
|
||||||
$generalSettings->theme = "default";
|
$generalSettings->theme = "default";
|
||||||
|
@ -100,9 +101,10 @@ class AppServiceProvider extends ServiceProvider
|
||||||
Theme::set("default", "default");
|
Theme::set("default", "default");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$settings = $this->app->make(MailSettings::class);
|
$settings = $this->app->make(MailSettings::class);
|
||||||
$settings->setConfig();
|
$settings->setConfig();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Log::error("Couldnt load Settings. Probably the installation is not completet. " . $e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,6 @@ class DiscordSettings extends Settings
|
||||||
return 'discord';
|
return 'discord';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Summary of validations array
|
* Summary of validations array
|
||||||
* @return array<string, string>
|
* @return array<string, string>
|
||||||
|
|
|
@ -20,7 +20,12 @@ class MailSettings extends Settings
|
||||||
return 'mail';
|
return 'mail';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function encrypted(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'mail_password',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function setConfig()
|
public function setConfig()
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,13 @@ class PterodactylSettings extends Settings
|
||||||
return 'pterodactyl';
|
return 'pterodactyl';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function encrypted(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'admin_token',
|
||||||
|
'user_token',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get url with ensured ending backslash
|
* Get url with ensured ending backslash
|
||||||
|
|
|
@ -26,7 +26,7 @@ class UpdateUserCreditsDatatype extends Migration
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::table('users', function (Blueprint $table) {
|
Schema::table('users', function (Blueprint $table) {
|
||||||
$table->decimal('price', ['11', '2'])->change();
|
$table->decimal('credits', ['11', '2'])->change();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
use App\Classes\LegacySettingsMigration;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class CreateGeneralSettings extends SettingsMigration
|
class CreateGeneralSettings extends LegacySettingsMigration
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -11,15 +11,15 @@ class CreateGeneralSettings extends SettingsMigration
|
||||||
|
|
||||||
// Get the user-set configuration values from the old table.
|
// Get the user-set configuration values from the old table.
|
||||||
$this->migrator->add('general.store_enabled', true);
|
$this->migrator->add('general.store_enabled', true);
|
||||||
$this->migrator->add('general.credits_display_name', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME') : 'Credits');
|
$this->migrator->add('general.credits_display_name', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME', 'Credits') : 'Credits');
|
||||||
$this->migrator->add('general.recaptcha_site_key', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:SITE_KEY") : env('RECAPTCHA_SITE_KEY', '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'));
|
$this->migrator->add('general.recaptcha_site_key', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:SITE_KEY") : env('RECAPTCHA_SITE_KEY', '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'));
|
||||||
$this->migrator->add('general.recaptcha_secret_key', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:SECRET_KEY") : env('RECAPTCHA_SECRET_KEY', '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'));
|
$this->migrator->add('general.recaptcha_secret_key', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:SECRET_KEY") : env('RECAPTCHA_SECRET_KEY', '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'));
|
||||||
$this->migrator->add('general.recaptcha_enabled', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:ENABLED") : true);
|
$this->migrator->add('general.recaptcha_enabled', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:ENABLED", false) : false);
|
||||||
$this->migrator->add('general.phpmyadmin_url', $table_exists ? $this->getOldValue("SETTINGS::MISC:PHPMYADMIN:URL") : env('PHPMYADMIN_URL', ''));
|
$this->migrator->add('general.phpmyadmin_url', $table_exists ? $this->getOldValue("SETTINGS::MISC:PHPMYADMIN:URL") : env('PHPMYADMIN_URL'));
|
||||||
$this->migrator->add('general.alert_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:ALERT_ENABLED") : false);
|
$this->migrator->add('general.alert_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:ALERT_ENABLED", false) : false);
|
||||||
$this->migrator->add('general.alert_type', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:ALERT_TYPE") : 'dark');
|
$this->migrator->add('general.alert_type', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:ALERT_TYPE", 'dark') : 'dark');
|
||||||
$this->migrator->add('general.alert_message', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:ALERT_MESSAGE") : '');
|
$this->migrator->add('general.alert_message', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:ALERT_MESSAGE") : null);
|
||||||
$this->migrator->add('general.theme', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:THEME") : 'default');
|
$this->migrator->add('general.theme', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:THEME", 'default') : 'default');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(): void
|
public function down(): void
|
||||||
|
@ -27,61 +27,61 @@ class CreateGeneralSettings extends SettingsMigration
|
||||||
DB::table('settings_old')->insert([
|
DB::table('settings_old')->insert([
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME',
|
'key' => 'SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME',
|
||||||
'value' => $this->getNewValue('credits_display_name'),
|
'value' => $this->getNewValue('credits_display_name', 'general'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The name of the credits on the panel.'
|
'description' => 'The name of the credits on the panel.'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:ALERT_ENABLED',
|
'key' => 'SETTINGS::SYSTEM:ALERT_ENABLED',
|
||||||
'value' => $this->getNewValue('alert_enabled'),
|
'value' => $this->getNewValue('alert_enabled', 'general'),
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'Enable the alert at the top of the panel.'
|
'description' => 'Enable the alert at the top of the panel.'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:ALERT_TYPE',
|
'key' => 'SETTINGS::SYSTEM:ALERT_TYPE',
|
||||||
'value' => $this->getNewValue('alert_type'),
|
'value' => $this->getNewValue('alert_type', 'general'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The type of alert to display.'
|
'description' => 'The type of alert to display.'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:ALERT_MESSAGE',
|
'key' => 'SETTINGS::SYSTEM:ALERT_MESSAGE',
|
||||||
'value' => $this->getNewValue('alert_message'),
|
'value' => $this->getNewValue('alert_message', 'general'),
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'description' => 'The message to display in the alert.'
|
'description' => 'The message to display in the alert.'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:THEME',
|
'key' => 'SETTINGS::SYSTEM:THEME',
|
||||||
'value' => $this->getNewValue('theme'),
|
'value' => $this->getNewValue('theme', 'general'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The theme to use for the panel.'
|
'description' => 'The theme to use for the panel.'
|
||||||
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::RECAPTCHA:SITE_KEY',
|
'key' => 'SETTINGS::RECAPTCHA:SITE_KEY',
|
||||||
'value' => $this->getNewValue('recaptcha_site_key'),
|
'value' => $this->getNewValue('recaptcha_site_key', 'general'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The site key for reCAPTCHA.'
|
'description' => 'The site key for reCAPTCHA.'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::RECAPTCHA:SECRET_KEY',
|
'key' => 'SETTINGS::RECAPTCHA:SECRET_KEY',
|
||||||
'value' => $this->getNewValue('recaptcha_secret_key'),
|
'value' => $this->getNewValue('recaptcha_secret_key', 'general'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The secret key for reCAPTCHA.'
|
'description' => 'The secret key for reCAPTCHA.'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::RECAPTCHA:ENABLED',
|
'key' => 'SETTINGS::RECAPTCHA:ENABLED',
|
||||||
'value' => $this->getNewValue('recaptcha_enabled'),
|
'value' => $this->getNewValue('recaptcha_enabled', 'general'),
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'Enable reCAPTCHA on the panel.'
|
'description' => 'Enable reCAPTCHA on the panel.'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::MISC:PHPMYADMIN:URL',
|
'key' => 'SETTINGS::MISC:PHPMYADMIN:URL',
|
||||||
'value' => $this->getNewValue('phpmyadmin_url'),
|
'value' => $this->getNewValue('phpmyadmin_url', 'general'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The URL to your phpMyAdmin installation.'
|
'description' => 'The URL to your phpMyAdmin installation.'
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
try {
|
||||||
$this->migrator->delete('general.store_enabled');
|
$this->migrator->delete('general.store_enabled');
|
||||||
$this->migrator->delete('general.credits_display_name');
|
$this->migrator->delete('general.credits_display_name');
|
||||||
$this->migrator->delete('general.recaptcha_site_key');
|
$this->migrator->delete('general.recaptcha_site_key');
|
||||||
|
@ -92,48 +92,8 @@ class CreateGeneralSettings extends SettingsMigration
|
||||||
$this->migrator->delete('general.alert_type');
|
$this->migrator->delete('general.alert_type');
|
||||||
$this->migrator->delete('general.alert_message');
|
$this->migrator->delete('general.alert_message');
|
||||||
$this->migrator->delete('general.theme');
|
$this->migrator->delete('general.theme');
|
||||||
}
|
} catch (Exception $e) {
|
||||||
|
// Do nothing
|
||||||
public function getNewValue(string $name)
|
}
|
||||||
{
|
|
||||||
$new_value = DB::table('settings')->where([['group', '=', 'general'], ['name', '=', $name]])->get(['payload'])->first();
|
|
||||||
|
|
||||||
// Some keys returns '""' as a value.
|
|
||||||
if ($new_value->payload === '""') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove the quotes from the string
|
|
||||||
if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') {
|
|
||||||
return substr($new_value->payload, 1, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $new_value->payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOldValue(string $key)
|
|
||||||
{
|
|
||||||
// Always get the first value of the key.
|
|
||||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
|
||||||
|
|
||||||
// Handle the old values to return without it being a string in all cases.
|
|
||||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
|
||||||
if (is_null($old_value->value)) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Some values have the type string, but their values are boolean.
|
|
||||||
if ($old_value->value === "false" || $old_value->value === "true") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $old_value->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($old_value->type === "boolean") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
use App\Classes\LegacySettingsMigration;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class CreatePterodactylSettings extends SettingsMigration
|
class CreatePterodactylSettings extends LegacySettingsMigration
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
$table_exists = DB::table('settings_old')->exists();
|
$table_exists = DB::table('settings_old')->exists();
|
||||||
|
|
||||||
// Get the user-set configuration values from the old table.
|
$this->migrator->addEncrypted('pterodactyl.admin_token', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:TOKEN', '') : env('PTERODACTYL_TOKEN', ''));
|
||||||
//$this->migrator->addEncrypted('pterodactyl.admin_token', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:TOKEN') : env('PTERODACTYL_TOKEN', ''));
|
$this->migrator->addEncrypted('pterodactyl.user_token', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN', '') : '');
|
||||||
//$this->migrator->addEncrypted('pterodactyl.user_token', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN') : '');
|
$this->migrator->add('pterodactyl.panel_url', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:URL', '') : env('PTERODACTYL_URL', ''));
|
||||||
$this->migrator->add('pterodactyl.admin_token', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:TOKEN') : env('PTERODACTYL_TOKEN', ''));
|
$this->migrator->add('pterodactyl.per_page_limit', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT', 200) : 200);
|
||||||
$this->migrator->add('pterodactyl.user_token', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN') : '');
|
|
||||||
$this->migrator->add('pterodactyl.panel_url', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:URL') : env('PTERODACTYL_URL', ''));
|
|
||||||
$this->migrator->add('pterodactyl.per_page_limit', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT') : 200);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(): void
|
public function down(): void
|
||||||
|
@ -25,76 +22,37 @@ class CreatePterodactylSettings extends SettingsMigration
|
||||||
DB::table('settings_old')->insert([
|
DB::table('settings_old')->insert([
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:PTERODACTYL:TOKEN',
|
'key' => 'SETTINGS::SYSTEM:PTERODACTYL:TOKEN',
|
||||||
'value' => $this->getNewValue('admin_token'),
|
'value' => $this->getNewValue('admin_token', 'pterodactyl'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The admin token for the Pterodactyl panel.',
|
'description' => 'The admin token for the Pterodactyl panel.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN',
|
'key' => 'SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN',
|
||||||
'value' => $this->getNewValue('user_token'),
|
'value' => $this->getNewValue('user_token', 'pterodactyl'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The user token for the Pterodactyl panel.',
|
'description' => 'The user token for the Pterodactyl panel.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:PTERODACTYL:URL',
|
'key' => 'SETTINGS::SYSTEM:PTERODACTYL:URL',
|
||||||
'value' => $this->getNewValue('panel_url'),
|
'value' => $this->getNewValue('panel_url', 'pterodactyl'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The URL for the Pterodactyl panel.',
|
'description' => 'The URL for the Pterodactyl panel.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT',
|
'key' => 'SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT',
|
||||||
'value' => $this->getNewValue('per_page_limit'),
|
'value' => $this->getNewValue('per_page_limit', 'pterodactyl'),
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'description' => 'The number of servers to show per page.',
|
'description' => 'The number of servers to show per page.',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
$this->migrator->delete('pterodactyl.admin_token');
|
$this->migrator->delete('pterodactyl.admin_token');
|
||||||
$this->migrator->delete('pterodactyl.user_token');
|
$this->migrator->delete('pterodactyl.user_token');
|
||||||
$this->migrator->delete('pterodactyl.panel_url');
|
$this->migrator->delete('pterodactyl.panel_url');
|
||||||
$this->migrator->delete('pterodactyl.per_page_limit');
|
$this->migrator->delete('pterodactyl.per_page_limit');
|
||||||
}
|
} catch (Exception $e) {
|
||||||
|
echo 'Caught exception: ', $e->getMessage(), "\n";
|
||||||
public function getNewValue(string $name)
|
}
|
||||||
{
|
|
||||||
$new_value = DB::table('settings')->where([['group', '=', 'pterodactyl'], ['name', '=', $name]])->get(['payload'])->first();
|
|
||||||
|
|
||||||
// Some keys returns '""' as a value.
|
|
||||||
if ($new_value->payload === '""') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove the quotes from the string
|
|
||||||
if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') {
|
|
||||||
return substr($new_value->payload, 1, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $new_value->payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOldValue(string $key)
|
|
||||||
{
|
|
||||||
// Always get the first value of the key.
|
|
||||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
|
||||||
|
|
||||||
// Handle the old values to return without it being a string in all cases.
|
|
||||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
|
||||||
if (is_null($old_value->value)) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Some values have the type string, but their values are boolean.
|
|
||||||
if ($old_value->value === "false" || $old_value->value === "true") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $old_value->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($old_value->type === "boolean") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
use App\Classes\LegacySettingsMigration;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class CreateMailSettings extends SettingsMigration
|
class CreateMailSettings extends LegacySettingsMigration
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -25,55 +25,56 @@ class CreateMailSettings extends SettingsMigration
|
||||||
DB::table('settings_old')->insert([
|
DB::table('settings_old')->insert([
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::MAIL:HOST',
|
'key' => 'SETTINGS::MAIL:HOST',
|
||||||
'value' => $this->getNewValue('mail_host'),
|
'value' => $this->getNewValue('mail_host', 'mail'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The host of the mail server.',
|
'description' => 'The host of the mail server.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::MAIL:PORT',
|
'key' => 'SETTINGS::MAIL:PORT',
|
||||||
'value' => $this->getNewValue('mail_port'),
|
'value' => $this->getNewValue('mail_port', 'mail'),
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'description' => 'The port of the mail server.',
|
'description' => 'The port of the mail server.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::MAIL:USERNAME',
|
'key' => 'SETTINGS::MAIL:USERNAME',
|
||||||
'value' => $this->getNewValue('mail_username'),
|
'value' => $this->getNewValue('mail_username', 'mail'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The username of the mail server.',
|
'description' => 'The username of the mail server.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::MAIL:PASSWORD',
|
'key' => 'SETTINGS::MAIL:PASSWORD',
|
||||||
'value' => $this->getNewValue('mail_password'),
|
'value' => $this->getNewValue('mail_password', 'mail'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The password of the mail server.',
|
'description' => 'The password of the mail server.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::MAIL:ENCRYPTION',
|
'key' => 'SETTINGS::MAIL:ENCRYPTION',
|
||||||
'value' => $this->getNewValue('mail_encryption'),
|
'value' => $this->getNewValue('mail_encryption', 'mail'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The encryption of the mail server.',
|
'description' => 'The encryption of the mail server.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::MAIL:FROM_ADDRESS',
|
'key' => 'SETTINGS::MAIL:FROM_ADDRESS',
|
||||||
'value' => $this->getNewValue('mail_from_address'),
|
'value' => $this->getNewValue('mail_from_address', 'mail'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The from address of the mail server.',
|
'description' => 'The from address of the mail server.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::MAIL:FROM_NAME',
|
'key' => 'SETTINGS::MAIL:FROM_NAME',
|
||||||
'value' => $this->getNewValue('mail_from_name'),
|
'value' => $this->getNewValue('mail_from_name', 'mail'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The from name of the mail server.',
|
'description' => 'The from name of the mail server.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::MAIL:MAILER',
|
'key' => 'SETTINGS::MAIL:MAILER',
|
||||||
'value' => $this->getNewValue('mail_mailer'),
|
'value' => $this->getNewValue('mail_mailer', 'mail'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The mailer of the mail server.',
|
'description' => 'The mailer of the mail server.',
|
||||||
],
|
],
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
$this->migrator->delete('mail.mail_host');
|
$this->migrator->delete('mail.mail_host');
|
||||||
$this->migrator->delete('mail.mail_port');
|
$this->migrator->delete('mail.mail_port');
|
||||||
$this->migrator->delete('mail.mail_username');
|
$this->migrator->delete('mail.mail_username');
|
||||||
|
@ -82,48 +83,8 @@ class CreateMailSettings extends SettingsMigration
|
||||||
$this->migrator->delete('mail.mail_from_address');
|
$this->migrator->delete('mail.mail_from_address');
|
||||||
$this->migrator->delete('mail.mail_from_name');
|
$this->migrator->delete('mail.mail_from_name');
|
||||||
$this->migrator->delete('mail.mail_mailer');
|
$this->migrator->delete('mail.mail_mailer');
|
||||||
}
|
} catch (Exception $e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
public function getNewValue(string $name)
|
|
||||||
{
|
|
||||||
$new_value = DB::table('settings')->where([['group', '=', 'mail'], ['name', '=', $name]])->get(['payload'])->first();
|
|
||||||
|
|
||||||
// Some keys returns '""' as a value.
|
|
||||||
if ($new_value->payload === '""') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove the quotes from the string
|
|
||||||
if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') {
|
|
||||||
return substr($new_value->payload, 1, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $new_value->payload;
|
|
||||||
}
|
|
||||||
public function getOldValue(string $key)
|
|
||||||
{
|
|
||||||
// Always get the first value of the key.
|
|
||||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
|
||||||
|
|
||||||
// Handle the old values to return without it being a string in all cases.
|
|
||||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
|
||||||
if (is_null($old_value->value)) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Some values have the type string, but their values are boolean.
|
|
||||||
if ($old_value->value === "false" || $old_value->value === "true") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $old_value->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($old_value->type === "boolean") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
use App\Classes\LegacySettingsMigration;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class CreateUserSettings extends SettingsMigration
|
class CreateUserSettings extends LegacySettingsMigration
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
$table_exists = DB::table('settings_old')->exists();
|
$table_exists = DB::table('settings_old')->exists();
|
||||||
|
|
||||||
// Get the user-set configuration values from the old table.
|
// Get the user-set configuration values from the old table.
|
||||||
$this->migrator->add('user.credits_reward_after_verify_discord', $table_exists ? $this->getOldValue('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD') : 250);
|
$this->migrator->add('user.credits_reward_after_verify_discord', $table_exists ? $this->getOldValue('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD', 250) : 250);
|
||||||
$this->migrator->add('user.credits_reward_after_verify_email', $table_exists ? $this->getOldValue('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL') : 250);
|
$this->migrator->add('user.credits_reward_after_verify_email', $table_exists ? $this->getOldValue('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL', 250) : 250);
|
||||||
$this->migrator->add('user.force_discord_verification', $table_exists ? $this->getOldValue('SETTINGS::USER:FORCE_DISCORD_VERIFICATION') : false);
|
$this->migrator->add('user.force_discord_verification', $table_exists ? $this->getOldValue('SETTINGS::USER:FORCE_DISCORD_VERIFICATION', false) : false);
|
||||||
$this->migrator->add('user.force_email_verification', $table_exists ? $this->getOldValue('SETTINGS::USER:FORCE_EMAIL_VERIFICATION') : false);
|
$this->migrator->add('user.force_email_verification', $table_exists ? $this->getOldValue('SETTINGS::USER:FORCE_EMAIL_VERIFICATION', false) : false);
|
||||||
$this->migrator->add('user.initial_credits', $table_exists ? $this->getOldValue('SETTINGS::USER:INITIAL_CREDITS') : 250);
|
$this->migrator->add('user.initial_credits', $table_exists ? $this->getOldValue('SETTINGS::USER:INITIAL_CREDITS', 250) : 250);
|
||||||
$this->migrator->add('user.initial_server_limit', $table_exists ? $this->getOldValue('SETTINGS::USER:INITIAL_SERVER_LIMIT') : 1);
|
$this->migrator->add('user.initial_server_limit', $table_exists ? $this->getOldValue('SETTINGS::USER:INITIAL_SERVER_LIMIT', 1) : 1);
|
||||||
$this->migrator->add('user.min_credits_to_make_server', $table_exists ? $this->getOldValue('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER') : 50);
|
$this->migrator->add('user.min_credits_to_make_server', $table_exists ? $this->getOldValue('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', 50) : 50);
|
||||||
$this->migrator->add('user.server_limit_after_irl_purchase', $table_exists ? $this->getOldValue('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') : 10);
|
$this->migrator->add('user.server_limit_after_irl_purchase', $table_exists ? $this->getOldValue('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE', 10) : 10);
|
||||||
$this->migrator->add('user.server_limit_after_verify_discord', $table_exists ? $this->getOldValue('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD') : 2);
|
$this->migrator->add('user.server_limit_after_verify_discord', $table_exists ? $this->getOldValue('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD', 2) : 2);
|
||||||
$this->migrator->add('user.server_limit_after_verify_email', $table_exists ? $this->getOldValue('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL') : 2);
|
$this->migrator->add('user.server_limit_after_verify_email', $table_exists ? $this->getOldValue('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL', 2) : 2);
|
||||||
$this->migrator->add('user.register_ip_check', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:REGISTER_IP_CHECK") : true);
|
$this->migrator->add('user.register_ip_check', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:REGISTER_IP_CHECK", true) : true);
|
||||||
$this->migrator->add('user.creation_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:CREATION_OF_NEW_USERS") : true);
|
$this->migrator->add('user.creation_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:CREATION_OF_NEW_USERS", true) : true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(): void
|
public function down(): void
|
||||||
|
@ -29,81 +29,82 @@ class CreateUserSettings extends SettingsMigration
|
||||||
DB::table('settings_old')->insert([
|
DB::table('settings_old')->insert([
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD',
|
'key' => 'SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD',
|
||||||
'value' => $this->getNewValue('credits_reward_after_verify_discord'),
|
'value' => $this->getNewValue('credits_reward_after_verify_discord', 'user'),
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'description' => 'The amount of credits that the user will receive after verifying their Discord account.',
|
'description' => 'The amount of credits that the user will receive after verifying their Discord account.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL',
|
'key' => 'SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL',
|
||||||
'value' => $this->getNewValue('credits_reward_after_verify_email'),
|
'value' => $this->getNewValue('credits_reward_after_verify_email', 'user'),
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'description' => 'The amount of credits that the user will receive after verifying their email.',
|
'description' => 'The amount of credits that the user will receive after verifying their email.',
|
||||||
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::USER:FORCE_DISCORD_VERIFICATION',
|
'key' => 'SETTINGS::USER:FORCE_DISCORD_VERIFICATION',
|
||||||
'value' => $this->getNewValue('force_discord_verification'),
|
'value' => $this->getNewValue('force_discord_verification', 'user'),
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'If the user must verify their Discord account to use the panel.',
|
'description' => 'If the user must verify their Discord account to use the panel.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::USER:FORCE_EMAIL_VERIFICATION',
|
'key' => 'SETTINGS::USER:FORCE_EMAIL_VERIFICATION',
|
||||||
'value' => $this->getNewValue('force_email_verification'),
|
'value' => $this->getNewValue('force_email_verification', 'user'),
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'If the user must verify their email to use the panel.',
|
'description' => 'If the user must verify their email to use the panel.',
|
||||||
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::USER:INITIAL_CREDITS',
|
'key' => 'SETTINGS::USER:INITIAL_CREDITS',
|
||||||
'value' => $this->getNewValue('initial_credits'),
|
'value' => $this->getNewValue('initial_credits', 'user'),
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'description' => 'The amount of credits that the user will receive when they register.',
|
'description' => 'The amount of credits that the user will receive when they register.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::USER:INITIAL_SERVER_LIMIT',
|
'key' => 'SETTINGS::USER:INITIAL_SERVER_LIMIT',
|
||||||
'value' => $this->getNewValue('initial_server_limit'),
|
'value' => $this->getNewValue('initial_server_limit', 'user'),
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'description' => 'The amount of servers that the user will be able to create when they register.',
|
'description' => 'The amount of servers that the user will be able to create when they register.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER',
|
'key' => 'SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER',
|
||||||
'value' => $this->getNewValue('min_credits_to_make_server'),
|
'value' => $this->getNewValue('min_credits_to_make_server', 'user'),
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'description' => 'The minimum amount of credits that the user must have to create a server.',
|
'description' => 'The minimum amount of credits that the user must have to create a server.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE',
|
'key' => 'SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE',
|
||||||
'value' => $this->getNewValue('server_limit_after_irl_purchase'),
|
'value' => $this->getNewValue('server_limit_after_irl_purchase', 'user'),
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'description' => 'The amount of servers that the user will be able to create after making a real purchase.',
|
'description' => 'The amount of servers that the user will be able to create after making a real purchase.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD',
|
'key' => 'SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD',
|
||||||
'value' => $this->getNewValue('server_limit_after_verify_discord'),
|
'value' => $this->getNewValue('server_limit_after_verify_discord', 'user'),
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'description' => 'The amount of servers that the user will be able to create after verifying their Discord account.',
|
'description' => 'The amount of servers that the user will be able to create after verifying their Discord account.',
|
||||||
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL',
|
'key' => 'SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL',
|
||||||
'value' => $this->getNewValue('server_limit_after_verify_email'),
|
'value' => $this->getNewValue('server_limit_after_verify_email', 'user'),
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'description' => 'The amount of servers that the user will be able to create after verifying their email.',
|
'description' => 'The amount of servers that the user will be able to create after verifying their email.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:REGISTER_IP_CHECK',
|
'key' => 'SETTINGS::SYSTEM:REGISTER_IP_CHECK',
|
||||||
'value' => $this->getNewValue('register_ip_check'),
|
'value' => $this->getNewValue('register_ip_check', 'user'),
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'If the user must verify their IP address to register.',
|
'description' => 'If the user must verify their IP address to register.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:CREATION_OF_NEW_USERS',
|
'key' => 'SETTINGS::SYSTEM:CREATION_OF_NEW_USERS',
|
||||||
'value' => $this->getNewValue('creation_enabled'),
|
'value' => $this->getNewValue('creation_enabled', 'user'),
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'If the user can register.',
|
'description' => 'If the user can register.',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
$this->migrator->delete('user.credits_reward_after_verify_discord');
|
$this->migrator->delete('user.credits_reward_after_verify_discord');
|
||||||
$this->migrator->delete('user.credits_reward_after_verify_email');
|
$this->migrator->delete('user.credits_reward_after_verify_email');
|
||||||
$this->migrator->delete('user.force_discord_verification');
|
$this->migrator->delete('user.force_discord_verification');
|
||||||
|
@ -116,48 +117,8 @@ class CreateUserSettings extends SettingsMigration
|
||||||
$this->migrator->delete('user.server_limit_after_verify_email');
|
$this->migrator->delete('user.server_limit_after_verify_email');
|
||||||
$this->migrator->delete('user.register_ip_check');
|
$this->migrator->delete('user.register_ip_check');
|
||||||
$this->migrator->delete('user.creation_enabled');
|
$this->migrator->delete('user.creation_enabled');
|
||||||
}
|
} catch (Exception $e) {
|
||||||
|
// Do nothing
|
||||||
public function getNewValue(string $name)
|
}
|
||||||
{
|
|
||||||
$new_value = DB::table('settings')->where([['group', '=', 'user'], ['name', '=', $name]])->get(['payload'])->first();
|
|
||||||
|
|
||||||
// Some keys returns '""' as a value.
|
|
||||||
if ($new_value->payload === '""') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove the quotes from the string
|
|
||||||
if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') {
|
|
||||||
return substr($new_value->payload, 1, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $new_value->payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOldValue(string $key)
|
|
||||||
{
|
|
||||||
// Always get the first value of the key.
|
|
||||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
|
||||||
|
|
||||||
// Handle the old values to return without it being a string in all cases.
|
|
||||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
|
||||||
if (is_null($old_value->value)) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Some values have the type string, but their values are boolean.
|
|
||||||
if ($old_value->value === "false" || $old_value->value === "true") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $old_value->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($old_value->type === "boolean") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
use App\Classes\LegacySettingsMigration;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class CreateServerSettings extends SettingsMigration
|
class CreateServerSettings extends LegacySettingsMigration
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
$table_exists = DB::table('settings_old')->exists();
|
$table_exists = DB::table('settings_old')->exists();
|
||||||
|
|
||||||
// Get the user-set configuration values from the old table.
|
// Get the user-set configuration values from the old table.
|
||||||
$this->migrator->add('server.allocation_limit', $table_exists ? $this->getOldValue('SETTINGS::SERVER:ALLOCATION_LIMIT') : 200);
|
$this->migrator->add('server.allocation_limit', $table_exists ? $this->getOldValue('SETTINGS::SERVER:ALLOCATION_LIMIT', 200) : 200);
|
||||||
$this->migrator->add('server.creation_enabled', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS') : true);
|
$this->migrator->add('server.creation_enabled', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS', true) : true);
|
||||||
$this->migrator->add('server.enable_upgrade', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:ENABLE_UPGRADE') : false);
|
$this->migrator->add('server.enable_upgrade', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:ENABLE_UPGRADE', false) : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(): void
|
public function down(): void
|
||||||
|
@ -20,69 +20,30 @@ class CreateServerSettings extends SettingsMigration
|
||||||
DB::table('settings_old')->insert([
|
DB::table('settings_old')->insert([
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SERVER:ALLOCATION_LIMIT',
|
'key' => 'SETTINGS::SERVER:ALLOCATION_LIMIT',
|
||||||
'value' => $this->getNewValue('allocation_limit'),
|
'value' => $this->getNewValue('allocation_limit', 'server'),
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'description' => 'The number of servers to show per page.',
|
'description' => 'The number of servers to show per page.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS',
|
'key' => 'SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS',
|
||||||
'value' => $this->getNewValue('creation_enabled'),
|
'value' => $this->getNewValue('creation_enabled', 'server'),
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'Whether or not users can create new servers.',
|
'description' => 'Whether or not users can create new servers.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:ENABLE_UPGRADE',
|
'key' => 'SETTINGS::SYSTEM:ENABLE_UPGRADE',
|
||||||
'value' => $this->getNewValue('enable_upgrade'),
|
'value' => $this->getNewValue('enable_upgrade', 'server'),
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'Whether or not users can upgrade their servers.',
|
'description' => 'Whether or not users can upgrade their servers.',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
$this->migrator->delete('server.allocation_limit');
|
$this->migrator->delete('server.allocation_limit');
|
||||||
$this->migrator->delete('server.creation_enabled');
|
$this->migrator->delete('server.creation_enabled');
|
||||||
$this->migrator->delete('server.enable_upgrade');
|
$this->migrator->delete('server.enable_upgrade');
|
||||||
}
|
} catch (Exception $e) {
|
||||||
|
// Do nothing
|
||||||
public function getNewValue(string $name)
|
}
|
||||||
{
|
|
||||||
$new_value = DB::table('settings')->where([['group', '=', 'server'], ['name', '=', $name]])->get(['payload'])->first();
|
|
||||||
|
|
||||||
// Some keys returns '""' as a value.
|
|
||||||
if ($new_value->payload === '""') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove the quotes from the string
|
|
||||||
if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') {
|
|
||||||
return substr($new_value->payload, 1, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $new_value->payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOldValue(string $key)
|
|
||||||
{
|
|
||||||
// Always get the first value of the key.
|
|
||||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
|
||||||
|
|
||||||
// Handle the old values to return without it being a string in all cases.
|
|
||||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
|
||||||
if (is_null($old_value->value)) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Some values have the type string, but their values are boolean.
|
|
||||||
if ($old_value->value === "false" || $old_value->value === "true") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $old_value->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($old_value->type === "boolean") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
use App\Classes\LegacySettingsMigration;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class CreateInvoiceSettings extends SettingsMigration
|
class CreateInvoiceSettings extends LegacySettingsMigration
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
$table_exists = DB::table('settings_old')->exists();
|
$table_exists = DB::table('settings_old')->exists();
|
||||||
|
|
||||||
// Get the user-set configuration values from the old table.
|
// Get the user-set configuration values from the old table.
|
||||||
$this->migrator->add('invoice.company_address', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_ADDRESS') : '');
|
$this->migrator->add('invoice.company_address', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_ADDRESS') : null);
|
||||||
$this->migrator->add('invoice.company_mail', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_MAIL') : '');
|
$this->migrator->add('invoice.company_mail', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_MAIL') : null);
|
||||||
$this->migrator->add('invoice.company_name', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_NAME') : '');
|
$this->migrator->add('invoice.company_name', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_NAME') : null);
|
||||||
$this->migrator->add('invoice.company_phone', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_PHONE') : '');
|
$this->migrator->add('invoice.company_phone', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_PHONE') : null);
|
||||||
$this->migrator->add('invoice.company_vat', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_VAT') : '');
|
$this->migrator->add('invoice.company_vat', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_VAT') : null);
|
||||||
$this->migrator->add('invoice.company_website', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_WEBSITE') : '');
|
$this->migrator->add('invoice.company_website', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_WEBSITE') : null);
|
||||||
$this->migrator->add('invoice.enabled', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:ENABLED') : false);
|
$this->migrator->add('invoice.enabled', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:ENABLED', false) : false);
|
||||||
$this->migrator->add('invoice.prefix', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:PREFIX') : 'INV');
|
$this->migrator->add('invoice.prefix', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:PREFIX') : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(): void
|
public function down(): void
|
||||||
|
@ -25,54 +25,55 @@ class CreateInvoiceSettings extends SettingsMigration
|
||||||
DB::table('settings_old')->insert([
|
DB::table('settings_old')->insert([
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::INVOICE:COMPANY_ADDRESS',
|
'key' => 'SETTINGS::INVOICE:COMPANY_ADDRESS',
|
||||||
'value' => $this->getNewValue('company_address'),
|
'value' => $this->getNewValue('company_address', 'invoice'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The address of the company.',
|
'description' => 'The address of the company.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::INVOICE:COMPANY_MAIL',
|
'key' => 'SETTINGS::INVOICE:COMPANY_MAIL',
|
||||||
'value' => $this->getNewValue('company_mail'),
|
'value' => $this->getNewValue('company_mail', 'invoice'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The email address of the company.',
|
'description' => 'The email address of the company.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::INVOICE:COMPANY_NAME',
|
'key' => 'SETTINGS::INVOICE:COMPANY_NAME',
|
||||||
'value' => $this->getNewValue('company_name'),
|
'value' => $this->getNewValue('company_name', 'invoice'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The name of the company.',
|
'description' => 'The name of the company.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::INVOICE:COMPANY_PHONE',
|
'key' => 'SETTINGS::INVOICE:COMPANY_PHONE',
|
||||||
'value' => $this->getNewValue('company_phone'),
|
'value' => $this->getNewValue('company_phone', 'invoice'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The phone number of the company.',
|
'description' => 'The phone number of the company.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::INVOICE:COMPANY_VAT',
|
'key' => 'SETTINGS::INVOICE:COMPANY_VAT',
|
||||||
'value' => $this->getNewValue('company_vat'),
|
'value' => $this->getNewValue('company_vat', 'invoice'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The VAT number of the company.',
|
'description' => 'The VAT number of the company.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::INVOICE:COMPANY_WEBSITE',
|
'key' => 'SETTINGS::INVOICE:COMPANY_WEBSITE',
|
||||||
'value' => $this->getNewValue('company_website'),
|
'value' => $this->getNewValue('company_website', 'invoice'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The website of the company.',
|
'description' => 'The website of the company.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::INVOICE:ENABLED',
|
'key' => 'SETTINGS::INVOICE:ENABLED',
|
||||||
'value' => $this->getNewValue('enabled'),
|
'value' => $this->getNewValue('enabled', 'invoice'),
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'Enable or disable the invoice system.',
|
'description' => 'Enable or disable the invoice system.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::INVOICE:PREFIX',
|
'key' => 'SETTINGS::INVOICE:PREFIX',
|
||||||
'value' => $this->getNewValue('prefix'),
|
'value' => $this->getNewValue('prefix', 'invoice'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The prefix of the invoice.',
|
'description' => 'The prefix of the invoice.',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
$this->migrator->delete('invoice.company_address');
|
$this->migrator->delete('invoice.company_address');
|
||||||
$this->migrator->delete('invoice.company_mail');
|
$this->migrator->delete('invoice.company_mail');
|
||||||
$this->migrator->delete('invoice.company_name');
|
$this->migrator->delete('invoice.company_name');
|
||||||
|
@ -81,48 +82,8 @@ class CreateInvoiceSettings extends SettingsMigration
|
||||||
$this->migrator->delete('invoice.company_website');
|
$this->migrator->delete('invoice.company_website');
|
||||||
$this->migrator->delete('invoice.enabled');
|
$this->migrator->delete('invoice.enabled');
|
||||||
$this->migrator->delete('invoice.prefix');
|
$this->migrator->delete('invoice.prefix');
|
||||||
}
|
} catch (Exception $e) {
|
||||||
|
// Do nothing
|
||||||
public function getNewValue(string $name)
|
}
|
||||||
{
|
|
||||||
$new_value = DB::table('settings')->where([['group', '=', 'invoice'], ['name', '=', $name]])->get(['payload'])->first();
|
|
||||||
|
|
||||||
// Some keys returns '""' as a value.
|
|
||||||
if ($new_value->payload === '""') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove the quotes from the string
|
|
||||||
if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') {
|
|
||||||
return substr($new_value->payload, 1, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $new_value->payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOldValue(string $key)
|
|
||||||
{
|
|
||||||
// Always get the first value of the key.
|
|
||||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
|
||||||
|
|
||||||
// Handle the old values to return without it being a string in all cases.
|
|
||||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
|
||||||
if (is_null($old_value->value)) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Some values have the type string, but their values are boolean.
|
|
||||||
if ($old_value->value === "false" || $old_value->value === "true") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $old_value->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($old_value->type === "boolean") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
use App\Classes\LegacySettingsMigration;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class CreateDiscordSettings extends SettingsMigration
|
class CreateDiscordSettings extends LegacySettingsMigration
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
$table_exists = DB::table('settings_old')->exists();
|
$table_exists = DB::table('settings_old')->exists();
|
||||||
|
|
||||||
// Get the user-set configuration values from the old table.
|
// Get the user-set configuration values from the old table.
|
||||||
$this->migrator->add('discord.bot_token', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:BOT_TOKEN') : '');
|
$this->migrator->add('discord.bot_token', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:BOT_TOKEN') : null);
|
||||||
$this->migrator->add('discord.client_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:CLIENT_ID') : '');
|
$this->migrator->add('discord.client_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:CLIENT_ID') : null);
|
||||||
$this->migrator->add('discord.client_secret', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:CLIENT_SECRET') : '');
|
$this->migrator->add('discord.client_secret', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:CLIENT_SECRET') : null);
|
||||||
$this->migrator->add('discord.guild_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:GUILD_ID') : '');
|
$this->migrator->add('discord.guild_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:GUILD_ID') : null);
|
||||||
$this->migrator->add('discord.invite_url', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:INVITE_URL') : '');
|
$this->migrator->add('discord.invite_url', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:INVITE_URL') : null);
|
||||||
$this->migrator->add('discord.role_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:ROLE_ID') : '');
|
$this->migrator->add('discord.role_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:ROLE_ID') : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(): void
|
public function down(): void
|
||||||
|
@ -23,91 +23,52 @@ class CreateDiscordSettings extends SettingsMigration
|
||||||
DB::table('settings_old')->insert([
|
DB::table('settings_old')->insert([
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::DISCORD:BOT_TOKEN',
|
'key' => 'SETTINGS::DISCORD:BOT_TOKEN',
|
||||||
'value' => $this->getNewValue('bot_token'),
|
'value' => $this->getNewValue('bot_token', 'discord'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The bot token for the Discord bot.',
|
'description' => 'The bot token for the Discord bot.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::DISCORD:CLIENT_ID',
|
'key' => 'SETTINGS::DISCORD:CLIENT_ID',
|
||||||
'value' => $this->getNewValue('client_id'),
|
'value' => $this->getNewValue('client_id', 'discord'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The client ID for the Discord bot.',
|
'description' => 'The client ID for the Discord bot.',
|
||||||
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::DISCORD:CLIENT_SECRET',
|
'key' => 'SETTINGS::DISCORD:CLIENT_SECRET',
|
||||||
'value' => $this->getNewValue('client_secret'),
|
'value' => $this->getNewValue('client_secret', 'discord'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The client secret for the Discord bot.',
|
'description' => 'The client secret for the Discord bot.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::DISCORD:GUILD_ID',
|
'key' => 'SETTINGS::DISCORD:GUILD_ID',
|
||||||
'value' => $this->getNewValue('guild_id'),
|
'value' => $this->getNewValue('guild_id', 'discord'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The guild ID for the Discord bot.',
|
'description' => 'The guild ID for the Discord bot.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::DISCORD:INVITE_URL',
|
'key' => 'SETTINGS::DISCORD:INVITE_URL',
|
||||||
'value' => $this->getNewValue('invite_url'),
|
'value' => $this->getNewValue('invite_url', 'discord'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The invite URL for the Discord bot.',
|
'description' => 'The invite URL for the Discord bot.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::DISCORD:ROLE_ID',
|
'key' => 'SETTINGS::DISCORD:ROLE_ID',
|
||||||
'value' => $this->getNewValue('role_id'),
|
'value' => $this->getNewValue('role_id', 'discord'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The role ID for the Discord bot.',
|
'description' => 'The role ID for the Discord bot.',
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
$this->migrator->delete('discord.bot_token');
|
$this->migrator->delete('discord.bot_token');
|
||||||
$this->migrator->delete('discord.client_id');
|
$this->migrator->delete('discord.client_id');
|
||||||
$this->migrator->delete('discord.client_secret');
|
$this->migrator->delete('discord.client_secret');
|
||||||
$this->migrator->delete('discord.guild_id');
|
$this->migrator->delete('discord.guild_id');
|
||||||
$this->migrator->delete('discord.invite_url');
|
$this->migrator->delete('discord.invite_url');
|
||||||
$this->migrator->delete('discord.role_id');
|
$this->migrator->delete('discord.role_id');
|
||||||
}
|
} catch (Exception $e) {
|
||||||
|
// Do nothing.
|
||||||
public function getNewValue(string $name)
|
}
|
||||||
{
|
|
||||||
$new_value = DB::table('settings')->where([['group', '=', 'discord'], ['name', '=', $name]])->get(['payload'])->first();
|
|
||||||
|
|
||||||
// Some keys returns '""' as a value.
|
|
||||||
if ($new_value->payload === '""') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove the quotes from the string
|
|
||||||
if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') {
|
|
||||||
return substr($new_value->payload, 1, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $new_value->payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOldValue(string $key)
|
|
||||||
{
|
|
||||||
// Always get the first value of the key.
|
|
||||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
|
||||||
|
|
||||||
// Handle the old values to return without it being a string in all cases.
|
|
||||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
|
||||||
if (is_null($old_value->value)) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Some values have the type string, but their values are boolean.
|
|
||||||
if ($old_value->value === "false" || $old_value->value === "true") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $old_value->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($old_value->type === "boolean") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
use App\Classes\LegacySettingsMigration;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class CreateLocaleSettings extends SettingsMigration
|
class CreateLocaleSettings extends LegacySettingsMigration
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -11,10 +11,10 @@ class CreateLocaleSettings extends SettingsMigration
|
||||||
|
|
||||||
// Get the user-set configuration values from the old table.
|
// Get the user-set configuration values from the old table.
|
||||||
$this->migrator->add('locale.available', $table_exists ? $this->getOldValue('SETTINGS::LOCALE:AVAILABLE') : '');
|
$this->migrator->add('locale.available', $table_exists ? $this->getOldValue('SETTINGS::LOCALE:AVAILABLE') : '');
|
||||||
$this->migrator->add('locale.clients_can_change', $table_exists ? $this->getOldValue('SETTINGS::LOCALE:CLIENTS_CAN_CHANGE') : true);
|
$this->migrator->add('locale.clients_can_change', $table_exists ? $this->getOldValue('SETTINGS::LOCALE:CLIENTS_CAN_CHANGE', true) : true);
|
||||||
$this->migrator->add('locale.datatables', $table_exists ? $this->getOldValue('SETTINGS::LOCALE:DATATABLES') : 'en-gb');
|
$this->migrator->add('locale.datatables', $table_exists ? $this->getOldValue('SETTINGS::LOCALE:DATATABLES') : 'en-gb');
|
||||||
$this->migrator->add('locale.default', $table_exists ? $this->getOldValue('SETTINGS::LOCALE:DEFAULT') : 'en');
|
$this->migrator->add('locale.default', $table_exists ? $this->getOldValue('SETTINGS::LOCALE:DEFAULT', 'en') : 'en');
|
||||||
$this->migrator->add('locale.dynamic', $table_exists ? $this->getOldValue('SETTINGS::LOCALE:DYNAMIC') : false);
|
$this->migrator->add('locale.dynamic', $table_exists ? $this->getOldValue('SETTINGS::LOCALE:DYNAMIC', false) : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(): void
|
public function down(): void
|
||||||
|
@ -22,83 +22,44 @@ class CreateLocaleSettings extends SettingsMigration
|
||||||
DB::table('settings_old')->insert([
|
DB::table('settings_old')->insert([
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::LOCALE:AVAILABLE',
|
'key' => 'SETTINGS::LOCALE:AVAILABLE',
|
||||||
'value' => $this->getNewValue('available'),
|
'value' => $this->getNewValue('available', 'locale'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The available locales.',
|
'description' => 'The available locales.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::LOCALE:CLIENTS_CAN_CHANGE',
|
'key' => 'SETTINGS::LOCALE:CLIENTS_CAN_CHANGE',
|
||||||
'value' => $this->getNewValue('clients_can_change'),
|
'value' => $this->getNewValue('clients_can_change', 'locale'),
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'If clients can change their locale.',
|
'description' => 'If clients can change their locale.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::LOCALE:DATATABLES',
|
'key' => 'SETTINGS::LOCALE:DATATABLES',
|
||||||
'value' => $this->getNewValue('datatables'),
|
'value' => $this->getNewValue('datatables', 'locale'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The locale for datatables.',
|
'description' => 'The locale for datatables.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::LOCALE:DEFAULT',
|
'key' => 'SETTINGS::LOCALE:DEFAULT',
|
||||||
'value' => $this->getNewValue('default'),
|
'value' => $this->getNewValue('default', 'locale'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The default locale.',
|
'description' => 'The default locale.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::LOCALE:DYNAMIC',
|
'key' => 'SETTINGS::LOCALE:DYNAMIC',
|
||||||
'value' => $this->getNewValue('dynamic'),
|
'value' => $this->getNewValue('dynamic', 'locale'),
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'If the locale should be dynamic.',
|
'description' => 'If the locale should be dynamic.',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
$this->migrator->delete('locale.available');
|
$this->migrator->delete('locale.available');
|
||||||
$this->migrator->delete('locale.clients_can_change');
|
$this->migrator->delete('locale.clients_can_change');
|
||||||
$this->migrator->delete('locale.datatables');
|
$this->migrator->delete('locale.datatables');
|
||||||
$this->migrator->delete('locale.default');
|
$this->migrator->delete('locale.default');
|
||||||
$this->migrator->delete('locale.dynamic');
|
$this->migrator->delete('locale.dynamic');
|
||||||
}
|
} catch (Exception $e) {
|
||||||
|
// Do nothing
|
||||||
public function getNewValue(string $name)
|
}
|
||||||
{
|
|
||||||
$new_value = DB::table('settings')->where([['group', '=', 'locale'], ['name', '=', $name]])->get(['payload'])->first();
|
|
||||||
|
|
||||||
// Some keys returns '""' as a value.
|
|
||||||
if ($new_value->payload === '""') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove the quotes from the string
|
|
||||||
if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') {
|
|
||||||
return substr($new_value->payload, 1, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $new_value->payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOldValue(string $key)
|
|
||||||
{
|
|
||||||
// Always get the first value of the key.
|
|
||||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
|
||||||
|
|
||||||
// Handle the old values to return without it being a string in all cases.
|
|
||||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
|
||||||
if (is_null($old_value->value)) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Some values have the type string, but their values are boolean.
|
|
||||||
if ($old_value->value === "false" || $old_value->value === "true") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $old_value->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($old_value->type === "boolean") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
use App\Classes\LegacySettingsMigration;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class CreateReferralSettings extends SettingsMigration
|
class CreateReferralSettings extends LegacySettingsMigration
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
$table_exists = DB::table('settings_old')->exists();
|
$table_exists = DB::table('settings_old')->exists();
|
||||||
|
|
||||||
// Get the user-set configuration values from the old table.
|
// Get the user-set configuration values from the old table.
|
||||||
$this->migrator->add('referral.always_give_commission', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION') : false);
|
$this->migrator->add('referral.always_give_commission', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION', false) : false);
|
||||||
$this->migrator->add('referral.enabled', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL::ENABLED') : false);
|
$this->migrator->add('referral.enabled', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL::ENABLED', false) : false);
|
||||||
$this->migrator->add('referral.reward', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL::REWARD') : 100);
|
$this->migrator->add('referral.reward', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL::REWARD') : 100);
|
||||||
$this->migrator->add('referral.mode', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL:MODE') : 'sign-up');
|
$this->migrator->add('referral.mode', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL:MODE', 'sign-up') : 'sign-up');
|
||||||
$this->migrator->add('referral.percentage', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL:PERCENTAGE') : 100);
|
$this->migrator->add('referral.percentage', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL:PERCENTAGE', 100) : 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(): void
|
public function down(): void
|
||||||
|
@ -22,90 +22,51 @@ class CreateReferralSettings extends SettingsMigration
|
||||||
DB::table('settings_old')->insert([
|
DB::table('settings_old')->insert([
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::REFERRAL::ALLOWED',
|
'key' => 'SETTINGS::REFERRAL::ALLOWED',
|
||||||
'value' => $this->getNewValue('allowed'),
|
'value' => $this->getNewValue('allowed', 'referral'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The allowed referral types.',
|
'description' => 'The allowed referral types.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION',
|
'key' => 'SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION',
|
||||||
'value' => $this->getNewValue('always_give_commission'),
|
'value' => $this->getNewValue('always_give_commission', 'referral'),
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'Whether to always give commission to the referrer.',
|
'description' => 'Whether to always give commission to the referrer.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::REFERRAL::ENABLED',
|
'key' => 'SETTINGS::REFERRAL::ENABLED',
|
||||||
'value' => $this->getNewValue('enabled'),
|
'value' => $this->getNewValue('enabled', 'referral'),
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'Whether to enable the referral system.',
|
'description' => 'Whether to enable the referral system.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::REFERRAL::REWARD',
|
'key' => 'SETTINGS::REFERRAL::REWARD',
|
||||||
'value' => $this->getNewValue('reward'),
|
'value' => $this->getNewValue('reward', 'referral'),
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'description' => 'The reward for the referral.',
|
'description' => 'The reward for the referral.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::REFERRAL:MODE',
|
'key' => 'SETTINGS::REFERRAL:MODE',
|
||||||
'value' => $this->getNewValue('mode'),
|
'value' => $this->getNewValue('mode', 'referral'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The referral mode.',
|
'description' => 'The referral mode.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::REFERRAL:PERCENTAGE',
|
'key' => 'SETTINGS::REFERRAL:PERCENTAGE',
|
||||||
'value' => $this->getNewValue('percentage'),
|
'value' => $this->getNewValue('percentage', 'referral'),
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'description' => 'The referral percentage.',
|
'description' => 'The referral percentage.',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
$this->migrator->delete('referral.allowed');
|
$this->migrator->delete('referral.allowed');
|
||||||
$this->migrator->delete('referral.always_give_commission');
|
$this->migrator->delete('referral.always_give_commission');
|
||||||
$this->migrator->delete('referral.enabled');
|
$this->migrator->delete('referral.enabled');
|
||||||
$this->migrator->delete('referral.reward');
|
$this->migrator->delete('referral.reward');
|
||||||
$this->migrator->delete('referral.mode');
|
$this->migrator->delete('referral.mode');
|
||||||
$this->migrator->delete('referral.percentage');
|
$this->migrator->delete('referral.percentage');
|
||||||
}
|
} catch (Exception $e) {
|
||||||
|
//
|
||||||
public function getNewValue(string $name)
|
}
|
||||||
{
|
|
||||||
$new_value = DB::table('settings')->where([['group', '=', 'referral'], ['name', '=', $name]])->get(['payload'])->first();
|
|
||||||
|
|
||||||
// Some keys returns '""' as a value.
|
|
||||||
if ($new_value->payload === '""') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove the quotes from the string
|
|
||||||
if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') {
|
|
||||||
return substr($new_value->payload, 1, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $new_value->payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOldValue(string $key)
|
|
||||||
{
|
|
||||||
// Always get the first value of the key.
|
|
||||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
|
||||||
|
|
||||||
// Handle the old values to return without it being a string in all cases.
|
|
||||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
|
||||||
if (is_null($old_value->value)) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Some values have the type string, but their values are boolean.
|
|
||||||
if ($old_value->value === "false" || $old_value->value === "true") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $old_value->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($old_value->type === "boolean") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,28 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
use App\Classes\LegacySettingsMigration;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class CreateWebsiteSettings extends SettingsMigration
|
class CreateWebsiteSettings extends LegacySettingsMigration
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
$table_exists = DB::table('settings_old')->exists();
|
$table_exists = DB::table('settings_old')->exists();
|
||||||
|
|
||||||
// Get the user-set configuration values from the old table.
|
// Get the user-set configuration values from the old table.
|
||||||
$this->migrator->add('website.motd_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:MOTD_ENABLED") : true);
|
$this->migrator->add('website.motd_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:MOTD_ENABLED", true) : true);
|
||||||
$this->migrator->add(
|
$this->migrator->add(
|
||||||
'website.motd_message',
|
'website.motd_message',
|
||||||
$table_exists ? $this->getOldValue("SETTINGS::SYSTEM:MOTD_MESSAGE") :
|
$table_exists ? $this->getOldValue("SETTINGS::SYSTEM:MOTD_MESSAGE") :
|
||||||
"<h1 style='text-align: center;'><img style='display: block; margin-left: auto; margin-right: auto;' src='https://ctrlpanel.gg/img/controlpanel.png' alt=' width='200' height='200'><span style='font-size: 36pt;'>CtrlPanel.gg</span></h1>
|
"<h1 style='text-align: center;'><img style='display: block; margin-left: auto; margin-right: auto;' src='https://ctrlpanel.gg/img/controlpanel.png' alt=' width='200' height='200'><span style='font-size: 36pt;'>CtrlPanel.gg</span></h1>
|
||||||
<p><span style='font-size: 18pt;'>Thank you for using our Software</span></p>
|
<p><span style='font-size: 18pt;'>Thank you for using our Software</span></p>
|
||||||
<p><span style='font-size: 18pt;'>If you have any questions, make sure to join our <a href='https://discord.com/invite/4Y6HjD2uyU' target='_blank' rel='noopener'>Discord</a></span></p>
|
<p><span style='font-size: 18pt;'>If you have any questions, make sure to join our <a href='https://discord.com/invite/4Y6HjD2uyU' target='_blank' rel='noopener'>Discord</a></span></p>
|
||||||
<p><span style='font-size: 10pt;'>(you can change this message in the <a href='admin/settings#system'>Settings</a> )</span></p>");
|
<p><span style='font-size: 10pt;'>(you can change this message in the <a href='admin/settings#system'>Settings</a> )</span></p>"
|
||||||
$this->migrator->add('website.show_imprint', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SHOW_IMPRINT") : false);
|
);
|
||||||
$this->migrator->add('website.show_privacy', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SHOW_PRIVACY") : false);
|
$this->migrator->add('website.show_imprint', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SHOW_IMPRINT", false) : false);
|
||||||
$this->migrator->add('website.show_tos', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SHOW_TOS") : false);
|
$this->migrator->add('website.show_privacy', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SHOW_PRIVACY", false) : false);
|
||||||
$this->migrator->add('website.useful_links_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:USEFULLINKS_ENABLED") : true);
|
$this->migrator->add('website.show_tos', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SHOW_TOS", false) : false);
|
||||||
|
$this->migrator->add('website.useful_links_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:USEFULLINKS_ENABLED", true) : true);
|
||||||
$this->migrator->add('website.seo_title', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SEO_TITLE") : 'CtrlPanel.gg');
|
$this->migrator->add('website.seo_title', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SEO_TITLE") : 'CtrlPanel.gg');
|
||||||
$this->migrator->add('website.seo_description', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SEO_DESCRIPTION") : 'Billing software for Pterodactyl Panel.');
|
$this->migrator->add('website.seo_description', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SEO_DESCRIPTION") : 'Billing software for Pterodactyl Panel.');
|
||||||
$this->migrator->add('website.enable_login_logo', true);
|
$this->migrator->add('website.enable_login_logo', true);
|
||||||
|
@ -32,60 +33,61 @@ class CreateWebsiteSettings extends SettingsMigration
|
||||||
DB::table('settings_old')->insert([
|
DB::table('settings_old')->insert([
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:MOTD_ENABLED',
|
'key' => 'SETTINGS::SYSTEM:MOTD_ENABLED',
|
||||||
'value' => $this->getNewValue('motd_enabled'),
|
'value' => $this->getNewValue('motd_enabled', 'website'),
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'Enable or disable the MOTD.',
|
'description' => 'Enable or disable the MOTD.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:MOTD_MESSAGE',
|
'key' => 'SETTINGS::SYSTEM:MOTD_MESSAGE',
|
||||||
'value' => $this->getNewValue('motd_message'),
|
'value' => $this->getNewValue('motd_message', 'website'),
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'description' => 'The message that will be displayed in the MOTD.',
|
'description' => 'The message that will be displayed in the MOTD.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:SHOW_IMPRINT',
|
'key' => 'SETTINGS::SYSTEM:SHOW_IMPRINT',
|
||||||
'value' => $this->getNewValue('show_imprint'),
|
'value' => $this->getNewValue('show_imprint', 'website'),
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'Enable or disable the imprint.',
|
'description' => 'Enable or disable the imprint.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:SHOW_PRIVACY',
|
'key' => 'SETTINGS::SYSTEM:SHOW_PRIVACY',
|
||||||
'value' => $this->getNewValue('show_privacy'),
|
'value' => $this->getNewValue('show_privacy', 'website'),
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'Enable or disable the privacy policy.',
|
'description' => 'Enable or disable the privacy policy.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:SHOW_TOS',
|
'key' => 'SETTINGS::SYSTEM:SHOW_TOS',
|
||||||
'value' => $this->getNewValue('show_tos'),
|
'value' => $this->getNewValue('show_tos', 'website'),
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'Enable or disable the terms of service.',
|
'description' => 'Enable or disable the terms of service.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:USEFULLINKS_ENABLED',
|
'key' => 'SETTINGS::SYSTEM:USEFULLINKS_ENABLED',
|
||||||
'value' => $this->getNewValue('useful_links_enabled'),
|
'value' => $this->getNewValue('useful_links_enabled', 'website'),
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'Enable or disable the useful links.',
|
'description' => 'Enable or disable the useful links.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:SEO_TITLE',
|
'key' => 'SETTINGS::SYSTEM:SEO_TITLE',
|
||||||
'value' => $this->getNewValue('seo_title'),
|
'value' => $this->getNewValue('seo_title', 'website'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The title of the website.',
|
'description' => 'The title of the website.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:SEO_DESCRIPTION',
|
'key' => 'SETTINGS::SYSTEM:SEO_DESCRIPTION',
|
||||||
'value' => $this->getNewValue('seo_description'),
|
'value' => $this->getNewValue('seo_description', 'website'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The description of the website.',
|
'description' => 'The description of the website.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::SYSTEM:ENABLE_LOGIN_LOGO',
|
'key' => 'SETTINGS::SYSTEM:ENABLE_LOGIN_LOGO',
|
||||||
'value' => $this->getNewValue('enable_login_logo'),
|
'value' => $this->getNewValue('enable_login_logo', 'website'),
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'Enable or disable the login logo.',
|
'description' => 'Enable or disable the login logo.',
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
$this->migrator->delete('website.motd_enabled');
|
$this->migrator->delete('website.motd_enabled');
|
||||||
$this->migrator->delete('website.motd_message');
|
$this->migrator->delete('website.motd_message');
|
||||||
$this->migrator->delete('website.show_imprint');
|
$this->migrator->delete('website.show_imprint');
|
||||||
|
@ -95,48 +97,8 @@ class CreateWebsiteSettings extends SettingsMigration
|
||||||
$this->migrator->delete('website.seo_title');
|
$this->migrator->delete('website.seo_title');
|
||||||
$this->migrator->delete('website.seo_description');
|
$this->migrator->delete('website.seo_description');
|
||||||
$this->migrator->delete('website.enable_login_logo');
|
$this->migrator->delete('website.enable_login_logo');
|
||||||
}
|
} catch (Exception $e) {
|
||||||
|
// Do nothing
|
||||||
public function getNewValue(string $name)
|
}
|
||||||
{
|
|
||||||
$new_value = DB::table('settings')->where([['group', '=', 'website'], ['name', '=', $name]])->get(['payload'])->first();
|
|
||||||
|
|
||||||
// Some keys returns '""' as a value.
|
|
||||||
if ($new_value->payload === '""') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove the quotes from the string
|
|
||||||
if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') {
|
|
||||||
return substr($new_value->payload, 1, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $new_value->payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOldValue(string $key)
|
|
||||||
{
|
|
||||||
// Always get the first value of the key.
|
|
||||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
|
||||||
|
|
||||||
// Handle the old values to return without it being a string in all cases.
|
|
||||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
|
||||||
if (is_null($old_value->value)) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Some values have the type string, but their values are boolean.
|
|
||||||
if ($old_value->value === "false" || $old_value->value === "true") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $old_value->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($old_value->type === "boolean") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
use App\Classes\LegacySettingsMigration;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class CreateTicketSettings extends SettingsMigration
|
class CreateTicketSettings extends LegacySettingsMigration
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -19,67 +19,23 @@ class CreateTicketSettings extends SettingsMigration
|
||||||
DB::table('settings_old')->insert([
|
DB::table('settings_old')->insert([
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::TICKET:NOTIFY',
|
'key' => 'SETTINGS::TICKET:NOTIFY',
|
||||||
'value' => $this->getNewValue('notify'),
|
'value' => $this->getNewValue('notify', 'ticket'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'The notification type for tickets.',
|
'description' => 'The notification type for tickets.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'key' => 'SETTINGS::TICKET:ENABLED',
|
'key' => 'SETTINGS::TICKET:ENABLED',
|
||||||
'value' => $this->getNewValue('enabled'),
|
'value' => $this->getNewValue('enabled', 'ticket'),
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'Enable or disable the ticket system.',
|
'description' => 'Enable or disable the ticket system.',
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
$this->migrator->delete('ticket.enabled');
|
$this->migrator->delete('ticket.enabled');
|
||||||
$this->migrator->delete('ticket.notify');
|
$this->migrator->delete('ticket.notify');
|
||||||
}
|
} catch (Exception $e) {
|
||||||
|
// Do nothing.
|
||||||
public function getNewValue(string $name)
|
}
|
||||||
{
|
|
||||||
$new_value = DB::table('settings')->where([['group', '=', 'ticket'], ['name', '=', $name]])->get(['payload'])->first();
|
|
||||||
|
|
||||||
// Some keys returns '""' as a value.
|
|
||||||
if ($new_value->payload === '""') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove the quotes from the string
|
|
||||||
if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') {
|
|
||||||
return substr($new_value->payload, 1, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $new_value->payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOldValue(string $key)
|
|
||||||
{
|
|
||||||
// Always get the first value of the key.
|
|
||||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
|
||||||
|
|
||||||
// Handle the old values to return without it being a string in all cases.
|
|
||||||
|
|
||||||
if (is_null($old_value)) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
|
||||||
if (is_null($old_value->value)) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Some values have the type string, but their values are boolean.
|
|
||||||
if ($old_value->value === "false" || $old_value->value === "true") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $old_value->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($old_value->type === "boolean") {
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,4 +9,10 @@ return new class extends SettingsMigration
|
||||||
$this->migrator->delete('ticket.notify');
|
$this->migrator->delete('ticket.notify');
|
||||||
$this->migrator->add('ticket.information', "Can't start your server? Need an additional port? Do you have any other questions? Let us know by opening a ticket.");
|
$this->migrator->add('ticket.information', "Can't start your server? Need an additional port? Do you have any other questions? Let us know by opening a ticket.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
$this->migrator->add('ticket.notify', 'all');
|
||||||
|
$this->migrator->delete('ticket.information');
|
||||||
|
}
|
||||||
};
|
};
|
|
@ -34,6 +34,7 @@ use App\Http\Controllers\TicketsController;
|
||||||
use App\Http\Controllers\TranslationController;
|
use App\Http\Controllers\TranslationController;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -77,11 +78,13 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () {
|
||||||
Route::patch('/servers/cancel/{server}', [ServerController::class, 'cancel'])->name('servers.cancel');
|
Route::patch('/servers/cancel/{server}', [ServerController::class, 'cancel'])->name('servers.cancel');
|
||||||
Route::resource('servers', ServerController::class);
|
Route::resource('servers', ServerController::class);
|
||||||
|
|
||||||
if (config('app.key')) {
|
try {
|
||||||
$serverSettings = app(App\Settings\ServerSettings::class);
|
$serverSettings = app(App\Settings\ServerSettings::class);
|
||||||
if ($serverSettings->enable_upgrade) {
|
if ($serverSettings->creation_enabled) {
|
||||||
Route::post('servers/{server}/upgrade', [ServerController::class, 'upgrade'])->name('servers.upgrade');
|
Route::post('servers/{server}/upgrade', [ServerController::class, 'upgrade'])->name('servers.upgrade');
|
||||||
}
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Log::error("ServerSettings not found, skipping server upgrade route");
|
||||||
}
|
}
|
||||||
|
|
||||||
Route::post('profile/selfdestruct', [ProfileController::class, 'selfDestroyUser'])->name('profile.selfDestroyUser');
|
Route::post('profile/selfdestruct', [ProfileController::class, 'selfDestroyUser'])->name('profile.selfDestroyUser');
|
||||||
|
|
Loading…
Reference in a new issue