From c8e82ca57b9a96994872156756baa1815665a109 Mon Sep 17 00:00:00 2001 From: Dennis Date: Thu, 23 Feb 2023 09:38:09 +0100 Subject: [PATCH 001/120] Update app.php --- config/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/app.php b/config/app.php index 5f16a82c..1afefd24 100644 --- a/config/app.php +++ b/config/app.php @@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Facade; return [ - 'version' => '0.9.2', + 'version' => '0.9.3', /* |-------------------------------------------------------------------------- From 2229586b58e68c99f6d0c0986d9749c88a2d6dd3 Mon Sep 17 00:00:00 2001 From: Ferks-FK Date: Wed, 1 Feb 2023 19:33:36 +0000 Subject: [PATCH 002/120] feat: implement laravel-settings --- app/Models/Settings.php | 40 - app/Providers/AppServiceProvider.php | 147 +- app/Settings/GeneralSettings.php | 29 + composer.json | 1 + composer.lock | 261 +++- config/settings.php | 88 ++ ...023_02_01_155140_rename_settings_table.php | 22 + ...02_01_155730_create_new_settings_table.php | 35 + database/seeders/Seeds/SettingsSeeder.php | 1188 +++++++++-------- ...3_02_01_164731_create_general_settings.php | 26 + ..._01_181334_create_pterodactyl_settings.php | 25 + ...2023_02_01_181453_create_mail_settings.php | 30 + ...2023_02_01_181925_create_user_settings.php | 31 + ...23_02_01_181950_create_server_settings.php | 22 + ...3_02_01_182021_create_invoice_settings.php | 29 + ...3_02_01_182043_create_discord_settings.php | 27 + ...23_02_01_182108_create_locale_settings.php | 26 + ..._02_01_182135_create_referral_settings.php | 27 + ...3_02_01_182158_create_website_settings.php | 22 + 19 files changed, 1366 insertions(+), 710 deletions(-) create mode 100644 app/Settings/GeneralSettings.php create mode 100644 config/settings.php create mode 100644 database/migrations/2023_02_01_155140_rename_settings_table.php create mode 100644 database/migrations/2023_02_01_155730_create_new_settings_table.php create mode 100644 database/settings/2023_02_01_164731_create_general_settings.php create mode 100644 database/settings/2023_02_01_181334_create_pterodactyl_settings.php create mode 100644 database/settings/2023_02_01_181453_create_mail_settings.php create mode 100644 database/settings/2023_02_01_181925_create_user_settings.php create mode 100644 database/settings/2023_02_01_181950_create_server_settings.php create mode 100644 database/settings/2023_02_01_182021_create_invoice_settings.php create mode 100644 database/settings/2023_02_01_182043_create_discord_settings.php create mode 100644 database/settings/2023_02_01_182108_create_locale_settings.php create mode 100644 database/settings/2023_02_01_182135_create_referral_settings.php create mode 100644 database/settings/2023_02_01_182158_create_website_settings.php diff --git a/app/Models/Settings.php b/app/Models/Settings.php index ccad0f4a..09713970 100644 --- a/app/Models/Settings.php +++ b/app/Models/Settings.php @@ -4,48 +4,8 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Facades\Cache; class Settings extends Model { use HasFactory; - - protected $table = 'settings'; - - public const CACHE_TAG = 'setting'; - - public $primaryKey = 'key'; - - public $incrementing = false; - - protected $keyType = 'string'; - - protected $fillable = [ - 'key', - 'value', - 'type', - ]; - - public static function boot() - { - parent::boot(); - - static::updated(function (Settings $settings) { - Cache::forget(self::CACHE_TAG.':'.$settings->key); - }); - } - - /** - * @param string $key - * @param $default - * @return mixed - */ - public static function getValueByKey(string $key, $default = null) - { - return Cache::rememberForever(self::CACHE_TAG.':'.$key, function () use ($default, $key) { - $settings = self::find($key); - - return $settings ? $settings->value : $default; - }); - } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 6299bf4f..88e4c3cd 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,7 +2,6 @@ namespace App\Providers; -use App\Models\Settings; use App\Models\UsefulLink; use Exception; use Illuminate\Pagination\Paginator; @@ -64,91 +63,89 @@ class AppServiceProvider extends ServiceProvider } //only run if the installer has been executed - try { - $settings = Settings::all(); - // Set all configs from database - foreach ($settings as $setting) { - config([$setting->key => $setting->value]); - } + // try { + // $settings = Settings::all(); + // // Set all configs from database + // foreach ($settings as $setting) { + // config([$setting->key => $setting->value]); + // } - if (!file_exists(base_path('themes') . "/" . config("SETTINGS::SYSTEM:THEME"))) { - config(['SETTINGS::SYSTEM:THEME' => "default"]); - } + // if(!file_exists(base_path('themes') . "/" . config("SETTINGS::SYSTEM:THEME"))){ + // config(['SETTINGS::SYSTEM:THEME' => "default"]); + // } - if (config('SETTINGS::SYSTEM:THEME') && config('SETTINGS::SYSTEM:THEME') !== config('theme.active')) { - Theme::set(config("SETTINGS::SYSTEM:THEME", "default"), "default"); - } else { - Theme::set("default", "default"); - } + // if(config('SETTINGS::SYSTEM:THEME') !== config('theme.active')){ + // Theme::set(config("SETTINGS::SYSTEM:THEME"), "default"); + // } - // Set Mail Config - //only update config if mail settings have changed in DB - if ( - config('mail.default') != config('SETTINGS:MAIL:MAILER') || - config('mail.mailers.smtp.host') != config('SETTINGS:MAIL:HOST') || - config('mail.mailers.smtp.port') != config('SETTINGS:MAIL:PORT') || - config('mail.mailers.smtp.username') != config('SETTINGS:MAIL:USERNAME') || - config('mail.mailers.smtp.password') != config('SETTINGS:MAIL:PASSWORD') || - config('mail.mailers.smtp.encryption') != config('SETTINGS:MAIL:ENCRYPTION') || - config('mail.from.address') != config('SETTINGS:MAIL:FROM_ADDRESS') || - config('mail.from.name') != config('SETTINGS:MAIL:FROM_NAME') - ) { - config(['mail.default' => config('SETTINGS::MAIL:MAILER')]); - config(['mail.mailers.smtp' => [ - 'transport' => 'smtp', - 'host' => config('SETTINGS::MAIL:HOST'), - 'port' => config('SETTINGS::MAIL:PORT'), - 'encryption' => config('SETTINGS::MAIL:ENCRYPTION'), - 'username' => config('SETTINGS::MAIL:USERNAME'), - 'password' => config('SETTINGS::MAIL:PASSWORD'), - 'timeout' => null, - 'auth_mode' => null, - ]]); - config(['mail.from' => ['address' => config('SETTINGS::MAIL:FROM_ADDRESS'), 'name' => config('SETTINGS::MAIL:FROM_NAME')]]); + // // Set Mail Config + // //only update config if mail settings have changed in DB + // if ( + // config('mail.default') != config('SETTINGS:MAIL:MAILER') || + // config('mail.mailers.smtp.host') != config('SETTINGS:MAIL:HOST') || + // config('mail.mailers.smtp.port') != config('SETTINGS:MAIL:PORT') || + // config('mail.mailers.smtp.username') != config('SETTINGS:MAIL:USERNAME') || + // config('mail.mailers.smtp.password') != config('SETTINGS:MAIL:PASSWORD') || + // config('mail.mailers.smtp.encryption') != config('SETTINGS:MAIL:ENCRYPTION') || + // config('mail.from.address') != config('SETTINGS:MAIL:FROM_ADDRESS') || + // config('mail.from.name') != config('SETTINGS:MAIL:FROM_NAME') + // ) { + // config(['mail.default' => config('SETTINGS::MAIL:MAILER')]); + // config(['mail.mailers.smtp' => [ + // 'transport' => 'smtp', + // 'host' => config('SETTINGS::MAIL:HOST'), + // 'port' => config('SETTINGS::MAIL:PORT'), + // 'encryption' => config('SETTINGS::MAIL:ENCRYPTION'), + // 'username' => config('SETTINGS::MAIL:USERNAME'), + // 'password' => config('SETTINGS::MAIL:PASSWORD'), + // 'timeout' => null, + // 'auth_mode' => null, + // ]]); + // config(['mail.from' => ['address' => config('SETTINGS::MAIL:FROM_ADDRESS'), 'name' => config('SETTINGS::MAIL:FROM_NAME')]]); - Artisan::call('queue:restart'); - } + // Artisan::call('queue:restart'); + // } - // Set Recaptcha API Config - // Load recaptcha package if recaptcha is enabled - if (config('SETTINGS::RECAPTCHA:ENABLED') == 'true') { - $this->app->register(\Biscolab\ReCaptcha\ReCaptchaServiceProvider::class); - } + // // Set Recaptcha API Config + // // Load recaptcha package if recaptcha is enabled + // if (config('SETTINGS::RECAPTCHA:ENABLED') == 'true') { + // $this->app->register(\Biscolab\ReCaptcha\ReCaptchaServiceProvider::class); + // } - //only update config if recaptcha settings have changed in DB - if ( - config('recaptcha.api_site_key') != config('SETTINGS::RECAPTCHA:SITE_KEY') || - config('recaptcha.api_secret_key') != config('SETTINGS::RECAPTCHA:SECRET_KEY') - ) { - config(['recaptcha.api_site_key' => config('SETTINGS::RECAPTCHA:SITE_KEY')]); - config(['recaptcha.api_secret_key' => config('SETTINGS::RECAPTCHA:SECRET_KEY')]); + // //only update config if recaptcha settings have changed in DB + // if ( + // config('recaptcha.api_site_key') != config('SETTINGS::RECAPTCHA:SITE_KEY') || + // config('recaptcha.api_secret_key') != config('SETTINGS::RECAPTCHA:SECRET_KEY') + // ) { + // config(['recaptcha.api_site_key' => config('SETTINGS::RECAPTCHA:SITE_KEY')]); + // config(['recaptcha.api_secret_key' => config('SETTINGS::RECAPTCHA:SECRET_KEY')]); - Artisan::call('config:clear'); - Artisan::call('cache:clear'); - } + // Artisan::call('config:clear'); + // Artisan::call('cache:clear'); + // } - try { - $stringfromfile = file(base_path() . '/.git/HEAD'); + // try { + // $stringfromfile = file(base_path().'/.git/HEAD'); - $firstLine = $stringfromfile[0]; //get the string from the array + // $firstLine = $stringfromfile[0]; //get the string from the array - $explodedstring = explode('/', $firstLine, 3); //seperate out by the "/" in the string + // $explodedstring = explode('/', $firstLine, 3); //seperate out by the "/" in the string - $branchname = $explodedstring[2]; //get the one that is always the branch name - } catch (Exception $e) { - $branchname = 'unknown'; - Log::notice($e); - } - config(['BRANCHNAME' => $branchname]); + // $branchname = $explodedstring[2]; //get the one that is always the branch name + // } catch (Exception $e) { + // $branchname = 'unknown'; + // Log::notice($e); + // } + // config(['BRANCHNAME' => $branchname]); - // Set Discord-API Config - config(['services.discord.client_id' => config('SETTINGS::DISCORD:CLIENT_ID')]); - config(['services.discord.client_secret' => config('SETTINGS::DISCORD:CLIENT_SECRET')]); - } catch (Exception $e) { - error_log('Settings Error: Could not load settings from database. The Installation probably is not done yet.'); - error_log($e); - Log::error('Settings Error: Could not load settings from database. The Installation probably is not done yet.'); - Log::error($e); - } + // // Set Discord-API Config + // config(['services.discord.client_id' => config('SETTINGS::DISCORD:CLIENT_ID')]); + // config(['services.discord.client_secret' => config('SETTINGS::DISCORD:CLIENT_SECRET')]); + // } catch (Exception $e) { + // error_log('Settings Error: Could not load settings from database. The Installation probably is not done yet.'); + // error_log($e); + // Log::error('Settings Error: Could not load settings from database. The Installation probably is not done yet.'); + // Log::error($e); + // } } } diff --git a/app/Settings/GeneralSettings.php b/app/Settings/GeneralSettings.php new file mode 100644 index 00000000..19ebf8ba --- /dev/null +++ b/app/Settings/GeneralSettings.php @@ -0,0 +1,29 @@ + [ + GeneralSettings::class + ], + + /* + * The path where the settings classes will be created. + */ + 'setting_class_path' => app_path('Settings'), + + /* + * In these directories settings migrations will be stored and ran when migrating. A settings + * migration created via the make:settings-migration command will be stored in the first path or + * a custom defined path when running the command. + */ + 'migrations_paths' => [ + database_path('settings'), + ], + + /* + * When no repository was set for a settings class the following repository + * will be used for loading and saving settings. + */ + 'default_repository' => 'database', + + /* + * Settings will be stored and loaded from these repositories. + */ + 'repositories' => [ + 'database' => [ + 'type' => Spatie\LaravelSettings\SettingsRepositories\DatabaseSettingsRepository::class, + 'model' => null, + 'table' => null, + 'connection' => null, + ], + 'redis' => [ + 'type' => Spatie\LaravelSettings\SettingsRepositories\RedisSettingsRepository::class, + 'connection' => null, + 'prefix' => null, + ], + ], + + /* + * The contents of settings classes can be cached through your application, + * settings will be stored within a provided Laravel store and can have an + * additional prefix. + */ + 'cache' => [ + 'enabled' => env('SETTINGS_CACHE_ENABLED', false), + 'store' => null, + 'prefix' => null, + 'ttl' => null, + ], + + /* + * These global casts will be automatically used whenever a property within + * your settings class isn't a default PHP type. + */ + 'global_casts' => [ + DateTimeInterface::class => Spatie\LaravelSettings\SettingsCasts\DateTimeInterfaceCast::class, + DateTimeZone::class => Spatie\LaravelSettings\SettingsCasts\DateTimeZoneCast::class, +// Spatie\DataTransferObject\DataTransferObject::class => Spatie\LaravelSettings\SettingsCasts\DtoCast::class, + Spatie\LaravelData\Data::class => Spatie\LaravelSettings\SettingsCasts\DataCast::class, + ], + + /* + * The package will look for settings in these paths and automatically + * register them. + */ + 'auto_discover_settings' => [ + app()->path(), + ], + + /* + * Automatically discovered settings classes can be cached so they don't + * need to be searched each time the application boots up. + */ + 'discovered_settings_cache_path' => storage_path('app/laravel-settings'), +]; diff --git a/database/migrations/2023_02_01_155140_rename_settings_table.php b/database/migrations/2023_02_01_155140_rename_settings_table.php new file mode 100644 index 00000000..89f0995a --- /dev/null +++ b/database/migrations/2023_02_01_155140_rename_settings_table.php @@ -0,0 +1,22 @@ +rename('settings_old'); + }); + } + + public function down() + { + Schema::table('settings', function (Blueprint $table) { + $table->rename("settings"); + }); + } +}; diff --git a/database/migrations/2023_02_01_155730_create_new_settings_table.php b/database/migrations/2023_02_01_155730_create_new_settings_table.php new file mode 100644 index 00000000..66647869 --- /dev/null +++ b/database/migrations/2023_02_01_155730_create_new_settings_table.php @@ -0,0 +1,35 @@ +id(); + $table->string('name'); + $table->json('payload')->nullable(); + $table->string('group')->index(); + $table->boolean('locked'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('settings'); + } +}; diff --git a/database/seeders/Seeds/SettingsSeeder.php b/database/seeders/Seeds/SettingsSeeder.php index accfc06c..65773e0b 100644 --- a/database/seeders/Seeds/SettingsSeeder.php +++ b/database/seeders/Seeds/SettingsSeeder.php @@ -4,6 +4,7 @@ namespace Database\Seeders\Seeds; use App\Models\Settings; use Illuminate\Database\Seeder; +use Illuminate\Support\Facades\DB; class SettingsSeeder extends Seeder { @@ -14,6 +15,7 @@ class SettingsSeeder extends Seeder */ public function run() { + DB::table('settings_old', 'old')->where(''); //initials Settings::firstOrCreate([ 'key' => 'SETTINGS::USER:INITIAL_CREDITS', @@ -23,634 +25,634 @@ class SettingsSeeder extends Seeder 'description' => 'The initial amount of credits the user starts with.', ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::USER:INITIAL_SERVER_LIMIT', - ], [ - 'value' => '1', - 'type' => 'integer', - 'description' => 'The initial server limit the user starts with.', - ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::USER:INITIAL_SERVER_LIMIT', +// ], [ +// 'value' => '1', +// 'type' => 'integer', +// 'description' => 'The initial server limit the user starts with.', +// ]); - //verify email event - Settings::firstOrCreate([ - 'key' => 'SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL', - ], [ - 'value' => '250', - 'type' => 'integer', - 'description' => 'Increase in credits after the user has verified their email account.', - ]); +// //verify email event +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL', +// ], [ +// 'value' => '250', +// 'type' => 'integer', +// 'description' => 'Increase in credits after the user has verified their email account.', +// ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL', - ], [ - 'value' => '2', - 'type' => 'integer', - 'description' => 'Increase in server limit after the user has verified their email account.', - ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL', +// ], [ +// 'value' => '2', +// 'type' => 'integer', +// 'description' => 'Increase in server limit after the user has verified their email account.', +// ]); - //verify discord event - Settings::firstOrCreate([ - 'key' => 'SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD', - ], [ - 'value' => '375', - 'type' => 'integer', - 'description' => 'Increase in credits after the user has verified their discord account.', - ]); +// //verify discord event +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD', +// ], [ +// 'value' => '375', +// 'type' => 'integer', +// 'description' => 'Increase in credits after the user has verified their discord account.', +// ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD', - ], [ - 'value' => '2', - 'type' => 'integer', - 'description' => 'Increase in server limit after the user has verified their discord account.', - ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD', +// ], [ +// 'value' => '2', +// 'type' => 'integer', +// 'description' => 'Increase in server limit after the user has verified their discord account.', +// ]); - //other - Settings::firstOrCreate([ - 'key' => 'SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', - ], [ - 'value' => '50', - 'type' => 'integer', - 'description' => 'The minimum amount of credits the user would need to make a server.', - ]); +// //other +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', +// ], [ +// 'value' => '50', +// 'type' => 'integer', +// 'description' => 'The minimum amount of credits the user would need to make a server.', +// ]); - //purchasing - Settings::firstOrCreate([ - 'key' => 'SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE', - ], [ - 'value' => '10', - 'type' => 'integer', - 'description' => 'updates the users server limit to this amount (unless the user already has a higher server limit) after making a purchase with real money, set to 0 to ignore this.', - ]); +// //purchasing +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE', +// ], [ +// 'value' => '10', +// 'type' => 'integer', +// 'description' => 'updates the users server limit to this amount (unless the user already has a higher server limit) after making a purchase with real money, set to 0 to ignore this.', +// ]); - //force email and discord verification - Settings::firstOrCreate([ - 'key' => 'SETTINGS::USER:FORCE_EMAIL_VERIFICATION', - ], [ - 'value' => 'false', - 'type' => 'boolean', - 'description' => 'Force an user to verify the email adress before creating a server / buying credits.', - ]); +// //force email and discord verification +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::USER:FORCE_EMAIL_VERIFICATION', +// ], [ +// 'value' => 'false', +// 'type' => 'boolean', +// 'description' => 'Force an user to verify the email adress before creating a server / buying credits.', +// ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::USER:FORCE_DISCORD_VERIFICATION', - ], [ - 'value' => 'false', - 'type' => 'boolean', - 'description' => 'Force an user to link an Discord Account before creating a server / buying credits.', - ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::USER:FORCE_DISCORD_VERIFICATION', +// ], [ +// 'value' => 'false', +// 'type' => 'boolean', +// 'description' => 'Force an user to link an Discord Account before creating a server / buying credits.', +// ]); - //disable ip check on register - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:REGISTER_IP_CHECK', - ], [ - 'value' => 'true', - 'type' => 'boolean', - 'description' => 'Prevent users from making multiple accounts using the same IP address', - ]); +// //disable ip check on register +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:REGISTER_IP_CHECK', +// ], [ +// 'value' => 'true', +// 'type' => 'boolean', +// 'description' => 'Prevent users from making multiple accounts using the same IP address', +// ]); - //per_page on allocations request - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SERVER:ALLOCATION_LIMIT', - ], [ - 'value' => '200', - 'type' => 'integer', - 'description' => 'The maximum amount of allocations to pull per node for automatic deployment, if more allocations are being used than this limit is set to, no new servers can be created!', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', - ], [ - 'value' => '0', - 'type' => 'integer', - 'description' => 'The minimum amount of credits user has to have to create a server. Can be overridden by package limits.' - ]); +// //per_page on allocations request +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SERVER:ALLOCATION_LIMIT', +// ], [ +// 'value' => '200', +// 'type' => 'integer', +// 'description' => 'The maximum amount of allocations to pull per node for automatic deployment, if more allocations are being used than this limit is set to, no new servers can be created!', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', +// ], [ +// 'value' => '0', +// 'type' => 'integer', +// 'description' => 'The minimum amount of credits user has to have to create a server. Can be overridden by package limits.' +// ]); - //credits display name - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME', - ], [ - 'value' => 'Credits', - 'type' => 'string', - 'description' => 'The display name of your currency.', - ]); +// //credits display name +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME', +// ], [ +// 'value' => 'Credits', +// 'type' => 'string', +// 'description' => 'The display name of your currency.', +// ]); - //credits display name - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:SERVER_CREATE_CHARGE_FIRST_HOUR', - ], [ - 'value' => 'true', - 'type' => 'boolean', - 'description' => 'Charges the first hour worth of credits upon creating a server.', - ]); - //sales tax - Settings::firstOrCreate([ - 'key' => 'SETTINGS::PAYMENTS:SALES_TAX', - ], [ - 'value' => '0', - 'type' => 'integer', - 'description' => 'The %-value of tax that will be added to the product price on checkout.', - ]); - //Invoices enabled - Settings::firstOrCreate([ - 'key' => 'SETTINGS::INVOICE:ENABLED', - ], [ - 'value' => 'false', - 'type' => 'boolean', - 'description' => 'Enables or disables the invoice feature for payments.', - ]); - //Invoice company name - Settings::firstOrCreate([ - 'key' => 'SETTINGS::INVOICE:COMPANY_NAME', - ], [ - 'value' => '', - 'type' => 'string', - 'description' => 'The name of the Company on the Invoices.', - ]); - //Invoice company address - Settings::firstOrCreate([ - 'key' => 'SETTINGS::INVOICE:COMPANY_ADDRESS', - ], [ - 'value' => '', - 'type' => 'string', - 'description' => 'The address of the Company on the Invoices.', - ]); - //Invoice company phone - Settings::firstOrCreate([ - 'key' => 'SETTINGS::INVOICE:COMPANY_PHONE', - ], [ - 'value' => '', - 'type' => 'string', - 'description' => 'The phone number of the Company on the Invoices.', - ]); +// //credits display name +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:SERVER_CREATE_CHARGE_FIRST_HOUR', +// ], [ +// 'value' => 'true', +// 'type' => 'boolean', +// 'description' => 'Charges the first hour worth of credits upon creating a server.', +// ]); +// //sales tax +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::PAYMENTS:SALES_TAX', +// ], [ +// 'value' => '0', +// 'type' => 'integer', +// 'description' => 'The %-value of tax that will be added to the product price on checkout.', +// ]); +// //Invoices enabled +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::INVOICE:ENABLED', +// ], [ +// 'value' => 'false', +// 'type' => 'boolean', +// 'description' => 'Enables or disables the invoice feature for payments.', +// ]); +// //Invoice company name +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::INVOICE:COMPANY_NAME', +// ], [ +// 'value' => '', +// 'type' => 'string', +// 'description' => 'The name of the Company on the Invoices.', +// ]); +// //Invoice company address +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::INVOICE:COMPANY_ADDRESS', +// ], [ +// 'value' => '', +// 'type' => 'string', +// 'description' => 'The address of the Company on the Invoices.', +// ]); +// //Invoice company phone +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::INVOICE:COMPANY_PHONE', +// ], [ +// 'value' => '', +// 'type' => 'string', +// 'description' => 'The phone number of the Company on the Invoices.', +// ]); - //Invoice company mail - Settings::firstOrCreate([ - 'key' => 'SETTINGS::INVOICE:COMPANY_MAIL', - ], [ - 'value' => '', - 'type' => 'string', - 'description' => 'The email address of the Company on the Invoices.', - ]); +// //Invoice company mail +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::INVOICE:COMPANY_MAIL', +// ], [ +// 'value' => '', +// 'type' => 'string', +// 'description' => 'The email address of the Company on the Invoices.', +// ]); - //Invoice VAT - Settings::firstOrCreate([ - 'key' => 'SETTINGS::INVOICE:COMPANY_VAT', - ], [ - 'value' => '', - 'type' => 'string', - 'description' => 'The VAT-Number of the Company on the Invoices.', - ]); +// //Invoice VAT +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::INVOICE:COMPANY_VAT', +// ], [ +// 'value' => '', +// 'type' => 'string', +// 'description' => 'The VAT-Number of the Company on the Invoices.', +// ]); - //Invoice Website - Settings::firstOrCreate([ - 'key' => 'SETTINGS::INVOICE:COMPANY_WEBSITE', - ], [ - 'value' => '', - 'type' => 'string', - 'description' => 'The Website of the Company on the Invoices.', - ]); +// //Invoice Website +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::INVOICE:COMPANY_WEBSITE', +// ], [ +// 'value' => '', +// 'type' => 'string', +// 'description' => 'The Website of the Company on the Invoices.', +// ]); - //Invoice Website - Settings::firstOrCreate([ - 'key' => 'SETTINGS::INVOICE:PREFIX', - ], [ - 'value' => 'INV', - 'type' => 'string', - 'description' => 'The invoice prefix.', - ]); +// //Invoice Website +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::INVOICE:PREFIX', +// ], [ +// 'value' => 'INV', +// 'type' => 'string', +// 'description' => 'The invoice prefix.', +// ]); - //Locale - Settings::firstOrCreate([ - 'key' => 'SETTINGS::LOCALE:DEFAULT', - ], [ - 'value' => 'en', - 'type' => 'string', - 'description' => 'The default dashboard language.', - ]); - //Dynamic locale - Settings::firstOrCreate([ - 'key' => 'SETTINGS::LOCALE:DYNAMIC', - ], [ - 'value' => 'false', - 'type' => 'boolean', - 'description' => 'If this is true, the Language will change to the Clients browserlanguage or default.', - ]); - //User can change Locale - Settings::firstOrCreate([ - 'key' => 'SETTINGS::LOCALE:CLIENTS_CAN_CHANGE', - ], [ - 'value' => 'false', - 'type' => 'boolean', - 'description' => 'If this is true, the clients will be able to change their Locale.', - ]); - //Locale - Settings::firstOrCreate([ - 'key' => 'SETTINGS::LOCALE:AVAILABLE', - ], [ - 'value' => 'en', - 'type' => 'string', - 'description' => 'The available languages.', - ]); - //Locale - Settings::firstOrCreate([ - 'key' => 'SETTINGS::LOCALE:DATATABLES', - ], [ - 'value' => 'en-gb', - 'type' => 'string', - 'description' => 'The Language of the Datatables. Grab the Language-Codes from here https://datatables.net/plug-ins/i18n/', - ]); +// //Locale +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::LOCALE:DEFAULT', +// ], [ +// 'value' => 'en', +// 'type' => 'string', +// 'description' => 'The default dashboard language.', +// ]); +// //Dynamic locale +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::LOCALE:DYNAMIC', +// ], [ +// 'value' => 'false', +// 'type' => 'boolean', +// 'description' => 'If this is true, the Language will change to the Clients browserlanguage or default.', +// ]); +// //User can change Locale +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::LOCALE:CLIENTS_CAN_CHANGE', +// ], [ +// 'value' => 'false', +// 'type' => 'boolean', +// 'description' => 'If this is true, the clients will be able to change their Locale.', +// ]); +// //Locale +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::LOCALE:AVAILABLE', +// ], [ +// 'value' => 'en', +// 'type' => 'string', +// 'description' => 'The available languages.', +// ]); +// //Locale +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::LOCALE:DATATABLES', +// ], [ +// 'value' => 'en-gb', +// 'type' => 'string', +// 'description' => 'The Language of the Datatables. Grab the Language-Codes from here https://datatables.net/plug-ins/i18n/', +// ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::PAYMENTS:PAYPAL:SECRET', - ], [ - 'value' => env('PAYPAL_SECRET', ''), - 'type' => 'string', - 'description' => 'Your PayPal Secret-Key (https://developer.paypal.com/docs/integration/direct/rest/).', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID', - ], [ - 'value' => env('PAYPAL_CLIENT_ID', ''), - 'type' => 'string', - 'description' => 'Your PayPal Client_ID.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET', - ], [ - 'value' => env('PAYPAL_SANDBOX_SECRET', ''), - 'type' => 'string', - 'description' => 'Your PayPal SANDBOX Secret-Key used for testing.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID', - ], [ - 'value' => env('PAYPAL_SANDBOX_CLIENT_ID', ''), - 'type' => 'string', - 'description' => 'Your PayPal SANDBOX Client-ID used for testing.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::PAYMENTS:STRIPE:SECRET', - ], [ - 'value' => env('STRIPE_SECRET', ''), - 'type' => 'string', - 'description' => 'Your Stripe Secret-Key (https://dashboard.stripe.com/account/apikeys).', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET', - ], [ - 'value' => env('STRIPE_ENDPOINT_SECRET', ''), - 'type' => 'string', - 'description' => 'Your Stripe endpoint secret-key.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::PAYMENTS:STRIPE:TEST_SECRET', - ], [ - 'value' => env('STRIPE_TEST_SECRET', ''), - 'type' => 'string', - 'description' => 'Your Stripe test secret-key.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET', - ], [ - 'value' => env('STRIPE_ENDPOINT_TEST_SECRET', ''), - 'type' => 'string', - 'description' => 'Your Stripe endpoint test secret-key.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::PAYMENTS:STRIPE:METHODS', - ], [ - 'value' => env('STRIPE_METHODS', 'card,sepa_debit'), - 'type' => 'string', - 'description' => 'Comma seperated list of payment methods that are enabled (https://stripe.com/docs/payments/payment-methods/integration-options).', - ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::PAYMENTS:PAYPAL:SECRET', +// ], [ +// 'value' => env('PAYPAL_SECRET', ''), +// 'type' => 'string', +// 'description' => 'Your PayPal Secret-Key (https://developer.paypal.com/docs/integration/direct/rest/).', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID', +// ], [ +// 'value' => env('PAYPAL_CLIENT_ID', ''), +// 'type' => 'string', +// 'description' => 'Your PayPal Client_ID.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET', +// ], [ +// 'value' => env('PAYPAL_SANDBOX_SECRET', ''), +// 'type' => 'string', +// 'description' => 'Your PayPal SANDBOX Secret-Key used for testing.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID', +// ], [ +// 'value' => env('PAYPAL_SANDBOX_CLIENT_ID', ''), +// 'type' => 'string', +// 'description' => 'Your PayPal SANDBOX Client-ID used for testing.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::PAYMENTS:STRIPE:SECRET', +// ], [ +// 'value' => env('STRIPE_SECRET', ''), +// 'type' => 'string', +// 'description' => 'Your Stripe Secret-Key (https://dashboard.stripe.com/account/apikeys).', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET', +// ], [ +// 'value' => env('STRIPE_ENDPOINT_SECRET', ''), +// 'type' => 'string', +// 'description' => 'Your Stripe endpoint secret-key.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::PAYMENTS:STRIPE:TEST_SECRET', +// ], [ +// 'value' => env('STRIPE_TEST_SECRET', ''), +// 'type' => 'string', +// 'description' => 'Your Stripe test secret-key.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET', +// ], [ +// 'value' => env('STRIPE_ENDPOINT_TEST_SECRET', ''), +// 'type' => 'string', +// 'description' => 'Your Stripe endpoint test secret-key.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::PAYMENTS:STRIPE:METHODS', +// ], [ +// 'value' => env('STRIPE_METHODS', 'card,sepa_debit'), +// 'type' => 'string', +// 'description' => 'Comma seperated list of payment methods that are enabled (https://stripe.com/docs/payments/payment-methods/integration-options).', +// ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::DISCORD:CLIENT_ID', - ], [ - 'value' => env('DISCORD_CLIENT_ID', ''), - 'type' => 'string', - 'description' => 'Discord API Credentials (https://discordapp.com/developers/applications/).', - ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::DISCORD:CLIENT_ID', +// ], [ +// 'value' => env('DISCORD_CLIENT_ID', ''), +// 'type' => 'string', +// 'description' => 'Discord API Credentials (https://discordapp.com/developers/applications/).', +// ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::DISCORD:CLIENT_SECRET', - ], [ - 'value' => env('DISCORD_CLIENT_SECRET', ''), - 'type' => 'string', - 'description' => 'Discord API Credentials (https://discordapp.com/developers/applications/).', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::DISCORD:BOT_TOKEN', - ], [ - 'value' => env('DISCORD_BOT_TOKEN', ''), - 'type' => 'string', - 'description' => 'Discord API Credentials (https://discordapp.com/developers/applications/).', - ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::DISCORD:CLIENT_SECRET', +// ], [ +// 'value' => env('DISCORD_CLIENT_SECRET', ''), +// 'type' => 'string', +// 'description' => 'Discord API Credentials (https://discordapp.com/developers/applications/).', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::DISCORD:BOT_TOKEN', +// ], [ +// 'value' => env('DISCORD_BOT_TOKEN', ''), +// 'type' => 'string', +// 'description' => 'Discord API Credentials (https://discordapp.com/developers/applications/).', +// ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::DISCORD:GUILD_ID', - ], [ - 'value' => env('DISCORD_GUILD_ID', ''), - 'type' => 'string', - 'description' => 'Discord API Credentials (https://discordapp.com/developers/applications/).', - ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::DISCORD:GUILD_ID', +// ], [ +// 'value' => env('DISCORD_GUILD_ID', ''), +// 'type' => 'string', +// 'description' => 'Discord API Credentials (https://discordapp.com/developers/applications/).', +// ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::DISCORD:ROLE_ID', - ], [ - 'value' => env('DISCORD_ROLE_ID', ''), - 'type' => 'string', - 'description' => 'Discord role that will be assigned to users when they register.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::DISCORD:INVITE_URL', - ], [ - 'value' => env('DISCORD_INVITE_URL', ''), - 'type' => 'string', - 'description' => 'The invite URL to your Discord Server.', - ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::DISCORD:ROLE_ID', +// ], [ +// 'value' => env('DISCORD_ROLE_ID', ''), +// 'type' => 'string', +// 'description' => 'Discord role that will be assigned to users when they register.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::DISCORD:INVITE_URL', +// ], [ +// 'value' => env('DISCORD_INVITE_URL', ''), +// 'type' => 'string', +// 'description' => 'The invite URL to your Discord Server.', +// ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:PTERODACTYL:TOKEN', - ], [ - 'value' => env('PTERODACTYL_TOKEN', ''), - 'type' => 'string', - 'description' => 'Admin API Token from Pterodactyl Panel - necessary for the Panel to work. The Key needs all read&write permissions!', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:PTERODACTYL:URL', - ], [ - 'value' => env('PTERODACTYL_URL', ''), - 'type' => 'string', - 'description' => 'The URL to your Pterodactyl Panel. Must not end with a / ', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT', - ], [ - 'value' => 200, - 'type' => 'integer', - 'description' => 'The Pterodactyl API perPage limit. It is necessary to set it higher than your server count.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::MISC:PHPMYADMIN:URL', - ], [ - 'value' => env('PHPMYADMIN_URL', ''), - 'type' => 'string', - 'description' => 'The URL to your PHPMYADMIN Panel. Must not end with a /, remove to remove database button', - ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:PTERODACTYL:TOKEN', +// ], [ +// 'value' => env('PTERODACTYL_TOKEN', ''), +// 'type' => 'string', +// 'description' => 'Admin API Token from Pterodactyl Panel - necessary for the Panel to work. The Key needs all read&write permissions!', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:PTERODACTYL:URL', +// ], [ +// 'value' => env('PTERODACTYL_URL', ''), +// 'type' => 'string', +// 'description' => 'The URL to your Pterodactyl Panel. Must not end with a / ', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT', +// ], [ +// 'value' => 200, +// 'type' => 'integer', +// 'description' => 'The Pterodactyl API perPage limit. It is necessary to set it higher than your server count.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::MISC:PHPMYADMIN:URL', +// ], [ +// 'value' => env('PHPMYADMIN_URL', ''), +// 'type' => 'string', +// 'description' => 'The URL to your PHPMYADMIN Panel. Must not end with a /, remove to remove database button', +// ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::RECAPTCHA:SITE_KEY', - ], [ - 'value' => env('RECAPTCHA_SITE_KEY', '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'), - 'type' => 'string', - 'description' => 'Google Recaptcha API Credentials (https://www.google.com/recaptcha/admin) - reCaptcha V2 (not v3)', - ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::RECAPTCHA:SITE_KEY', +// ], [ +// 'value' => env('RECAPTCHA_SITE_KEY', '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'), +// 'type' => 'string', +// 'description' => 'Google Recaptcha API Credentials (https://www.google.com/recaptcha/admin) - reCaptcha V2 (not v3)', +// ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::RECAPTCHA:SECRET_KEY', - ], [ - 'value' => env('RECAPTCHA_SECRET_KEY', '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'), - 'type' => 'string', - 'description' => 'Google Recaptcha API Credentials (https://www.google.com/recaptcha/admin) - reCaptcha V2 (not v3)', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::RECAPTCHA:ENABLED', - ], [ - 'value' => 'true', - 'type' => 'boolean', - 'description' => 'Enables or disables the ReCaptcha feature on the registration/login page.', +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::RECAPTCHA:SECRET_KEY', +// ], [ +// 'value' => env('RECAPTCHA_SECRET_KEY', '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'), +// 'type' => 'string', +// 'description' => 'Google Recaptcha API Credentials (https://www.google.com/recaptcha/admin) - reCaptcha V2 (not v3)', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::RECAPTCHA:ENABLED', +// ], [ +// 'value' => 'true', +// 'type' => 'boolean', +// 'description' => 'Enables or disables the ReCaptcha feature on the registration/login page.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::MAIL:MAILER', - ], [ - 'value' => env('MAIL_MAILER', 'smtp'), - 'type' => 'string', - 'description' => 'Selected Mailer (smtp, mailgun, sendgrid, mailtrap).', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::MAIL:HOST', - ], [ - 'value' => env('MAIL_HOST', 'localhost'), - 'type' => 'string', - 'description' => 'Mailer Host Address.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::MAIL:PORT', - ], [ - 'value' => env('MAIL_PORT', '25'), - 'type' => 'string', - 'description' => 'Mailer Server Port.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::MAIL:USERNAME', - ], [ - 'value' => env('MAIL_USERNAME', ''), - 'type' => 'string', - 'description' => 'Mailer Username.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::MAIL:PASSWORD', - ], [ - 'value' => env('MAIL_PASSWORD', ''), - 'type' => 'string', - 'description' => 'Mailer Password.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::MAIL:ENCRYPTION', - ], [ - 'value' => env('MAIL_ENCRYPTION', 'tls'), - 'type' => 'string', - 'description' => 'Mailer Encryption (tls, ssl).', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::MAIL:FROM_ADDRESS', - ], [ - 'value' => env('MAIL_FROM_ADDRESS', ''), - 'type' => 'string', - 'description' => 'Mailer From Address.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::MAIL:FROM_NAME', - ], [ - 'value' => env('APP_NAME', 'Controlpanel'), - 'type' => 'string', - 'description' => 'Mailer From Name.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::REFERRAL::ENABLED', - ], [ - 'value' => 'false', - 'type' => 'string', - 'description' => 'Enable or disable the referral system.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION', - ], [ - 'value' => 'false', - 'type' => 'string', - 'description' => 'Whether referrals get percentage commission only on first purchase or on every purchase', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::REFERRAL::REWARD', - ], [ - 'value' => 100, - 'type' => 'integer', - 'description' => 'Credit reward a user should receive when a user registers with his referral code', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::REFERRAL::ALLOWED', - ], [ - 'value' => 'client', - 'type' => 'string', - 'description' => 'Who should be allowed to to use the referral code. all/client', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::REFERRAL:MODE', - ], [ - 'value' => 'sign-up', - 'type' => 'string', - 'description' => 'Whether referrals get Credits on User-Registration or if a User buys credits', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::REFERRAL:PERCENTAGE', - ], [ - 'value' => 100, - 'type' => 'integer', - 'description' => 'The Percentage value a referred user gets.', - ]); +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::MAIL:MAILER', +// ], [ +// 'value' => env('MAIL_MAILER', 'smtp'), +// 'type' => 'string', +// 'description' => 'Selected Mailer (smtp, mailgun, sendgrid, mailtrap).', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::MAIL:HOST', +// ], [ +// 'value' => env('MAIL_HOST', 'localhost'), +// 'type' => 'string', +// 'description' => 'Mailer Host Address.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::MAIL:PORT', +// ], [ +// 'value' => env('MAIL_PORT', '25'), +// 'type' => 'string', +// 'description' => 'Mailer Server Port.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::MAIL:USERNAME', +// ], [ +// 'value' => env('MAIL_USERNAME', ''), +// 'type' => 'string', +// 'description' => 'Mailer Username.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::MAIL:PASSWORD', +// ], [ +// 'value' => env('MAIL_PASSWORD', ''), +// 'type' => 'string', +// 'description' => 'Mailer Password.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::MAIL:ENCRYPTION', +// ], [ +// 'value' => env('MAIL_ENCRYPTION', 'tls'), +// 'type' => 'string', +// 'description' => 'Mailer Encryption (tls, ssl).', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::MAIL:FROM_ADDRESS', +// ], [ +// 'value' => env('MAIL_FROM_ADDRESS', ''), +// 'type' => 'string', +// 'description' => 'Mailer From Address.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::MAIL:FROM_NAME', +// ], [ +// 'value' => env('APP_NAME', 'Controlpanel'), +// 'type' => 'string', +// 'description' => 'Mailer From Name.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::REFERRAL::ENABLED', +// ], [ +// 'value' => 'false', +// 'type' => 'string', +// 'description' => 'Enable or disable the referral system.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION', +// ], [ +// 'value' => 'false', +// 'type' => 'string', +// 'description' => 'Whether referrals get percentage commission only on first purchase or on every purchase', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::REFERRAL::REWARD', +// ], [ +// 'value' => 100, +// 'type' => 'integer', +// 'description' => 'Credit reward a user should receive when a user registers with his referral code', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::REFERRAL::ALLOWED', +// ], [ +// 'value' => 'client', +// 'type' => 'string', +// 'description' => 'Who should be allowed to to use the referral code. all/client', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::REFERRAL:MODE', +// ], [ +// 'value' => 'sign-up', +// 'type' => 'string', +// 'description' => 'Whether referrals get Credits on User-Registration or if a User buys credits', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::REFERRAL:PERCENTAGE', +// ], [ +// 'value' => 100, +// 'type' => 'integer', +// 'description' => 'The Percentage value a referred user gets.', +// ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN', - ], [ - 'value' => '', - 'type' => 'string', - 'description' => 'The Client API Key of an Pterodactyl Admin Account.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:ENABLE_UPGRADE', - ], [ - 'value' => 'false', - 'type' => 'boolean', - 'description' => 'Enables the updgrade/downgrade feature for servers.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS', - ], [ - 'value' => 'true', - 'type' => 'boolean', - 'description' => 'Enable creation of new servers', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:CREATION_OF_NEW_USERS', - ], [ - 'value' => 'true', - 'type' => 'boolean', - 'description' => 'Enable creation of new users', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:SHOW_IMPRINT', - ], [ +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN', +// ], [ +// 'value' => '', +// 'type' => 'string', +// 'description' => 'The Client API Key of an Pterodactyl Admin Account.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:ENABLE_UPGRADE', +// ], [ +// 'value' => 'false', +// 'type' => 'boolean', +// 'description' => 'Enables the updgrade/downgrade feature for servers.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS', +// ], [ +// 'value' => 'true', +// 'type' => 'boolean', +// 'description' => 'Enable creation of new servers', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:CREATION_OF_NEW_USERS', +// ], [ +// 'value' => 'true', +// 'type' => 'boolean', +// 'description' => 'Enable creation of new users', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:SHOW_IMPRINT', +// ], [ - 'value' => "false", - 'type' => 'boolean', - 'description' => 'Enable imprint in footer.' +// 'value' => "false", +// 'type' => 'boolean', +// 'description' => 'Enable imprint in footer.' - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:SHOW_PRIVACY', - ], [ +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:SHOW_PRIVACY', +// ], [ - 'value' => "false", - 'type' => 'boolean', - 'description' => 'Enable privacy policy in footer.' +// 'value' => "false", +// 'type' => 'boolean', +// 'description' => 'Enable privacy policy in footer.' - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:SHOW_TOS', - ], [ - 'value' => 'false', - 'type' => 'boolean', - 'description' => 'Enable Terms of Service in footer.', - ]); +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:SHOW_TOS', +// ], [ +// 'value' => 'false', +// 'type' => 'boolean', +// 'description' => 'Enable Terms of Service in footer.', +// ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:ALERT_ENABLED', - ], [ - 'value' => 'false', - 'type' => 'boolean', - 'description' => 'Enable Alerts on Homepage.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:ALERT_TYPE', - ], [ - 'value' => 'dark', - 'type' => 'text', - 'description' => 'Changes the Color of the Alert.', - ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:ALERT_ENABLED', +// ], [ +// 'value' => 'false', +// 'type' => 'boolean', +// 'description' => 'Enable Alerts on Homepage.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:ALERT_TYPE', +// ], [ +// 'value' => 'dark', +// 'type' => 'text', +// 'description' => 'Changes the Color of the Alert.', +// ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:ALERT_MESSAGE', - ], [ - 'value' => '', - 'type' => 'text', - 'description' => 'Changes the Content the Alert.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:THEME', - ], [ - 'value' => 'default', - 'type' => 'text', - 'description' => 'Current active theme.', - ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:ALERT_MESSAGE', +// ], [ +// 'value' => '', +// 'type' => 'text', +// 'description' => 'Changes the Content the Alert.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:THEME', +// ], [ +// 'value' => 'default', +// 'type' => 'text', +// 'description' => 'Current active theme.', +// ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:USEFULLINKS_ENABLED', - ], [ - 'value' => 'true', - 'type' => 'boolean', - 'description' => 'Enable Useful Links on Homepage.', - ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:USEFULLINKS_ENABLED', +// ], [ +// 'value' => 'true', +// 'type' => 'boolean', +// 'description' => 'Enable Useful Links on Homepage.', +// ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:MOTD_ENABLED', - ], [ - 'value' => 'true', - 'type' => 'boolean', - 'description' => 'Enable MOTD on Homepage.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:MOTD_MESSAGE', - ], [ - 'value' => '

Controlpanel.gg

-

Thank you for using our Software

-

If you have any questions, make sure to join our Discord

-

(you can change this message in the Settings )

', - 'type' => 'text', - 'description' => 'MOTD Message.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:SEO_TITLE', - ], [ - 'value' => 'Controlpanel.gg', - 'type' => 'text', - 'description' => 'The SEO Title.', - ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:MOTD_ENABLED', +// ], [ +// 'value' => 'true', +// 'type' => 'boolean', +// 'description' => 'Enable MOTD on Homepage.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:MOTD_MESSAGE', +// ], [ +// 'value' => '

Controlpanel.gg

+//

Thank you for using our Software

+//

If you have any questions, make sure to join our Discord

+//

(you can change this message in the Settings )

', +// 'type' => 'text', +// 'description' => 'MOTD Message.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:SEO_TITLE', +// ], [ +// 'value' => 'Controlpanel.gg', +// 'type' => 'text', +// 'description' => 'The SEO Title.', +// ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::SYSTEM:SEO_DESCRIPTION', - ], [ - 'value' => 'Billing software for Pterodactyl Dashboard!', - 'type' => 'text', - 'description' => 'SEO Description.', - ]); - Settings::firstOrCreate([ - 'key' => 'SETTINGS::TICKET:NOTIFY', - ], [ - 'value' => 'all', - 'type' => 'text', - 'description' => 'Who will get a Email Notifcation on new Tickets.', - ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::SYSTEM:SEO_DESCRIPTION', +// ], [ +// 'value' => 'Billing software for Pterodactyl Dashboard!', +// 'type' => 'text', +// 'description' => 'SEO Description.', +// ]); +// Settings::firstOrCreate([ +// 'key' => 'SETTINGS::TICKET:NOTIFY', +// ], [ +// 'value' => 'all', +// 'type' => 'text', +// 'description' => 'Who will get a Email Notifcation on new Tickets.', +// ]); } } diff --git a/database/settings/2023_02_01_164731_create_general_settings.php b/database/settings/2023_02_01_164731_create_general_settings.php new file mode 100644 index 00000000..ff3eb1cf --- /dev/null +++ b/database/settings/2023_02_01_164731_create_general_settings.php @@ -0,0 +1,26 @@ +migrator->add('general.credits_display_name', ($this->getOldValue('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME') != null) ?: 'Credits'); + $this->migrator->add('general.register_ip_check', ($this->getOldValue("SETTINGS::SYSTEM:REGISTER_IP_CHECK") != null) ?: true); + $this->migrator->add('general.initial_user_credits', ($this->getOldValue("SETTINGS::USER:INITIAL_CREDITS") != null) ?: 250); + $this->migrator->add('general.initial_server_limit', ($this->getOldValue("SETTINGS::USER:INITIAL_SERVER_LIMIT") != null) ?: 1); + $this->migrator->add('general.main_site', ""); + } + + public function getOldValue(string $key) + { + if (DB::table('settings_old')->exists()) { + return DB::table('settings_old')->where('key', '=', $key)->get(['value']); + } + + return null; + } +} \ No newline at end of file diff --git a/database/settings/2023_02_01_181334_create_pterodactyl_settings.php b/database/settings/2023_02_01_181334_create_pterodactyl_settings.php new file mode 100644 index 00000000..6bc39486 --- /dev/null +++ b/database/settings/2023_02_01_181334_create_pterodactyl_settings.php @@ -0,0 +1,25 @@ +migrator->add('pterodactyl.admin_token', ($this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:TOKEN') != null) ?: env('PTERODACTYL_TOKEN', '')); + $this->migrator->add('pterodactyl.user_token', ($this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN') != null) ?: ''); + $this->migrator->add('pterodactyl.panel_url', ($this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:URL') != null) ?: env('PTERODACTYL_URL', '')); + $this->migrator->add('pterodactyl.per_page_limit', ($this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT') != null) ?: 200); + } + + public function getOldValue(string $key) + { + if (DB::table('settings_old')->exists()) { + return DB::table('settings_old')->where('key', '=', $key)->get(['value']); + } + + return null; + } +} \ No newline at end of file diff --git a/database/settings/2023_02_01_181453_create_mail_settings.php b/database/settings/2023_02_01_181453_create_mail_settings.php new file mode 100644 index 00000000..7ba84bc1 --- /dev/null +++ b/database/settings/2023_02_01_181453_create_mail_settings.php @@ -0,0 +1,30 @@ +migrator->add('mail.mail_host', ($this->getOldValue('SETTINGS::MAIL:HOST') != null) ?: ''); + $this->migrator->add('mail.mail_port', ($this->getOldValue('SETTINGS::MAIL:PORT') != null) ?: 'mailhog'); + $this->migrator->add('mail.mail_username', ($this->getOldValue('SETTINGS::MAIL:USERNAME') != null) ?: null); + $this->migrator->add('mail.mail_password', ($this->getOldValue('SETTINGS::MAIL:PASSWORD') != null) ?: null); + $this->migrator->add('mail.mail_encryption', ($this->getOldValue('SETTINGS::MAIL:ENCRYPTION') != null) ?: null); + $this->migrator->add('mail.mail_from_address', ($this->getOldValue('SETTINGS::MAIL:FROM_ADDRESS') != null) ?: null); + $this->migrator->add('mail.mail_from_name', ($this->getOldValue('SETTINGS::MAIL:FROM_NAME') != null) ?: 'ControlPanel.gg'); + $this->migrator->add('mail.mail_mailer', ($this->getOldValue('SETTINGS::MAIL:MAILER') != null) ?: 'smtp'); + $this->migrator->add('mail.mail_enabled', true); + } + + public function getOldValue(string $key) + { + if (DB::table('settings_old')->exists()) { + return DB::table('settings_old')->where('key', '=', $key)->get(['value']); + } + + return null; + } +} \ No newline at end of file diff --git a/database/settings/2023_02_01_181925_create_user_settings.php b/database/settings/2023_02_01_181925_create_user_settings.php new file mode 100644 index 00000000..48cdb353 --- /dev/null +++ b/database/settings/2023_02_01_181925_create_user_settings.php @@ -0,0 +1,31 @@ +migrator->add('user.credits_reward_after_verify_discord', ($this->getOldValue('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD') != null) ?: 250); + $this->migrator->add('user.credits_reward_after_verify_email', ($this->getOldValue('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL') != null) ?: 250); + $this->migrator->add('user.force_discord_verification', ($this->getOldValue('SETTINGS::USER:FORCE_DISCORD_VERIFICATION') != null) ?: false); + $this->migrator->add('user.force_email_verification', ($this->getOldValue('SETTINGS::USER:FORCE_EMAIL_VERIFICATION') != null) ?: false); + $this->migrator->add('user.initial_credits', ($this->getOldValue('SETTINGS::USER:INITIAL_CREDITS') != null) ?: 250); + $this->migrator->add('user.initial_server_limit', ($this->getOldValue('SETTINGS::USER:INITIAL_SERVER_LIMIT') != null) ?: 1); + $this->migrator->add('user.min_credits_to_make_server', ($this->getOldValue('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER') != null) ?: 50); + $this->migrator->add('user.server_limit_after_irl_purchase', ($this->getOldValue('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') != null) ?: 10); + $this->migrator->add('user.server_limit_after_verify_discord', ($this->getOldValue('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD') != null) ?: 2); + $this->migrator->add('user.server_limit_after_verify_email', ($this->getOldValue('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL') != null) ?: 2); + } + + public function getOldValue(string $key) + { + if (DB::table('settings_old')->exists()) { + return DB::table('settings_old')->where('key', '=', $key)->get(['value']); + } + + return null; + } +} \ No newline at end of file diff --git a/database/settings/2023_02_01_181950_create_server_settings.php b/database/settings/2023_02_01_181950_create_server_settings.php new file mode 100644 index 00000000..354a93ec --- /dev/null +++ b/database/settings/2023_02_01_181950_create_server_settings.php @@ -0,0 +1,22 @@ +migrator->add('server.allocation_limit', ($this->getOldValue('SETTINGS::SERVER:ALLOCATION_LIMIT') != null) ?: 200); + } + + public function getOldValue(string $key) + { + if (DB::table('settings_old')->exists()) { + return DB::table('settings_old')->where('key', '=', $key)->get(['value']); + } + + return null; + } +} \ No newline at end of file diff --git a/database/settings/2023_02_01_182021_create_invoice_settings.php b/database/settings/2023_02_01_182021_create_invoice_settings.php new file mode 100644 index 00000000..0630495e --- /dev/null +++ b/database/settings/2023_02_01_182021_create_invoice_settings.php @@ -0,0 +1,29 @@ +migrator->add('invoice.company_address', ($this->getOldValue('SETTINGS::INVOICE:COMPANY_ADDRESS') != null) ?: null); + $this->migrator->add('invoice.company_mail', ($this->getOldValue('SETTINGS::INVOICE:COMPANY_MAIL') != null) ?: null); + $this->migrator->add('invoice.company_name', ($this->getOldValue('SETTINGS::INVOICE:COMPANY_NAME') != null) ?: null); + $this->migrator->add('invoice.company_phone', ($this->getOldValue('SETTINGS::INVOICE:COMPANY_PHONE') != null) ?: null); + $this->migrator->add('invoice.company_vat', ($this->getOldValue('SETTINGS::INVOICE:COMPANY_VAT') != null) ?: null); + $this->migrator->add('invoice.company_website', ($this->getOldValue('SETTINGS::INVOICE:COMPANY_WEBSITE') != null) ?: null); + $this->migrator->add('invoice.enabled', ($this->getOldValue('SETTINGS::INVOICE:ENABLED') != null) ?: true); + $this->migrator->add('invoice.prefix', ($this->getOldValue('SETTINGS::INVOICE:PREFIX') != null) ?: 'INV'); + } + + public function getOldValue(string $key) + { + if (DB::table('settings_old')->exists()) { + return DB::table('settings_old')->where('key', '=', $key)->get(['value']); + } + + return null; + } +} \ No newline at end of file diff --git a/database/settings/2023_02_01_182043_create_discord_settings.php b/database/settings/2023_02_01_182043_create_discord_settings.php new file mode 100644 index 00000000..34f06141 --- /dev/null +++ b/database/settings/2023_02_01_182043_create_discord_settings.php @@ -0,0 +1,27 @@ +migrator->add('discord.bot_token', ($this->getOldValue('SETTINGS::DISCORD:BOT_TOKEN') != null) ?: null); + $this->migrator->add('discord.client_id', ($this->getOldValue('SETTINGS::DISCORD:CLIENT_ID') != null) ?: null); + $this->migrator->add('discord.client_secret', ($this->getOldValue('SETTINGS::DISCORD:CLIENT_SECRET') != null) ?: null); + $this->migrator->add('discord.guild_id', ($this->getOldValue('SETTINGS::DISCORD:GUILD_ID') != null) ?: null); + $this->migrator->add('discord.invite_url', ($this->getOldValue('SETTINGS::DISCORD:INVITE_URL') != null) ?: null); + $this->migrator->add('discord.role_id', ($this->getOldValue('SETTINGS::DISCORD:ROLE_ID') != null) ?: null); + } + + public function getOldValue(string $key) + { + if (DB::table('settings_old')->exists()) { + return DB::table('settings_old')->where('key', '=', $key)->get(['value']); + } + + return null; + } +} \ No newline at end of file diff --git a/database/settings/2023_02_01_182108_create_locale_settings.php b/database/settings/2023_02_01_182108_create_locale_settings.php new file mode 100644 index 00000000..49c833c7 --- /dev/null +++ b/database/settings/2023_02_01_182108_create_locale_settings.php @@ -0,0 +1,26 @@ +migrator->add('locale.available', ($this->getOldValue('SETTINGS::LOCALE:AVAILABLE') != null) ?: ''); + $this->migrator->add('locale.clients_can_change', ($this->getOldValue('SETTINGS::LOCALE:CLIENTS_CAN_CHANGE') != null) ?: true); + $this->migrator->add('locale.datatables', ($this->getOldValue('SETTINGS::LOCALE:DATATABLES') != null) ?: 'en-gb'); + $this->migrator->add('locale.default', ($this->getOldValue('SETTINGS::LOCALE:DEFAULT') != null) ?: 'en'); + $this->migrator->add('locale.dynamic', ($this->getOldValue('SETTINGS::LOCALE:DYNAMIC') != null) ?: false); + } + + public function getOldValue(string $key) + { + if (DB::table('settings_old')->exists()) { + return DB::table('settings_old')->where('key', '=', $key)->get(['value']); + } + + return null; + } +} \ No newline at end of file diff --git a/database/settings/2023_02_01_182135_create_referral_settings.php b/database/settings/2023_02_01_182135_create_referral_settings.php new file mode 100644 index 00000000..6d305604 --- /dev/null +++ b/database/settings/2023_02_01_182135_create_referral_settings.php @@ -0,0 +1,27 @@ +migrator->add('referral.allowed', ($this->getOldValue('SETTINGS::REFERRAL::ALLOWED') != null) ?: 'client'); + $this->migrator->add('referral.always_give_commission', ($this->getOldValue('SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION') != null) ?: false); + $this->migrator->add('referral.enabled', ($this->getOldValue('SETTINGS::REFERRAL::ENABLED') != null) ?: false); + $this->migrator->add('referral.reward', ($this->getOldValue('SETTINGS::REFERRAL::REWARD') != null) ?: 100); + $this->migrator->add('referral.mode', ($this->getOldValue('SETTINGS::REFERRAL:MODE') != null) ?: 'sign-up'); + $this->migrator->add('referral.percentage', ($this->getOldValue('SETTINGS::REFERRAL:PERCENTAGE') != null) ?: 100); + } + + public function getOldValue(string $key) + { + if (DB::table('settings_old')->exists()) { + return DB::table('settings_old')->where('key', '=', $key)->get(['value']); + } + + return null; + } +} \ No newline at end of file diff --git a/database/settings/2023_02_01_182158_create_website_settings.php b/database/settings/2023_02_01_182158_create_website_settings.php new file mode 100644 index 00000000..d164c3b4 --- /dev/null +++ b/database/settings/2023_02_01_182158_create_website_settings.php @@ -0,0 +1,22 @@ +migrator->add('website.', ($this->getOldValue('SETTINGS::') != null) ?: ''); + } + + public function getOldValue(string $key) + { + if (DB::table('settings_old')->exists()) { + return DB::table('settings_old')->where('key', '=', $key)->get(['value']); + } + + return null; + } +} \ No newline at end of file From ca0fae7bdb3e92131063b8d3f8a797b7e38af3eb Mon Sep 17 00:00:00 2001 From: Ferks-FK Date: Thu, 2 Feb 2023 15:08:34 +0000 Subject: [PATCH 003/120] Add missing keys --- .../2023_02_01_164731_create_general_settings.php | 11 +++++++++-- .../2023_02_01_181925_create_user_settings.php | 2 ++ .../2023_02_01_181950_create_server_settings.php | 2 ++ .../2023_02_01_182158_create_website_settings.php | 14 ++++++++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/database/settings/2023_02_01_164731_create_general_settings.php b/database/settings/2023_02_01_164731_create_general_settings.php index ff3eb1cf..d3e1238b 100644 --- a/database/settings/2023_02_01_164731_create_general_settings.php +++ b/database/settings/2023_02_01_164731_create_general_settings.php @@ -9,10 +9,17 @@ class CreateGeneralSettings extends SettingsMigration { // Get the user-set configuration values from the old table. $this->migrator->add('general.credits_display_name', ($this->getOldValue('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME') != null) ?: 'Credits'); - $this->migrator->add('general.register_ip_check', ($this->getOldValue("SETTINGS::SYSTEM:REGISTER_IP_CHECK") != null) ?: true); $this->migrator->add('general.initial_user_credits', ($this->getOldValue("SETTINGS::USER:INITIAL_CREDITS") != null) ?: 250); $this->migrator->add('general.initial_server_limit', ($this->getOldValue("SETTINGS::USER:INITIAL_SERVER_LIMIT") != null) ?: 1); - $this->migrator->add('general.main_site', ""); + $this->migrator->add('general.recaptcha_site_key', ($this->getOldValue("SETTINGS::RECAPTCHA:SITE_KEY") != null) ?: env('RECAPTCHA_SITE_KEY', '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI')); + $this->migrator->add('general.recaptcha_secret_key', ($this->getOldValue("SETTINGS::RECAPTCHA:SECRET_KEY") != null) ?: env('RECAPTCHA_SECRET_KEY', '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe')); + $this->migrator->add('general.recaptcha_enabled', ($this->getOldValue("SETTINGS::RECAPTCHA:ENABLED") != null) ?: true); + $this->migrator->add('general.phpmyadmin_url', ($this->getOldValue("SETTINGS::MISC:PHPMYADMIN:URL") != null) ?: env('PHPMYADMIN_URL', '')); + $this->migrator->add('general.alert_enabled', ($this->getOldValue("SETTINGS::SYSTEM:ALERT_ENABLED") != null) ?: false); + $this->migrator->add('general.alert_type', ($this->getOldValue("SETTINGS::SYSTEM:ALERT_TYPE") != null) ?: 'dark'); + $this->migrator->add('general.alert_message', ($this->getOldValue("SETTINGS::SYSTEM:ALERT_MESSAGE") != null) ?: ''); + $this->migrator->add('general.theme', ($this->getOldValue("SETTINGS::SYSTEM:THEME") != null) ?: 'default'); + $this->migrator->add('general.main_site', ''); } public function getOldValue(string $key) diff --git a/database/settings/2023_02_01_181925_create_user_settings.php b/database/settings/2023_02_01_181925_create_user_settings.php index 48cdb353..24ed7cea 100644 --- a/database/settings/2023_02_01_181925_create_user_settings.php +++ b/database/settings/2023_02_01_181925_create_user_settings.php @@ -18,6 +18,8 @@ class CreateUserSettings extends SettingsMigration $this->migrator->add('user.server_limit_after_irl_purchase', ($this->getOldValue('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') != null) ?: 10); $this->migrator->add('user.server_limit_after_verify_discord', ($this->getOldValue('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD') != null) ?: 2); $this->migrator->add('user.server_limit_after_verify_email', ($this->getOldValue('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL') != null) ?: 2); + $this->migrator->add('user.register_ip_check', ($this->getOldValue("SETTINGS::SYSTEM:REGISTER_IP_CHECK") != null) ?: true); + $this->migrator->add('user.creation_enabled', ($this->getOldValue("SETTINGS::SYSTEM:CREATION_OF_NEW_USERS") != null) ?: true); } public function getOldValue(string $key) diff --git a/database/settings/2023_02_01_181950_create_server_settings.php b/database/settings/2023_02_01_181950_create_server_settings.php index 354a93ec..6144170f 100644 --- a/database/settings/2023_02_01_181950_create_server_settings.php +++ b/database/settings/2023_02_01_181950_create_server_settings.php @@ -9,6 +9,8 @@ class CreateServerSettings extends SettingsMigration { // Get the user-set configuration values from the old table. $this->migrator->add('server.allocation_limit', ($this->getOldValue('SETTINGS::SERVER:ALLOCATION_LIMIT') != null) ?: 200); + $this->migrator->add('server.creation_enabled', ($this->getOldValue('SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS') != null) ?: true); + $this->migrator->add('server.enable_upgrade', ($this->getOldValue('SETTINGS::SYSTEM:ENABLE_UPGRADE') != null) ?: false); } public function getOldValue(string $key) diff --git a/database/settings/2023_02_01_182158_create_website_settings.php b/database/settings/2023_02_01_182158_create_website_settings.php index d164c3b4..310024b9 100644 --- a/database/settings/2023_02_01_182158_create_website_settings.php +++ b/database/settings/2023_02_01_182158_create_website_settings.php @@ -9,6 +9,20 @@ class CreateWebsiteSettings extends SettingsMigration { // Get the user-set configuration values from the old table. $this->migrator->add('website.', ($this->getOldValue('SETTINGS::') != null) ?: ''); + $this->migrator->add('website.motd_enabled', ($this->getOldValue("SETTINGS::SYSTEM:MOTD_ENABLED") != null) ?: true); + $this->migrator->add('website.motd_message', ($this->getOldValue("SETTINGS::SYSTEM:MOTD_MESSAGE") != null) ?: + '

Controlpanel.gg

+

Thank you for using our Software

+

If you have any questions, make sure to join our Discord

+

(you can change this message in the Settings )

' + ); + $this->migrator->add('website.show_imprint', ($this->getOldValue("SETTINGS::SYSTEM:SHOW_IMPRINT") != null) ?: false); + $this->migrator->add('website.show_privacy', ($this->getOldValue("SETTINGS::SYSTEM:SHOW_PRIVACY") != null) ?: false); + $this->migrator->add('website.show_tos', ($this->getOldValue("SETTINGS::SYSTEM:SHOW_TOS") != null) ?: false); + $this->migrator->add('website.useful_links_enabled', ($this->getOldValue("SETTINGS::SYSTEM:USEFULLINKS_ENABLED") != null) ?: true); + $this->migrator->add('website.seo_title', ($this->getOldValue("SETTINGS::SYSTEM:SEO_TITLE") != null) ?: 'ControlPanel.gg'); + $this->migrator->add('website.seo_description', ($this->getOldValue("SETTINGS::SYSTEM:SEO_DESCRIPTION") != null) ?: 'Billing software for Pterodactyl Panel.'); + } public function getOldValue(string $key) From 1086dd85a490038b9fbf39ce8a7fcce40b25c87a Mon Sep 17 00:00:00 2001 From: Ferks-FK Date: Thu, 2 Feb 2023 15:14:44 +0000 Subject: [PATCH 004/120] Ptero API keys are now encrypted. --- .../2023_02_01_181334_create_pterodactyl_settings.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/settings/2023_02_01_181334_create_pterodactyl_settings.php b/database/settings/2023_02_01_181334_create_pterodactyl_settings.php index 6bc39486..2e3dd63f 100644 --- a/database/settings/2023_02_01_181334_create_pterodactyl_settings.php +++ b/database/settings/2023_02_01_181334_create_pterodactyl_settings.php @@ -8,8 +8,8 @@ class CreatePterodactylSettings extends SettingsMigration public function up(): void { // Get the user-set configuration values from the old table. - $this->migrator->add('pterodactyl.admin_token', ($this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:TOKEN') != null) ?: env('PTERODACTYL_TOKEN', '')); - $this->migrator->add('pterodactyl.user_token', ($this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN') != null) ?: ''); + $this->migrator->addEncrypted('pterodactyl.admin_token', ($this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:TOKEN') != null) ?: env('PTERODACTYL_TOKEN', '')); + $this->migrator->addEncrypted('pterodactyl.user_token', ($this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN') != null) ?: ''); $this->migrator->add('pterodactyl.panel_url', ($this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:URL') != null) ?: env('PTERODACTYL_URL', '')); $this->migrator->add('pterodactyl.per_page_limit', ($this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT') != null) ?: 200); } From 8e212889a4b706fc538ebebf188a7fc97e16d069 Mon Sep 17 00:00:00 2001 From: Ferks-FK Date: Thu, 2 Feb 2023 15:45:17 +0000 Subject: [PATCH 005/120] Create all the settings files. --- app/Settings/DiscordSettings.php | 25 +++++++++++++ app/Settings/InvoiceSettings.php | 29 +++++++++++++++ app/Settings/LocaleSettings.php | 23 ++++++++++++ app/Settings/MailSettings.php | 31 ++++++++++++++++ app/Settings/PterodactylSettings.php | 21 +++++++++++ app/Settings/ReferralSettings.php | 25 +++++++++++++ app/Settings/ServerSettings.php | 19 ++++++++++ app/Settings/UserSettings.php | 37 +++++++++++++++++++ app/Settings/WebsiteSettings.php | 29 +++++++++++++++ ...2023_02_01_181453_create_mail_settings.php | 16 ++++---- ...3_02_01_182043_create_discord_settings.php | 6 +-- ...3_02_01_182158_create_website_settings.php | 1 - 12 files changed, 250 insertions(+), 12 deletions(-) create mode 100644 app/Settings/DiscordSettings.php create mode 100644 app/Settings/InvoiceSettings.php create mode 100644 app/Settings/LocaleSettings.php create mode 100644 app/Settings/MailSettings.php create mode 100644 app/Settings/PterodactylSettings.php create mode 100644 app/Settings/ReferralSettings.php create mode 100644 app/Settings/ServerSettings.php create mode 100644 app/Settings/UserSettings.php create mode 100644 app/Settings/WebsiteSettings.php diff --git a/app/Settings/DiscordSettings.php b/app/Settings/DiscordSettings.php new file mode 100644 index 00000000..3065c05c --- /dev/null +++ b/app/Settings/DiscordSettings.php @@ -0,0 +1,25 @@ +migrator->add('mail.mail_host', ($this->getOldValue('SETTINGS::MAIL:HOST') != null) ?: ''); - $this->migrator->add('mail.mail_port', ($this->getOldValue('SETTINGS::MAIL:PORT') != null) ?: 'mailhog'); - $this->migrator->add('mail.mail_username', ($this->getOldValue('SETTINGS::MAIL:USERNAME') != null) ?: null); - $this->migrator->add('mail.mail_password', ($this->getOldValue('SETTINGS::MAIL:PASSWORD') != null) ?: null); - $this->migrator->add('mail.mail_encryption', ($this->getOldValue('SETTINGS::MAIL:ENCRYPTION') != null) ?: null); - $this->migrator->add('mail.mail_from_address', ($this->getOldValue('SETTINGS::MAIL:FROM_ADDRESS') != null) ?: null); - $this->migrator->add('mail.mail_from_name', ($this->getOldValue('SETTINGS::MAIL:FROM_NAME') != null) ?: 'ControlPanel.gg'); - $this->migrator->add('mail.mail_mailer', ($this->getOldValue('SETTINGS::MAIL:MAILER') != null) ?: 'smtp'); + $this->migrator->add('mail.mail_host', ($this->getOldValue('SETTINGS::MAIL:HOST') != null) ?: env('MAIL_HOST', 'localhost')); + $this->migrator->add('mail.mail_port', ($this->getOldValue('SETTINGS::MAIL:PORT') != null) ?: env('MAIL_PORT', '25')); + $this->migrator->add('mail.mail_username', ($this->getOldValue('SETTINGS::MAIL:USERNAME') != null) ?: env('MAIL_USERNAME', '')); + $this->migrator->addEncrypted('mail.mail_password', ($this->getOldValue('SETTINGS::MAIL:PASSWORD') != null) ?: env('MAIL_PASSWORD', '')); + $this->migrator->add('mail.mail_encryption', ($this->getOldValue('SETTINGS::MAIL:ENCRYPTION') != null) ?: env('MAIL_ENCRYPTION', 'tls')); + $this->migrator->add('mail.mail_from_address', ($this->getOldValue('SETTINGS::MAIL:FROM_ADDRESS') != null) ?: env('MAIL_FROM_ADDRESS', '')); + $this->migrator->add('mail.mail_from_name', ($this->getOldValue('SETTINGS::MAIL:FROM_NAME') != null) ?: env('APP_NAME', 'ControlPanel.gg')); + $this->migrator->add('mail.mail_mailer', ($this->getOldValue('SETTINGS::MAIL:MAILER') != null) ?: env('MAIL_MAILER', 'smtp')); $this->migrator->add('mail.mail_enabled', true); } diff --git a/database/settings/2023_02_01_182043_create_discord_settings.php b/database/settings/2023_02_01_182043_create_discord_settings.php index 34f06141..bbc03009 100644 --- a/database/settings/2023_02_01_182043_create_discord_settings.php +++ b/database/settings/2023_02_01_182043_create_discord_settings.php @@ -8,9 +8,9 @@ class CreateDiscordSettings extends SettingsMigration public function up(): void { // Get the user-set configuration values from the old table. - $this->migrator->add('discord.bot_token', ($this->getOldValue('SETTINGS::DISCORD:BOT_TOKEN') != null) ?: null); - $this->migrator->add('discord.client_id', ($this->getOldValue('SETTINGS::DISCORD:CLIENT_ID') != null) ?: null); - $this->migrator->add('discord.client_secret', ($this->getOldValue('SETTINGS::DISCORD:CLIENT_SECRET') != null) ?: null); + $this->migrator->addEncrypted('discord.bot_token', ($this->getOldValue('SETTINGS::DISCORD:BOT_TOKEN') != null) ?: null); + $this->migrator->addEncrypted('discord.client_id', ($this->getOldValue('SETTINGS::DISCORD:CLIENT_ID') != null) ?: null); + $this->migrator->addEncrypted('discord.client_secret', ($this->getOldValue('SETTINGS::DISCORD:CLIENT_SECRET') != null) ?: null); $this->migrator->add('discord.guild_id', ($this->getOldValue('SETTINGS::DISCORD:GUILD_ID') != null) ?: null); $this->migrator->add('discord.invite_url', ($this->getOldValue('SETTINGS::DISCORD:INVITE_URL') != null) ?: null); $this->migrator->add('discord.role_id', ($this->getOldValue('SETTINGS::DISCORD:ROLE_ID') != null) ?: null); diff --git a/database/settings/2023_02_01_182158_create_website_settings.php b/database/settings/2023_02_01_182158_create_website_settings.php index 310024b9..b5a1fba0 100644 --- a/database/settings/2023_02_01_182158_create_website_settings.php +++ b/database/settings/2023_02_01_182158_create_website_settings.php @@ -8,7 +8,6 @@ class CreateWebsiteSettings extends SettingsMigration public function up(): void { // Get the user-set configuration values from the old table. - $this->migrator->add('website.', ($this->getOldValue('SETTINGS::') != null) ?: ''); $this->migrator->add('website.motd_enabled', ($this->getOldValue("SETTINGS::SYSTEM:MOTD_ENABLED") != null) ?: true); $this->migrator->add('website.motd_message', ($this->getOldValue("SETTINGS::SYSTEM:MOTD_MESSAGE") != null) ?: '

Controlpanel.gg

From 5305ae78033a1dee4c0ace6d6f33fc991405f97d Mon Sep 17 00:00:00 2001 From: Ferks-FK Date: Thu, 2 Feb 2023 16:36:19 +0000 Subject: [PATCH 006/120] fix: Ternary would always return 'true' --- database/seeders/DatabaseSeeder.php | 2 +- database/seeders/Seeds/SettingsSeeder.php | 2 -- ...3_02_01_164731_create_general_settings.php | 31 +++++++++-------- ..._01_181334_create_pterodactyl_settings.php | 17 +++++----- ...2023_02_01_181453_create_mail_settings.php | 25 +++++++------- ...2023_02_01_181925_create_user_settings.php | 33 +++++++++---------- ...23_02_01_181950_create_server_settings.php | 15 ++++----- ...3_02_01_182021_create_invoice_settings.php | 25 +++++++------- ...3_02_01_182043_create_discord_settings.php | 21 ++++++------ ...23_02_01_182108_create_locale_settings.php | 19 +++++------ ..._02_01_182135_create_referral_settings.php | 21 ++++++------ ...3_02_01_182158_create_website_settings.php | 25 +++++++------- 12 files changed, 112 insertions(+), 124 deletions(-) diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 6ed3baa0..b2610636 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -15,7 +15,7 @@ class DatabaseSeeder extends Seeder public function run() { $this->call([ - SettingsSeeder::class, + //SettingsSeeder::class, ]); } } diff --git a/database/seeders/Seeds/SettingsSeeder.php b/database/seeders/Seeds/SettingsSeeder.php index 65773e0b..c4b32925 100644 --- a/database/seeders/Seeds/SettingsSeeder.php +++ b/database/seeders/Seeds/SettingsSeeder.php @@ -4,7 +4,6 @@ namespace Database\Seeders\Seeds; use App\Models\Settings; use Illuminate\Database\Seeder; -use Illuminate\Support\Facades\DB; class SettingsSeeder extends Seeder { @@ -15,7 +14,6 @@ class SettingsSeeder extends Seeder */ public function run() { - DB::table('settings_old', 'old')->where(''); //initials Settings::firstOrCreate([ 'key' => 'SETTINGS::USER:INITIAL_CREDITS', diff --git a/database/settings/2023_02_01_164731_create_general_settings.php b/database/settings/2023_02_01_164731_create_general_settings.php index d3e1238b..a19b4a04 100644 --- a/database/settings/2023_02_01_164731_create_general_settings.php +++ b/database/settings/2023_02_01_164731_create_general_settings.php @@ -7,27 +7,26 @@ class CreateGeneralSettings extends SettingsMigration { public function up(): void { + $table_exists = DB::table('settings_old')->exists(); + // Get the user-set configuration values from the old table. - $this->migrator->add('general.credits_display_name', ($this->getOldValue('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME') != null) ?: 'Credits'); - $this->migrator->add('general.initial_user_credits', ($this->getOldValue("SETTINGS::USER:INITIAL_CREDITS") != null) ?: 250); - $this->migrator->add('general.initial_server_limit', ($this->getOldValue("SETTINGS::USER:INITIAL_SERVER_LIMIT") != null) ?: 1); - $this->migrator->add('general.recaptcha_site_key', ($this->getOldValue("SETTINGS::RECAPTCHA:SITE_KEY") != null) ?: env('RECAPTCHA_SITE_KEY', '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI')); - $this->migrator->add('general.recaptcha_secret_key', ($this->getOldValue("SETTINGS::RECAPTCHA:SECRET_KEY") != null) ?: env('RECAPTCHA_SECRET_KEY', '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe')); - $this->migrator->add('general.recaptcha_enabled', ($this->getOldValue("SETTINGS::RECAPTCHA:ENABLED") != null) ?: true); - $this->migrator->add('general.phpmyadmin_url', ($this->getOldValue("SETTINGS::MISC:PHPMYADMIN:URL") != null) ?: env('PHPMYADMIN_URL', '')); - $this->migrator->add('general.alert_enabled', ($this->getOldValue("SETTINGS::SYSTEM:ALERT_ENABLED") != null) ?: false); - $this->migrator->add('general.alert_type', ($this->getOldValue("SETTINGS::SYSTEM:ALERT_TYPE") != null) ?: 'dark'); - $this->migrator->add('general.alert_message', ($this->getOldValue("SETTINGS::SYSTEM:ALERT_MESSAGE") != null) ?: ''); - $this->migrator->add('general.theme', ($this->getOldValue("SETTINGS::SYSTEM:THEME") != null) ?: 'default'); + $this->migrator->add('general.credits_display_name', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME') : 'Credits'); + $this->migrator->add('general.initial_user_credits', $table_exists ? $this->getOldValue("SETTINGS::USER:INITIAL_CREDITS") : 250); + $this->migrator->add('general.initial_server_limit', $table_exists ? $this->getOldValue("SETTINGS::USER:INITIAL_SERVER_LIMIT") : 1); + $this->migrator->addEncrypted('general.recaptcha_site_key', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:SITE_KEY") : env('RECAPTCHA_SITE_KEY', '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI')); + $this->migrator->addEncrypted('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.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_type', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:ALERT_TYPE") : 'dark'); + $this->migrator->add('general.alert_message', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:ALERT_MESSAGE") : ''); + $this->migrator->add('general.theme', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:THEME") : 'default'); $this->migrator->add('general.main_site', ''); } public function getOldValue(string $key) { - if (DB::table('settings_old')->exists()) { - return DB::table('settings_old')->where('key', '=', $key)->get(['value']); - } - - return null; + // Always get the first value of the key. + return DB::table('settings_old')->where('key', '=', $key)->get(['value'])->first()->value; } } \ No newline at end of file diff --git a/database/settings/2023_02_01_181334_create_pterodactyl_settings.php b/database/settings/2023_02_01_181334_create_pterodactyl_settings.php index 2e3dd63f..7f97f5c0 100644 --- a/database/settings/2023_02_01_181334_create_pterodactyl_settings.php +++ b/database/settings/2023_02_01_181334_create_pterodactyl_settings.php @@ -7,19 +7,18 @@ class CreatePterodactylSettings extends SettingsMigration { public function up(): void { + $table_exists = DB::table('settings_old')->exists(); + // Get the user-set configuration values from the old table. - $this->migrator->addEncrypted('pterodactyl.admin_token', ($this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:TOKEN') != null) ?: env('PTERODACTYL_TOKEN', '')); - $this->migrator->addEncrypted('pterodactyl.user_token', ($this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN') != null) ?: ''); - $this->migrator->add('pterodactyl.panel_url', ($this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:URL') != null) ?: env('PTERODACTYL_URL', '')); - $this->migrator->add('pterodactyl.per_page_limit', ($this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT') != null) ?: 200); + $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->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 getOldValue(string $key) { - if (DB::table('settings_old')->exists()) { - return DB::table('settings_old')->where('key', '=', $key)->get(['value']); - } - - return null; + // Always get the first value of the key. + return DB::table('settings_old')->where('key', '=', $key)->get(['value'])->first()->value; } } \ No newline at end of file diff --git a/database/settings/2023_02_01_181453_create_mail_settings.php b/database/settings/2023_02_01_181453_create_mail_settings.php index 41b6b6e1..cbd0e998 100644 --- a/database/settings/2023_02_01_181453_create_mail_settings.php +++ b/database/settings/2023_02_01_181453_create_mail_settings.php @@ -7,24 +7,23 @@ class CreateMailSettings extends SettingsMigration { public function up(): void { + $table_exists = DB::table('settings_old')->exists(); + // Get the user-set configuration values from the old table. - $this->migrator->add('mail.mail_host', ($this->getOldValue('SETTINGS::MAIL:HOST') != null) ?: env('MAIL_HOST', 'localhost')); - $this->migrator->add('mail.mail_port', ($this->getOldValue('SETTINGS::MAIL:PORT') != null) ?: env('MAIL_PORT', '25')); - $this->migrator->add('mail.mail_username', ($this->getOldValue('SETTINGS::MAIL:USERNAME') != null) ?: env('MAIL_USERNAME', '')); - $this->migrator->addEncrypted('mail.mail_password', ($this->getOldValue('SETTINGS::MAIL:PASSWORD') != null) ?: env('MAIL_PASSWORD', '')); - $this->migrator->add('mail.mail_encryption', ($this->getOldValue('SETTINGS::MAIL:ENCRYPTION') != null) ?: env('MAIL_ENCRYPTION', 'tls')); - $this->migrator->add('mail.mail_from_address', ($this->getOldValue('SETTINGS::MAIL:FROM_ADDRESS') != null) ?: env('MAIL_FROM_ADDRESS', '')); - $this->migrator->add('mail.mail_from_name', ($this->getOldValue('SETTINGS::MAIL:FROM_NAME') != null) ?: env('APP_NAME', 'ControlPanel.gg')); - $this->migrator->add('mail.mail_mailer', ($this->getOldValue('SETTINGS::MAIL:MAILER') != null) ?: env('MAIL_MAILER', 'smtp')); + $this->migrator->add('mail.mail_host', $table_exists ? $this->getOldValue('SETTINGS::MAIL:HOST') : env('MAIL_HOST', 'localhost')); + $this->migrator->add('mail.mail_port', $table_exists ? $this->getOldValue('SETTINGS::MAIL:PORT') : env('MAIL_PORT', '25')); + $this->migrator->add('mail.mail_username', $table_exists ? $this->getOldValue('SETTINGS::MAIL:USERNAME') : env('MAIL_USERNAME', '')); + $this->migrator->addEncrypted('mail.mail_password', $table_exists ? $this->getOldValue('SETTINGS::MAIL:PASSWORD') : env('MAIL_PASSWORD', '')); + $this->migrator->add('mail.mail_encryption', $table_exists ? $this->getOldValue('SETTINGS::MAIL:ENCRYPTION') : env('MAIL_ENCRYPTION', 'tls')); + $this->migrator->add('mail.mail_from_address', $table_exists ? $this->getOldValue('SETTINGS::MAIL:FROM_ADDRESS') : env('MAIL_FROM_ADDRESS', '')); + $this->migrator->add('mail.mail_from_name', $table_exists ? $this->getOldValue('SETTINGS::MAIL:FROM_NAME') : env('APP_NAME', 'ControlPanel.gg')); + $this->migrator->add('mail.mail_mailer', $table_exists ? $this->getOldValue('SETTINGS::MAIL:MAILER') : env('MAIL_MAILER', 'smtp')); $this->migrator->add('mail.mail_enabled', true); } public function getOldValue(string $key) { - if (DB::table('settings_old')->exists()) { - return DB::table('settings_old')->where('key', '=', $key)->get(['value']); - } - - return null; + // Always get the first value of the key. + return DB::table('settings_old')->where('key', '=', $key)->get(['value'])->first()->value; } } \ No newline at end of file diff --git a/database/settings/2023_02_01_181925_create_user_settings.php b/database/settings/2023_02_01_181925_create_user_settings.php index 24ed7cea..5c0ab300 100644 --- a/database/settings/2023_02_01_181925_create_user_settings.php +++ b/database/settings/2023_02_01_181925_create_user_settings.php @@ -7,27 +7,26 @@ class CreateUserSettings extends SettingsMigration { public function up(): void { + $table_exists = DB::table('settings_old')->exists(); + // Get the user-set configuration values from the old table. - $this->migrator->add('user.credits_reward_after_verify_discord', ($this->getOldValue('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD') != null) ?: 250); - $this->migrator->add('user.credits_reward_after_verify_email', ($this->getOldValue('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL') != null) ?: 250); - $this->migrator->add('user.force_discord_verification', ($this->getOldValue('SETTINGS::USER:FORCE_DISCORD_VERIFICATION') != null) ?: false); - $this->migrator->add('user.force_email_verification', ($this->getOldValue('SETTINGS::USER:FORCE_EMAIL_VERIFICATION') != null) ?: false); - $this->migrator->add('user.initial_credits', ($this->getOldValue('SETTINGS::USER:INITIAL_CREDITS') != null) ?: 250); - $this->migrator->add('user.initial_server_limit', ($this->getOldValue('SETTINGS::USER:INITIAL_SERVER_LIMIT') != null) ?: 1); - $this->migrator->add('user.min_credits_to_make_server', ($this->getOldValue('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER') != null) ?: 50); - $this->migrator->add('user.server_limit_after_irl_purchase', ($this->getOldValue('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') != null) ?: 10); - $this->migrator->add('user.server_limit_after_verify_discord', ($this->getOldValue('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD') != null) ?: 2); - $this->migrator->add('user.server_limit_after_verify_email', ($this->getOldValue('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL') != null) ?: 2); - $this->migrator->add('user.register_ip_check', ($this->getOldValue("SETTINGS::SYSTEM:REGISTER_IP_CHECK") != null) ?: true); - $this->migrator->add('user.creation_enabled', ($this->getOldValue("SETTINGS::SYSTEM:CREATION_OF_NEW_USERS") != null) ?: true); + $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_email', $table_exists ? $this->getOldValue('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL'): 250); + $this->migrator->add('user.force_discord_verification', $table_exists ? $this->getOldValue('SETTINGS::USER:FORCE_DISCORD_VERIFICATION'): false); + $this->migrator->add('user.force_email_verification', $table_exists ? $this->getOldValue('SETTINGS::USER:FORCE_EMAIL_VERIFICATION'): false); + $this->migrator->add('user.initial_credits', $table_exists ? $this->getOldValue('SETTINGS::USER:INITIAL_CREDITS'): 250); + $this->migrator->add('user.initial_server_limit', $table_exists ? $this->getOldValue('SETTINGS::USER:INITIAL_SERVER_LIMIT'): 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.server_limit_after_irl_purchase', $table_exists ? $this->getOldValue('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE'): 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_email', $table_exists ? $this->getOldValue('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL'): 2); + $this->migrator->add('user.register_ip_check', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:REGISTER_IP_CHECK"): true); + $this->migrator->add('user.creation_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:CREATION_OF_NEW_USERS"): true); } public function getOldValue(string $key) { - if (DB::table('settings_old')->exists()) { - return DB::table('settings_old')->where('key', '=', $key)->get(['value']); - } - - return null; + // Always get the first value of the key. + return DB::table('settings_old')->where('key', '=', $key)->get(['value'])->first()->value; } } \ No newline at end of file diff --git a/database/settings/2023_02_01_181950_create_server_settings.php b/database/settings/2023_02_01_181950_create_server_settings.php index 6144170f..804aad88 100644 --- a/database/settings/2023_02_01_181950_create_server_settings.php +++ b/database/settings/2023_02_01_181950_create_server_settings.php @@ -7,18 +7,17 @@ class CreateServerSettings extends SettingsMigration { public function up(): void { + $table_exists = DB::table('settings_old')->exists(); + // Get the user-set configuration values from the old table. - $this->migrator->add('server.allocation_limit', ($this->getOldValue('SETTINGS::SERVER:ALLOCATION_LIMIT') != null) ?: 200); - $this->migrator->add('server.creation_enabled', ($this->getOldValue('SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS') != null) ?: true); - $this->migrator->add('server.enable_upgrade', ($this->getOldValue('SETTINGS::SYSTEM:ENABLE_UPGRADE') != null) ?: false); + $this->migrator->add('server.allocation_limit', $table_exists ? $this->getOldValue('SETTINGS::SERVER:ALLOCATION_LIMIT'): 200); + $this->migrator->add('server.creation_enabled', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS'): true); + $this->migrator->add('server.enable_upgrade', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:ENABLE_UPGRADE'): false); } public function getOldValue(string $key) { - if (DB::table('settings_old')->exists()) { - return DB::table('settings_old')->where('key', '=', $key)->get(['value']); - } - - return null; + // Always get the first value of the key. + return DB::table('settings_old')->where('key', '=', $key)->get(['value'])->first()->value; } } \ No newline at end of file diff --git a/database/settings/2023_02_01_182021_create_invoice_settings.php b/database/settings/2023_02_01_182021_create_invoice_settings.php index 0630495e..93ab9513 100644 --- a/database/settings/2023_02_01_182021_create_invoice_settings.php +++ b/database/settings/2023_02_01_182021_create_invoice_settings.php @@ -7,23 +7,22 @@ class CreateInvoiceSettings extends SettingsMigration { public function up(): void { + $table_exists = DB::table('settings_old')->exists(); + // Get the user-set configuration values from the old table. - $this->migrator->add('invoice.company_address', ($this->getOldValue('SETTINGS::INVOICE:COMPANY_ADDRESS') != null) ?: null); - $this->migrator->add('invoice.company_mail', ($this->getOldValue('SETTINGS::INVOICE:COMPANY_MAIL') != null) ?: null); - $this->migrator->add('invoice.company_name', ($this->getOldValue('SETTINGS::INVOICE:COMPANY_NAME') != null) ?: null); - $this->migrator->add('invoice.company_phone', ($this->getOldValue('SETTINGS::INVOICE:COMPANY_PHONE') != null) ?: null); - $this->migrator->add('invoice.company_vat', ($this->getOldValue('SETTINGS::INVOICE:COMPANY_VAT') != null) ?: null); - $this->migrator->add('invoice.company_website', ($this->getOldValue('SETTINGS::INVOICE:COMPANY_WEBSITE') != null) ?: null); - $this->migrator->add('invoice.enabled', ($this->getOldValue('SETTINGS::INVOICE:ENABLED') != null) ?: true); - $this->migrator->add('invoice.prefix', ($this->getOldValue('SETTINGS::INVOICE:PREFIX') != null) ?: 'INV'); + $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'): null); + $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'): null); + $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'): null); + $this->migrator->add('invoice.enabled', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:ENABLED'): true); + $this->migrator->add('invoice.prefix', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:PREFIX'): 'INV'); } public function getOldValue(string $key) { - if (DB::table('settings_old')->exists()) { - return DB::table('settings_old')->where('key', '=', $key)->get(['value']); - } - - return null; + // Always get the first value of the key. + return DB::table('settings_old')->where('key', '=', $key)->get(['value'])->first()->value; } } \ No newline at end of file diff --git a/database/settings/2023_02_01_182043_create_discord_settings.php b/database/settings/2023_02_01_182043_create_discord_settings.php index bbc03009..74771dc4 100644 --- a/database/settings/2023_02_01_182043_create_discord_settings.php +++ b/database/settings/2023_02_01_182043_create_discord_settings.php @@ -7,21 +7,20 @@ class CreateDiscordSettings extends SettingsMigration { public function up(): void { + $table_exists = DB::table('settings_old')->exists(); + // Get the user-set configuration values from the old table. - $this->migrator->addEncrypted('discord.bot_token', ($this->getOldValue('SETTINGS::DISCORD:BOT_TOKEN') != null) ?: null); - $this->migrator->addEncrypted('discord.client_id', ($this->getOldValue('SETTINGS::DISCORD:CLIENT_ID') != null) ?: null); - $this->migrator->addEncrypted('discord.client_secret', ($this->getOldValue('SETTINGS::DISCORD:CLIENT_SECRET') != null) ?: null); - $this->migrator->add('discord.guild_id', ($this->getOldValue('SETTINGS::DISCORD:GUILD_ID') != null) ?: null); - $this->migrator->add('discord.invite_url', ($this->getOldValue('SETTINGS::DISCORD:INVITE_URL') != null) ?: null); - $this->migrator->add('discord.role_id', ($this->getOldValue('SETTINGS::DISCORD:ROLE_ID') != null) ?: null); + $this->migrator->addEncrypted('discord.bot_token', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:BOT_TOKEN'): null); + $this->migrator->addEncrypted('discord.client_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:CLIENT_ID'): null); + $this->migrator->addEncrypted('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'): null); + $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'): null); } public function getOldValue(string $key) { - if (DB::table('settings_old')->exists()) { - return DB::table('settings_old')->where('key', '=', $key)->get(['value']); - } - - return null; + // Always get the first value of the key. + return DB::table('settings_old')->where('key', '=', $key)->get(['value'])->first()->value; } } \ No newline at end of file diff --git a/database/settings/2023_02_01_182108_create_locale_settings.php b/database/settings/2023_02_01_182108_create_locale_settings.php index 49c833c7..7b9facbd 100644 --- a/database/settings/2023_02_01_182108_create_locale_settings.php +++ b/database/settings/2023_02_01_182108_create_locale_settings.php @@ -7,20 +7,19 @@ class CreateLocaleSettings extends SettingsMigration { public function up(): void { + $table_exists = DB::table('settings_old')->exists(); + // Get the user-set configuration values from the old table. - $this->migrator->add('locale.available', ($this->getOldValue('SETTINGS::LOCALE:AVAILABLE') != null) ?: ''); - $this->migrator->add('locale.clients_can_change', ($this->getOldValue('SETTINGS::LOCALE:CLIENTS_CAN_CHANGE') != null) ?: true); - $this->migrator->add('locale.datatables', ($this->getOldValue('SETTINGS::LOCALE:DATATABLES') != null) ?: 'en-gb'); - $this->migrator->add('locale.default', ($this->getOldValue('SETTINGS::LOCALE:DEFAULT') != null) ?: 'en'); - $this->migrator->add('locale.dynamic', ($this->getOldValue('SETTINGS::LOCALE:DYNAMIC') != null) ?: false); + $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.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.dynamic', $table_exists ? $this->getOldValue('SETTINGS::LOCALE:DYNAMIC'): false); } public function getOldValue(string $key) { - if (DB::table('settings_old')->exists()) { - return DB::table('settings_old')->where('key', '=', $key)->get(['value']); - } - - return null; + // Always get the first value of the key. + return DB::table('settings_old')->where('key', '=', $key)->get(['value'])->first()->value; } } \ No newline at end of file diff --git a/database/settings/2023_02_01_182135_create_referral_settings.php b/database/settings/2023_02_01_182135_create_referral_settings.php index 6d305604..e07eef40 100644 --- a/database/settings/2023_02_01_182135_create_referral_settings.php +++ b/database/settings/2023_02_01_182135_create_referral_settings.php @@ -7,21 +7,20 @@ class CreateReferralSettings extends SettingsMigration { public function up(): void { + $table_exists = DB::table('settings_old')->exists(); + // Get the user-set configuration values from the old table. - $this->migrator->add('referral.allowed', ($this->getOldValue('SETTINGS::REFERRAL::ALLOWED') != null) ?: 'client'); - $this->migrator->add('referral.always_give_commission', ($this->getOldValue('SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION') != null) ?: false); - $this->migrator->add('referral.enabled', ($this->getOldValue('SETTINGS::REFERRAL::ENABLED') != null) ?: false); - $this->migrator->add('referral.reward', ($this->getOldValue('SETTINGS::REFERRAL::REWARD') != null) ?: 100); - $this->migrator->add('referral.mode', ($this->getOldValue('SETTINGS::REFERRAL:MODE') != null) ?: 'sign-up'); - $this->migrator->add('referral.percentage', ($this->getOldValue('SETTINGS::REFERRAL:PERCENTAGE') != null) ?: 100); + $this->migrator->add('referral.allowed', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL::ALLOWED') : 'client'); + $this->migrator->add('referral.always_give_commission', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION') : false); + $this->migrator->add('referral.enabled', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL::ENABLED') : false); + $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.percentage', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL:PERCENTAGE') : 100); } public function getOldValue(string $key) { - if (DB::table('settings_old')->exists()) { - return DB::table('settings_old')->where('key', '=', $key)->get(['value']); - } - - return null; + // Always get the first value of the key. + return DB::table('settings_old')->where('key', '=', $key)->get(['value'])->first()->value; } } \ No newline at end of file diff --git a/database/settings/2023_02_01_182158_create_website_settings.php b/database/settings/2023_02_01_182158_create_website_settings.php index b5a1fba0..6c7a00a3 100644 --- a/database/settings/2023_02_01_182158_create_website_settings.php +++ b/database/settings/2023_02_01_182158_create_website_settings.php @@ -7,29 +7,28 @@ class CreateWebsiteSettings extends SettingsMigration { public function up(): void { + $table_exists = DB::table('settings_old')->exists(); + // Get the user-set configuration values from the old table. - $this->migrator->add('website.motd_enabled', ($this->getOldValue("SETTINGS::SYSTEM:MOTD_ENABLED") != null) ?: true); - $this->migrator->add('website.motd_message', ($this->getOldValue("SETTINGS::SYSTEM:MOTD_MESSAGE") != null) ?: + $this->migrator->add('website.motd_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:MOTD_ENABLED") : true); + $this->migrator->add('website.motd_message', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:MOTD_MESSAGE") : '

Controlpanel.gg

Thank you for using our Software

If you have any questions, make sure to join our Discord

(you can change this message in the Settings )

' ); - $this->migrator->add('website.show_imprint', ($this->getOldValue("SETTINGS::SYSTEM:SHOW_IMPRINT") != null) ?: false); - $this->migrator->add('website.show_privacy', ($this->getOldValue("SETTINGS::SYSTEM:SHOW_PRIVACY") != null) ?: false); - $this->migrator->add('website.show_tos', ($this->getOldValue("SETTINGS::SYSTEM:SHOW_TOS") != null) ?: false); - $this->migrator->add('website.useful_links_enabled', ($this->getOldValue("SETTINGS::SYSTEM:USEFULLINKS_ENABLED") != null) ?: true); - $this->migrator->add('website.seo_title', ($this->getOldValue("SETTINGS::SYSTEM:SEO_TITLE") != null) ?: 'ControlPanel.gg'); - $this->migrator->add('website.seo_description', ($this->getOldValue("SETTINGS::SYSTEM:SEO_DESCRIPTION") != null) ?: 'Billing software for Pterodactyl Panel.'); + $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_tos', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SHOW_TOS") : false); + $this->migrator->add('website.useful_links_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:USEFULLINKS_ENABLED") : true); + $this->migrator->add('website.seo_title', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SEO_TITLE") : 'ControlPanel.gg'); + $this->migrator->add('website.seo_description', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SEO_DESCRIPTION") : 'Billing software for Pterodactyl Panel.'); } public function getOldValue(string $key) { - if (DB::table('settings_old')->exists()) { - return DB::table('settings_old')->where('key', '=', $key)->get(['value']); - } - - return null; + // Always get the first value of the key. + return DB::table('settings_old')->where('key', '=', $key)->get(['value'])->first()->value; } } \ No newline at end of file From 636d4e259e6aaa633094ab8e62d930ac29210296 Mon Sep 17 00:00:00 2001 From: Ferks-FK Date: Thu, 2 Feb 2023 17:29:50 +0000 Subject: [PATCH 007/120] Register all classes in the config file --- config/settings.php | 20 +- database/seeders/DatabaseSeeder.php | 6 +- database/seeders/Seeds/SettingsSeeder.php | 656 ---------------------- 3 files changed, 21 insertions(+), 661 deletions(-) delete mode 100644 database/seeders/Seeds/SettingsSeeder.php diff --git a/config/settings.php b/config/settings.php index 3a48ef9c..88aba4fa 100644 --- a/config/settings.php +++ b/config/settings.php @@ -1,6 +1,15 @@ [ - GeneralSettings::class + GeneralSettings::class, + DiscordSettings::class, + InvoiceSettings::class, + LocaleSettings::class, + MailSettings::class, + PterodactylSettings::class, + ReferralSettings::class, + ServerSettings::class, + UserSettings::class, + WebsiteSettings::class ], /* diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index b2610636..f58bfb26 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -2,8 +2,8 @@ namespace Database\Seeders; -use Database\Seeders\Seeds\SettingsSeeder; use Illuminate\Database\Seeder; +use Illuminate\Support\Facades\Schema; class DatabaseSeeder extends Seeder { @@ -14,8 +14,6 @@ class DatabaseSeeder extends Seeder */ public function run() { - $this->call([ - //SettingsSeeder::class, - ]); + Schema::dropIfExists('settings_old'); } } diff --git a/database/seeders/Seeds/SettingsSeeder.php b/database/seeders/Seeds/SettingsSeeder.php deleted file mode 100644 index c4b32925..00000000 --- a/database/seeders/Seeds/SettingsSeeder.php +++ /dev/null @@ -1,656 +0,0 @@ - 'SETTINGS::USER:INITIAL_CREDITS', - ], [ - 'value' => '250', - 'type' => 'integer', - 'description' => 'The initial amount of credits the user starts with.', - ]); - -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::USER:INITIAL_SERVER_LIMIT', -// ], [ -// 'value' => '1', -// 'type' => 'integer', -// 'description' => 'The initial server limit the user starts with.', -// ]); - -// //verify email event -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL', -// ], [ -// 'value' => '250', -// 'type' => 'integer', -// 'description' => 'Increase in credits after the user has verified their email account.', -// ]); - -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL', -// ], [ -// 'value' => '2', -// 'type' => 'integer', -// 'description' => 'Increase in server limit after the user has verified their email account.', -// ]); - -// //verify discord event -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD', -// ], [ -// 'value' => '375', -// 'type' => 'integer', -// 'description' => 'Increase in credits after the user has verified their discord account.', -// ]); - -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD', -// ], [ -// 'value' => '2', -// 'type' => 'integer', -// 'description' => 'Increase in server limit after the user has verified their discord account.', -// ]); - -// //other -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', -// ], [ -// 'value' => '50', -// 'type' => 'integer', -// 'description' => 'The minimum amount of credits the user would need to make a server.', -// ]); - -// //purchasing -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE', -// ], [ -// 'value' => '10', -// 'type' => 'integer', -// 'description' => 'updates the users server limit to this amount (unless the user already has a higher server limit) after making a purchase with real money, set to 0 to ignore this.', -// ]); - -// //force email and discord verification -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::USER:FORCE_EMAIL_VERIFICATION', -// ], [ -// 'value' => 'false', -// 'type' => 'boolean', -// 'description' => 'Force an user to verify the email adress before creating a server / buying credits.', -// ]); - -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::USER:FORCE_DISCORD_VERIFICATION', -// ], [ -// 'value' => 'false', -// 'type' => 'boolean', -// 'description' => 'Force an user to link an Discord Account before creating a server / buying credits.', -// ]); - -// //disable ip check on register -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:REGISTER_IP_CHECK', -// ], [ -// 'value' => 'true', -// 'type' => 'boolean', -// 'description' => 'Prevent users from making multiple accounts using the same IP address', -// ]); - -// //per_page on allocations request -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SERVER:ALLOCATION_LIMIT', -// ], [ -// 'value' => '200', -// 'type' => 'integer', -// 'description' => 'The maximum amount of allocations to pull per node for automatic deployment, if more allocations are being used than this limit is set to, no new servers can be created!', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', -// ], [ -// 'value' => '0', -// 'type' => 'integer', -// 'description' => 'The minimum amount of credits user has to have to create a server. Can be overridden by package limits.' -// ]); - -// //credits display name -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME', -// ], [ -// 'value' => 'Credits', -// 'type' => 'string', -// 'description' => 'The display name of your currency.', -// ]); - -// //credits display name -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:SERVER_CREATE_CHARGE_FIRST_HOUR', -// ], [ -// 'value' => 'true', -// 'type' => 'boolean', -// 'description' => 'Charges the first hour worth of credits upon creating a server.', -// ]); -// //sales tax -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::PAYMENTS:SALES_TAX', -// ], [ -// 'value' => '0', -// 'type' => 'integer', -// 'description' => 'The %-value of tax that will be added to the product price on checkout.', -// ]); -// //Invoices enabled -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::INVOICE:ENABLED', -// ], [ -// 'value' => 'false', -// 'type' => 'boolean', -// 'description' => 'Enables or disables the invoice feature for payments.', -// ]); -// //Invoice company name -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::INVOICE:COMPANY_NAME', -// ], [ -// 'value' => '', -// 'type' => 'string', -// 'description' => 'The name of the Company on the Invoices.', -// ]); -// //Invoice company address -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::INVOICE:COMPANY_ADDRESS', -// ], [ -// 'value' => '', -// 'type' => 'string', -// 'description' => 'The address of the Company on the Invoices.', -// ]); -// //Invoice company phone -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::INVOICE:COMPANY_PHONE', -// ], [ -// 'value' => '', -// 'type' => 'string', -// 'description' => 'The phone number of the Company on the Invoices.', -// ]); - -// //Invoice company mail -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::INVOICE:COMPANY_MAIL', -// ], [ -// 'value' => '', -// 'type' => 'string', -// 'description' => 'The email address of the Company on the Invoices.', -// ]); - -// //Invoice VAT -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::INVOICE:COMPANY_VAT', -// ], [ -// 'value' => '', -// 'type' => 'string', -// 'description' => 'The VAT-Number of the Company on the Invoices.', -// ]); - -// //Invoice Website -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::INVOICE:COMPANY_WEBSITE', -// ], [ -// 'value' => '', -// 'type' => 'string', -// 'description' => 'The Website of the Company on the Invoices.', -// ]); - -// //Invoice Website -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::INVOICE:PREFIX', -// ], [ -// 'value' => 'INV', -// 'type' => 'string', -// 'description' => 'The invoice prefix.', -// ]); - -// //Locale -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::LOCALE:DEFAULT', -// ], [ -// 'value' => 'en', -// 'type' => 'string', -// 'description' => 'The default dashboard language.', -// ]); -// //Dynamic locale -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::LOCALE:DYNAMIC', -// ], [ -// 'value' => 'false', -// 'type' => 'boolean', -// 'description' => 'If this is true, the Language will change to the Clients browserlanguage or default.', -// ]); -// //User can change Locale -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::LOCALE:CLIENTS_CAN_CHANGE', -// ], [ -// 'value' => 'false', -// 'type' => 'boolean', -// 'description' => 'If this is true, the clients will be able to change their Locale.', -// ]); -// //Locale -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::LOCALE:AVAILABLE', -// ], [ -// 'value' => 'en', -// 'type' => 'string', -// 'description' => 'The available languages.', -// ]); -// //Locale -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::LOCALE:DATATABLES', -// ], [ -// 'value' => 'en-gb', -// 'type' => 'string', -// 'description' => 'The Language of the Datatables. Grab the Language-Codes from here https://datatables.net/plug-ins/i18n/', -// ]); - -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::PAYMENTS:PAYPAL:SECRET', -// ], [ -// 'value' => env('PAYPAL_SECRET', ''), -// 'type' => 'string', -// 'description' => 'Your PayPal Secret-Key (https://developer.paypal.com/docs/integration/direct/rest/).', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID', -// ], [ -// 'value' => env('PAYPAL_CLIENT_ID', ''), -// 'type' => 'string', -// 'description' => 'Your PayPal Client_ID.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET', -// ], [ -// 'value' => env('PAYPAL_SANDBOX_SECRET', ''), -// 'type' => 'string', -// 'description' => 'Your PayPal SANDBOX Secret-Key used for testing.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID', -// ], [ -// 'value' => env('PAYPAL_SANDBOX_CLIENT_ID', ''), -// 'type' => 'string', -// 'description' => 'Your PayPal SANDBOX Client-ID used for testing.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::PAYMENTS:STRIPE:SECRET', -// ], [ -// 'value' => env('STRIPE_SECRET', ''), -// 'type' => 'string', -// 'description' => 'Your Stripe Secret-Key (https://dashboard.stripe.com/account/apikeys).', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET', -// ], [ -// 'value' => env('STRIPE_ENDPOINT_SECRET', ''), -// 'type' => 'string', -// 'description' => 'Your Stripe endpoint secret-key.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::PAYMENTS:STRIPE:TEST_SECRET', -// ], [ -// 'value' => env('STRIPE_TEST_SECRET', ''), -// 'type' => 'string', -// 'description' => 'Your Stripe test secret-key.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET', -// ], [ -// 'value' => env('STRIPE_ENDPOINT_TEST_SECRET', ''), -// 'type' => 'string', -// 'description' => 'Your Stripe endpoint test secret-key.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::PAYMENTS:STRIPE:METHODS', -// ], [ -// 'value' => env('STRIPE_METHODS', 'card,sepa_debit'), -// 'type' => 'string', -// 'description' => 'Comma seperated list of payment methods that are enabled (https://stripe.com/docs/payments/payment-methods/integration-options).', -// ]); - -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::DISCORD:CLIENT_ID', -// ], [ -// 'value' => env('DISCORD_CLIENT_ID', ''), -// 'type' => 'string', -// 'description' => 'Discord API Credentials (https://discordapp.com/developers/applications/).', -// ]); - -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::DISCORD:CLIENT_SECRET', -// ], [ -// 'value' => env('DISCORD_CLIENT_SECRET', ''), -// 'type' => 'string', -// 'description' => 'Discord API Credentials (https://discordapp.com/developers/applications/).', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::DISCORD:BOT_TOKEN', -// ], [ -// 'value' => env('DISCORD_BOT_TOKEN', ''), -// 'type' => 'string', -// 'description' => 'Discord API Credentials (https://discordapp.com/developers/applications/).', -// ]); - -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::DISCORD:GUILD_ID', -// ], [ -// 'value' => env('DISCORD_GUILD_ID', ''), -// 'type' => 'string', -// 'description' => 'Discord API Credentials (https://discordapp.com/developers/applications/).', -// ]); - -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::DISCORD:ROLE_ID', -// ], [ -// 'value' => env('DISCORD_ROLE_ID', ''), -// 'type' => 'string', -// 'description' => 'Discord role that will be assigned to users when they register.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::DISCORD:INVITE_URL', -// ], [ -// 'value' => env('DISCORD_INVITE_URL', ''), -// 'type' => 'string', -// 'description' => 'The invite URL to your Discord Server.', -// ]); - -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:PTERODACTYL:TOKEN', -// ], [ -// 'value' => env('PTERODACTYL_TOKEN', ''), -// 'type' => 'string', -// 'description' => 'Admin API Token from Pterodactyl Panel - necessary for the Panel to work. The Key needs all read&write permissions!', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:PTERODACTYL:URL', -// ], [ -// 'value' => env('PTERODACTYL_URL', ''), -// 'type' => 'string', -// 'description' => 'The URL to your Pterodactyl Panel. Must not end with a / ', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT', -// ], [ -// 'value' => 200, -// 'type' => 'integer', -// 'description' => 'The Pterodactyl API perPage limit. It is necessary to set it higher than your server count.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::MISC:PHPMYADMIN:URL', -// ], [ -// 'value' => env('PHPMYADMIN_URL', ''), -// 'type' => 'string', -// 'description' => 'The URL to your PHPMYADMIN Panel. Must not end with a /, remove to remove database button', -// ]); - -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::RECAPTCHA:SITE_KEY', -// ], [ -// 'value' => env('RECAPTCHA_SITE_KEY', '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'), -// 'type' => 'string', -// 'description' => 'Google Recaptcha API Credentials (https://www.google.com/recaptcha/admin) - reCaptcha V2 (not v3)', -// ]); - -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::RECAPTCHA:SECRET_KEY', -// ], [ -// 'value' => env('RECAPTCHA_SECRET_KEY', '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'), -// 'type' => 'string', -// 'description' => 'Google Recaptcha API Credentials (https://www.google.com/recaptcha/admin) - reCaptcha V2 (not v3)', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::RECAPTCHA:ENABLED', -// ], [ -// 'value' => 'true', -// 'type' => 'boolean', -// 'description' => 'Enables or disables the ReCaptcha feature on the registration/login page.', - -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::MAIL:MAILER', -// ], [ -// 'value' => env('MAIL_MAILER', 'smtp'), -// 'type' => 'string', -// 'description' => 'Selected Mailer (smtp, mailgun, sendgrid, mailtrap).', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::MAIL:HOST', -// ], [ -// 'value' => env('MAIL_HOST', 'localhost'), -// 'type' => 'string', -// 'description' => 'Mailer Host Address.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::MAIL:PORT', -// ], [ -// 'value' => env('MAIL_PORT', '25'), -// 'type' => 'string', -// 'description' => 'Mailer Server Port.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::MAIL:USERNAME', -// ], [ -// 'value' => env('MAIL_USERNAME', ''), -// 'type' => 'string', -// 'description' => 'Mailer Username.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::MAIL:PASSWORD', -// ], [ -// 'value' => env('MAIL_PASSWORD', ''), -// 'type' => 'string', -// 'description' => 'Mailer Password.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::MAIL:ENCRYPTION', -// ], [ -// 'value' => env('MAIL_ENCRYPTION', 'tls'), -// 'type' => 'string', -// 'description' => 'Mailer Encryption (tls, ssl).', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::MAIL:FROM_ADDRESS', -// ], [ -// 'value' => env('MAIL_FROM_ADDRESS', ''), -// 'type' => 'string', -// 'description' => 'Mailer From Address.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::MAIL:FROM_NAME', -// ], [ -// 'value' => env('APP_NAME', 'Controlpanel'), -// 'type' => 'string', -// 'description' => 'Mailer From Name.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::REFERRAL::ENABLED', -// ], [ -// 'value' => 'false', -// 'type' => 'string', -// 'description' => 'Enable or disable the referral system.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION', -// ], [ -// 'value' => 'false', -// 'type' => 'string', -// 'description' => 'Whether referrals get percentage commission only on first purchase or on every purchase', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::REFERRAL::REWARD', -// ], [ -// 'value' => 100, -// 'type' => 'integer', -// 'description' => 'Credit reward a user should receive when a user registers with his referral code', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::REFERRAL::ALLOWED', -// ], [ -// 'value' => 'client', -// 'type' => 'string', -// 'description' => 'Who should be allowed to to use the referral code. all/client', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::REFERRAL:MODE', -// ], [ -// 'value' => 'sign-up', -// 'type' => 'string', -// 'description' => 'Whether referrals get Credits on User-Registration or if a User buys credits', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::REFERRAL:PERCENTAGE', -// ], [ -// 'value' => 100, -// 'type' => 'integer', -// 'description' => 'The Percentage value a referred user gets.', -// ]); - -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN', -// ], [ -// 'value' => '', -// 'type' => 'string', -// 'description' => 'The Client API Key of an Pterodactyl Admin Account.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:ENABLE_UPGRADE', -// ], [ -// 'value' => 'false', -// 'type' => 'boolean', -// 'description' => 'Enables the updgrade/downgrade feature for servers.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS', -// ], [ -// 'value' => 'true', -// 'type' => 'boolean', -// 'description' => 'Enable creation of new servers', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:CREATION_OF_NEW_USERS', -// ], [ -// 'value' => 'true', -// 'type' => 'boolean', -// 'description' => 'Enable creation of new users', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:SHOW_IMPRINT', -// ], [ - -// 'value' => "false", -// 'type' => 'boolean', -// 'description' => 'Enable imprint in footer.' - -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:SHOW_PRIVACY', -// ], [ - -// 'value' => "false", -// 'type' => 'boolean', -// 'description' => 'Enable privacy policy in footer.' - -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:SHOW_TOS', -// ], [ -// 'value' => 'false', -// 'type' => 'boolean', -// 'description' => 'Enable Terms of Service in footer.', -// ]); - -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:ALERT_ENABLED', -// ], [ -// 'value' => 'false', -// 'type' => 'boolean', -// 'description' => 'Enable Alerts on Homepage.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:ALERT_TYPE', -// ], [ -// 'value' => 'dark', -// 'type' => 'text', -// 'description' => 'Changes the Color of the Alert.', -// ]); - -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:ALERT_MESSAGE', -// ], [ -// 'value' => '', -// 'type' => 'text', -// 'description' => 'Changes the Content the Alert.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:THEME', -// ], [ -// 'value' => 'default', -// 'type' => 'text', -// 'description' => 'Current active theme.', -// ]); - -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:USEFULLINKS_ENABLED', -// ], [ -// 'value' => 'true', -// 'type' => 'boolean', -// 'description' => 'Enable Useful Links on Homepage.', -// ]); - -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:MOTD_ENABLED', -// ], [ -// 'value' => 'true', -// 'type' => 'boolean', -// 'description' => 'Enable MOTD on Homepage.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:MOTD_MESSAGE', -// ], [ -// 'value' => '

Controlpanel.gg

-//

Thank you for using our Software

-//

If you have any questions, make sure to join our Discord

-//

(you can change this message in the Settings )

', -// 'type' => 'text', -// 'description' => 'MOTD Message.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:SEO_TITLE', -// ], [ -// 'value' => 'Controlpanel.gg', -// 'type' => 'text', -// 'description' => 'The SEO Title.', -// ]); - -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::SYSTEM:SEO_DESCRIPTION', -// ], [ -// 'value' => 'Billing software for Pterodactyl Dashboard!', -// 'type' => 'text', -// 'description' => 'SEO Description.', -// ]); -// Settings::firstOrCreate([ -// 'key' => 'SETTINGS::TICKET:NOTIFY', -// ], [ -// 'value' => 'all', -// 'type' => 'text', -// 'description' => 'Who will get a Email Notifcation on new Tickets.', -// ]); - } -} From 16ca76090118d067cbb2e05e0446984dd4990790 Mon Sep 17 00:00:00 2001 From: Ferks-FK Date: Fri, 3 Feb 2023 16:38:03 +0000 Subject: [PATCH 008/120] Several modifications, something already works --- ...{Pterodactyl.php => PterodactylClient.php} | 113 ++++--- .../Controllers/Admin/OverViewController.php | 21 +- app/Http/Controllers/HomeController.php | 8 +- app/Models/{ => Pterodactyl}/Egg.php | 11 +- app/Models/{ => Pterodactyl}/Location.php | 7 +- app/Models/{ => Pterodactyl}/Nest.php | 7 +- app/Models/{ => Pterodactyl}/Node.php | 7 +- app/Settings/DiscordSettings.php | 9 + app/Settings/GeneralSettings.php | 37 ++- app/Settings/MailSettings.php | 7 + app/Settings/PterodactylSettings.php | 18 ++ themes/default/views/home.blade.php | 295 ++++++++++-------- 12 files changed, 328 insertions(+), 212 deletions(-) rename app/Classes/{Pterodactyl.php => PterodactylClient.php} (71%) rename app/Models/{ => Pterodactyl}/Egg.php (92%) rename app/Models/{ => Pterodactyl}/Location.php (92%) rename app/Models/{ => Pterodactyl}/Nest.php (92%) rename app/Models/{ => Pterodactyl}/Node.php (93%) diff --git a/app/Classes/Pterodactyl.php b/app/Classes/PterodactylClient.php similarity index 71% rename from app/Classes/Pterodactyl.php rename to app/Classes/PterodactylClient.php index 89ae028c..8aa85a35 100644 --- a/app/Classes/Pterodactyl.php +++ b/app/Classes/PterodactylClient.php @@ -2,46 +2,63 @@ namespace App\Classes; -use App\Models\Egg; -use App\Models\Nest; -use App\Models\Node; +use App\Models\Pterodactyl\Egg; +use App\Models\Pterodactyl\Nest; +use App\Models\Pterodactyl\Node; use App\Models\Product; use App\Models\Server; -use App\Models\User; use Exception; use Illuminate\Http\Client\PendingRequest; use Illuminate\Http\Client\Response; use Illuminate\Support\Facades\Http; +use App\Settings\PterodactylSettings; -class Pterodactyl +class PterodactylClient { //TODO: Extend error handling (maybe logger for more errors when debugging) + public int $per_page_limit = 200; + + public PendingRequest $client; + + public PendingRequest $client_admin; + + public function __construct(PterodactylSettings $ptero_settings) + { + try { + $this->client = $this->client($ptero_settings); + $this->client_admin = $this->clientAdmin($ptero_settings); + $this->per_page_limit = $ptero_settings->per_page_limit; + } + catch (Exception $exception) { + logger('Failed to construct Pterodactyl client, Settings table not available?', ['exception' => $exception]); + } + } /** * @return PendingRequest */ - public static function client() + public function client(PterodactylSettings $ptero_settings) { return Http::withHeaders([ - 'Authorization' => 'Bearer ' . config('SETTINGS::SYSTEM:PTERODACTYL:TOKEN'), + 'Authorization' => 'Bearer ' . $ptero_settings->user_token, 'Content-type' => 'application/json', 'Accept' => 'Application/vnd.pterodactyl.v1+json', - ])->baseUrl(config('SETTINGS::SYSTEM:PTERODACTYL:URL') . '/api'); + ])->baseUrl($ptero_settings->getUrl() . 'api' . '/'); } - public static function clientAdmin() + public function clientAdmin(PterodactylSettings $ptero_settings) { return Http::withHeaders([ - 'Authorization' => 'Bearer ' . config('SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN'), + 'Authorization' => 'Bearer ' . $ptero_settings->admin_token, 'Content-type' => 'application/json', 'Accept' => 'Application/vnd.pterodactyl.v1+json', - ])->baseUrl(config('SETTINGS::SYSTEM:PTERODACTYL:URL') . '/api'); + ])->baseUrl($ptero_settings->getUrl() . 'api' . '/'); } /** * @return Exception */ - private static function getException(string $message = '', int $status = 0): Exception + private function getException(string $message = '', int $status = 0): Exception { if ($status == 404) { return new Exception('Ressource does not exist on pterodactyl - ' . $message, 404); @@ -68,10 +85,10 @@ class Pterodactyl * * @throws Exception */ - public static function getEggs(Nest $nest) + public function getEggs(Nest $nest) { try { - $response = self::client()->get("/application/nests/{$nest->id}/eggs?include=nest,variables&per_page=" . config('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT')); + $response = $this->client_admin->get("application/nests/{$nest->id}/eggs?include=nest,variables&per_page=" . $this->per_page_limit); } catch (Exception $e) { throw self::getException($e->getMessage()); } @@ -87,10 +104,10 @@ class Pterodactyl * * @throws Exception */ - public static function getNodes() + public function getNodes() { try { - $response = self::client()->get('/application/nodes?per_page=' . config('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT')); + $response = $this->client_admin->get('application/nodes?per_page=' . $this->per_page_limit); } catch (Exception $e) { throw self::getException($e->getMessage()); } @@ -107,10 +124,10 @@ class Pterodactyl * @throws Exception * @description Returns the infos of a single node */ - public static function getNode($id) + public function getNode($id) { try { - $response = self::client()->get('/application/nodes/' . $id); + $response = $this->client_admin->get('application/nodes/' . $id); } catch (Exception $e) { throw self::getException($e->getMessage()); } @@ -121,10 +138,10 @@ class Pterodactyl return $response->json()['attributes']; } - public static function getServers() + public function getServers() { try { - $response = self::client()->get('/application/servers?per_page=' . config('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT')); + $response = $this->client_admin->get('application/servers?per_page=' . $this->per_page_limit); } catch (Exception $e) { throw self::getException($e->getMessage()); } @@ -140,10 +157,10 @@ class Pterodactyl * * @throws Exception */ - public static function getNests() + public function getNests() { try { - $response = self::client()->get('/application/nests?per_page=' . config('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT')); + $response = $this->client_admin->get('application/nests?per_page=' . $this->per_page_limit); } catch (Exception $e) { throw self::getException($e->getMessage()); } @@ -159,10 +176,10 @@ class Pterodactyl * * @throws Exception */ - public static function getLocations() + public function getLocations() { try { - $response = self::client()->get('/application/locations?per_page=' . config('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT')); + $response = $this->client_admin->get('application/locations?per_page=' . $this->per_page_limit); } catch (Exception $e) { throw self::getException($e->getMessage()); } @@ -179,7 +196,7 @@ class Pterodactyl * * @throws Exception */ - public static function getFreeAllocationId(Node $node) + public function getFreeAllocationId(Node $node) { return self::getFreeAllocations($node)[0]['attributes']['id'] ?? null; } @@ -190,7 +207,7 @@ class Pterodactyl * * @throws Exception */ - public static function getFreeAllocations(Node $node) + public function getFreeAllocations(Node $node) { $response = self::getAllocations($node); $freeAllocations = []; @@ -214,11 +231,11 @@ class Pterodactyl * * @throws Exception */ - public static function getAllocations(Node $node) + public function getAllocations(Node $node) { $per_page = config('SETTINGS::SERVER:ALLOCATION_LIMIT', 200); try { - $response = self::client()->get("/application/nodes/{$node->id}/allocations?per_page={$per_page}"); + $response = $this->client_admin->get("application/nodes/{$node->id}/allocations?per_page={$per_page}"); } catch (Exception $e) { throw self::getException($e->getMessage()); } @@ -233,7 +250,7 @@ class Pterodactyl * @param string $route * @return string */ - public static function url(string $route): string + public function url(string $route): string { return config('SETTINGS::SYSTEM:PTERODACTYL:URL') . $route; } @@ -244,9 +261,9 @@ class Pterodactyl * @param int $allocationId * @return Response */ - public static function createServer(Server $server, Egg $egg, int $allocationId) + public function createServer(Server $server, Egg $egg, int $allocationId) { - return self::client()->post('/application/servers', [ + return $this->client_admin->post('application/servers', [ 'name' => $server->name, 'external_id' => $server->id, 'user' => $server->user->pterodactyl_id, @@ -272,10 +289,10 @@ class Pterodactyl ]); } - public static function suspendServer(Server $server) + public function suspendServer(Server $server) { try { - $response = self::client()->post("/application/servers/$server->pterodactyl_id/suspend"); + $response = $this->client_admin->post("application/servers/$server->pterodactyl_id/suspend"); } catch (Exception $e) { throw self::getException($e->getMessage()); } @@ -286,10 +303,10 @@ class Pterodactyl return $response; } - public static function unSuspendServer(Server $server) + public function unSuspendServer(Server $server) { try { - $response = self::client()->post("/application/servers/$server->pterodactyl_id/unsuspend"); + $response = $this->client_admin->post("application/servers/$server->pterodactyl_id/unsuspend"); } catch (Exception $e) { throw self::getException($e->getMessage()); } @@ -309,7 +326,7 @@ class Pterodactyl public function getUser(int $pterodactylId) { try { - $response = self::client()->get("/application/users/{$pterodactylId}"); + $response = $this->client_admin->get("application/users/{$pterodactylId}"); } catch (Exception $e) { throw self::getException($e->getMessage()); } @@ -326,10 +343,10 @@ class Pterodactyl * @param int $pterodactylId * @return mixed */ - public static function getServerAttributes(int $pterodactylId, bool $deleteOn404 = false) + public function getServerAttributes(int $pterodactylId, bool $deleteOn404 = false) { try { - $response = self::client()->get("/application/servers/{$pterodactylId}?include=egg,node,nest,location"); + $response = $this->client_admin->get("application/servers/{$pterodactylId}?include=egg,node,nest,location"); } catch (Exception $e) { throw self::getException($e->getMessage()); } @@ -356,9 +373,9 @@ class Pterodactyl * @param Product $product * @return Response */ - public static function updateServer(Server $server, Product $product) + public function updateServer(Server $server, Product $product) { - return self::client()->patch("/application/servers/{$server->pterodactyl_id}/build", [ + return $this->client_admin->patch("application/servers/{$server->pterodactyl_id}/build", [ 'allocation' => $server->allocation, 'memory' => $product->memory, 'swap' => $product->swap, @@ -381,9 +398,9 @@ class Pterodactyl * @param Server $server * @return mixed */ - public static function updateServerOwner(Server $server, int $userId) + public function updateServerOwner(Server $server, int $userId) { - return self::client()->patch("/application/servers/{$server->pterodactyl_id}/details", [ + return $this->client_admin->patch("application/servers/{$server->pterodactyl_id}/details", [ 'name' => $server->name, 'user' => $userId, ]); @@ -396,9 +413,9 @@ class Pterodactyl * @param string $action * @return Response */ - public static function powerAction(Server $server, $action) + public function powerAction(Server $server, $action) { - return self::clientAdmin()->post("/client/servers/{$server->identifier}/power", [ + return $this->client->post("client/servers/{$server->identifier}/power", [ 'signal' => $action, ]); } @@ -406,9 +423,9 @@ class Pterodactyl /** * Get info about user */ - public static function getClientUser() + public function getClientUser() { - return self::clientAdmin()->get('/client/account'); + return $this->client->get('client/account'); } /** @@ -419,10 +436,10 @@ class Pterodactyl * @param int $requireDisk * @return bool */ - public static function checkNodeResources(Node $node, int $requireMemory, int $requireDisk) + public function checkNodeResources(Node $node, int $requireMemory, int $requireDisk) { try { - $response = self::client()->get("/application/nodes/{$node->id}"); + $response = $this->client_admin->get("application/nodes/{$node->id}"); } catch (Exception $e) { throw self::getException($e->getMessage()); } diff --git a/app/Http/Controllers/Admin/OverViewController.php b/app/Http/Controllers/Admin/OverViewController.php index 280b59d4..8f89b587 100644 --- a/app/Http/Controllers/Admin/OverViewController.php +++ b/app/Http/Controllers/Admin/OverViewController.php @@ -2,12 +2,13 @@ namespace App\Http\Controllers\Admin; -use App\Classes\Pterodactyl; +use App\Classes\PterodactylClient; +use App\Settings\PterodactylSettings; use App\Http\Controllers\Controller; -use App\Models\Egg; -use App\Models\Location; -use App\Models\Nest; -use App\Models\Node; +use App\Models\Pterodactyl\Egg; +use App\Models\Pterodactyl\Location; +use App\Models\Pterodactyl\Nest; +use App\Models\Pterodactyl\Node; use App\Models\Payment; use App\Models\Product; use App\Models\Server; @@ -19,8 +20,10 @@ class OverViewController extends Controller { public const TTL = 86400; - public function index() + public function index(PterodactylSettings $ptero_settings) { + //Prepare pterodactyl client + $pterodactyl_client = new PterodactylClient($ptero_settings); //Get counters $counters = collect(); //Set basic variables in the collection @@ -134,7 +137,7 @@ class OverViewController extends Controller //Get node information and prepare collection $pteroNodeIds = []; - foreach (Pterodactyl::getNodes() as $pteroNode) { + foreach ($pterodactyl_client->getNodes() as $pteroNode) { array_push($pteroNodeIds, $pteroNode['attributes']['id']); } $nodes = collect(); @@ -145,7 +148,7 @@ class OverViewController extends Controller } //Check if node exists on pterodactyl too, if not, skip $nodes->put($nodeId, collect()); $nodes[$nodeId]->name = $DBnode['name']; - $pteroNode = Pterodactyl::getNode($nodeId); + $pteroNode = $pterodactyl_client->getNode($nodeId); $nodes[$nodeId]->usagePercent = round(max($pteroNode['allocated_resources']['memory'] / ($pteroNode['memory'] * ($pteroNode['memory_overallocate'] + 100) / 100), $pteroNode['allocated_resources']['disk'] / ($pteroNode['disk'] * ($pteroNode['disk_overallocate'] + 100) / 100)) * 100, 2); $counters['totalUsagePercent'] += $nodes[$nodeId]->usagePercent; @@ -156,7 +159,7 @@ class OverViewController extends Controller } $counters['totalUsagePercent'] = ($DBnodes->count()) ? round($counters['totalUsagePercent'] / $DBnodes->count(), 2) : 0; - foreach (Pterodactyl::getServers() as $server) { //gets all servers from Pterodactyl and calculates total of credit usage for each node separately + total + foreach ($pterodactyl_client->getServers() as $server) { //gets all servers from Pterodactyl and calculates total of credit usage for each node separately + total $nodeId = $server['attributes']['node']; if ($CPServer = Server::query()->where('pterodactyl_id', $server['attributes']['id'])->first()) { diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 5a511758..dc2de500 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -11,6 +11,9 @@ use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\URL; +use App\Settings\GeneralSettings; +use App\Settings\WebsiteSettings; +use App\Settings\ReferralSettings; class HomeController extends Controller { @@ -87,7 +90,7 @@ class HomeController extends Controller } /** Show the application dashboard. */ - public function index(Request $request) + public function index(GeneralSettings $general_settings, WebsiteSettings $website_settings, ReferralSettings $referral_settings) { $usage = Auth::user()->creditUsage(); $credits = Auth::user()->Credits(); @@ -118,6 +121,9 @@ class HomeController extends Controller 'numberOfReferrals' => DB::table('user_referrals')->where('referral_id', '=', Auth::user()->id)->count(), 'partnerDiscount' => PartnerDiscount::where('user_id', Auth::user()->id)->first(), 'myDiscount' => PartnerDiscount::getDiscount(), + 'general_settings' => $general_settings, + 'website_settings' => $website_settings, + 'referral_settings' => $referral_settings ]); } } diff --git a/app/Models/Egg.php b/app/Models/Pterodactyl/Egg.php similarity index 92% rename from app/Models/Egg.php rename to app/Models/Pterodactyl/Egg.php index 23bf34ef..55170045 100644 --- a/app/Models/Egg.php +++ b/app/Models/Pterodactyl/Egg.php @@ -1,12 +1,13 @@ each(function (Nest $nest) { - $eggs = Pterodactyl::getEggs($nest); + $client = app(PterodactylClient::class); + Nest::all()->each(function (Nest $nest) use ($client) { + $eggs = $client->getEggs($nest); foreach ($eggs as $egg) { $array = []; diff --git a/app/Models/Location.php b/app/Models/Pterodactyl/Location.php similarity index 92% rename from app/Models/Location.php rename to app/Models/Pterodactyl/Location.php index a020c73f..8d4bf7c1 100644 --- a/app/Models/Location.php +++ b/app/Models/Pterodactyl/Location.php @@ -1,8 +1,8 @@ getLocations(); //map response $locations = array_map(function ($val) { diff --git a/app/Models/Nest.php b/app/Models/Pterodactyl/Nest.php similarity index 92% rename from app/Models/Nest.php rename to app/Models/Pterodactyl/Nest.php index 06c5ce26..699c52db 100644 --- a/app/Models/Nest.php +++ b/app/Models/Pterodactyl/Nest.php @@ -1,8 +1,8 @@ getNests(); //map response $nests = array_map(function ($nest) { diff --git a/app/Models/Node.php b/app/Models/Pterodactyl/Node.php similarity index 93% rename from app/Models/Node.php rename to app/Models/Pterodactyl/Node.php index 01eee0ea..d66dbce3 100644 --- a/app/Models/Node.php +++ b/app/Models/Pterodactyl/Node.php @@ -1,8 +1,8 @@ getNodes(); //map response $nodes = array_map(function ($node) { diff --git a/app/Settings/DiscordSettings.php b/app/Settings/DiscordSettings.php index 3065c05c..bcc51498 100644 --- a/app/Settings/DiscordSettings.php +++ b/app/Settings/DiscordSettings.php @@ -22,4 +22,13 @@ class DiscordSettings extends Settings { return 'discord'; } + + public static function encrypted(): array + { + return [ + 'bot_token', + 'client_id', + 'client_secret' + ]; + } } \ No newline at end of file diff --git a/app/Settings/GeneralSettings.php b/app/Settings/GeneralSettings.php index 19ebf8ba..e311986f 100644 --- a/app/Settings/GeneralSettings.php +++ b/app/Settings/GeneralSettings.php @@ -6,24 +6,43 @@ use Spatie\LaravelSettings\Settings; class GeneralSettings extends Settings { - //instead of showing Credits, show something like example 'Emeralds' - public string $credits_display_name; - //url to the main site public string $main_site; - //check the ip during register for dupes - public bool $register_ip_check; + public string $credits_display_name; - //the initial amount of credits given to the user on register public float $initial_user_credits; - //the initial amount of credits given to the user on register - public float $initial_server_limit; - //the initial role given to the user on register + + public int $initial_server_limit; + + public string $recaptcha_site_key; + + public string $recaptcha_secret_key; + + public bool $recaptcha_enabled; + + public string $phpmyadmin_url; + + public bool $alert_enabled; + + public string $alert_type; + + public string $alert_message; + + public string $theme; + //public int $initial_user_role; wait for Roles & Permissions PR. public static function group(): string { return 'general'; } + + public static function encrypted(): array + { + return [ + 'recaptcha_site_key', + 'recaptcha_secret_key' + ]; + } } \ No newline at end of file diff --git a/app/Settings/MailSettings.php b/app/Settings/MailSettings.php index 173a1f63..2cb8ced8 100644 --- a/app/Settings/MailSettings.php +++ b/app/Settings/MailSettings.php @@ -28,4 +28,11 @@ class MailSettings extends Settings { return 'mail'; } + + public static function encrypted(): array + { + return [ + 'mail_password' + ]; + } } \ No newline at end of file diff --git a/app/Settings/PterodactylSettings.php b/app/Settings/PterodactylSettings.php index d982e529..c705f1ea 100644 --- a/app/Settings/PterodactylSettings.php +++ b/app/Settings/PterodactylSettings.php @@ -18,4 +18,22 @@ class PterodactylSettings extends Settings { return 'pterodactyl'; } + + public static function encrypted(): array + { + return [ + 'admin_token', + 'user_token' + ]; + } + + /** + * Get url with ensured ending backslash + * + * @return string + */ + public function getUrl(): string + { + return str_ends_with($this->panel_url, '/') ? $this->panel_url : $this->panel_url . '/'; + } } \ No newline at end of file diff --git a/themes/default/views/home.blade.php b/themes/default/views/home.blade.php index 720e39aa..69c14089 100644 --- a/themes/default/views/home.blade.php +++ b/themes/default/views/home.blade.php @@ -18,18 +18,19 @@ - @if(!file_exists(base_path()."/install.lock") && Auth::User()->role == "admin") + @if (!file_exists(base_path() . '/install.lock') && Auth::User()->role == 'admin')

{{ __('The installer is not locked!') }}

-

{{ __('please create a file called "install.lock" in your dashboard Root directory. Otherwise no settings will be loaded!') }}

- +

{{ __('please create a file called "install.lock" in your dashboard Root directory. Otherwise no settings will be loaded!') }} +

+
@endif - @if(config("SETTINGS::SYSTEM:ALERT_ENABLED") && !empty(config("SETTINGS::SYSTEM:ALERT_MESSAGE"))) - - @if ($credits > 0.01 and $usage > 0) + @if ($credits > 0.01 && $usage > 0)
{{ __('Out of Credits in', ['credits' => CREDITS_DISPLAY_NAME]) }} + class="info-box-text">{{ __('Out of Credits in', ['credits' => $general_settings->credits_display_name]) }} {{ $boxText }}{{ $unit }}
@@ -106,7 +108,7 @@
- @if(config("SETTINGS::SYSTEM:MOTD_ENABLED") == "true") + @if ($website_settings->motd_enabled)

@@ -116,27 +118,43 @@

- {!! config('SETTINGS::SYSTEM:MOTD_MESSAGE', '') !!} + {!! $website_settings->motd_message !!}
@endif - @if(config("SETTINGS::SYSTEM:USEFULLINKS_ENABLED") == "true") -
-
-

- - {{ __('Useful Links') }} -

+ @if ($website_settings->useful_links_enabled) +
+
+

+ + {{ __('Useful Links') }} +

+
+ +
+ @foreach ($useful_links as $useful_link) +
+ +
+ + {{ $useful_link->title }} + +
+ {!! $useful_link->description !!} +
+ @endforeach +
+
@foreach ($useful_links_dashboard as $useful_link) -
- @endif -
- + @endif + +
+ -
+
+
+
+

+ + {{ __('Activity Logs') }} +

+
+ +
+
    + @foreach (Auth::user()->actions()->take(8)->orderBy('created_at', 'desc')->get() as $log) +
  • + + @if (str_starts_with($log->description, 'created')) + + @elseif(str_starts_with($log->description, 'redeemed')) + + @elseif(str_starts_with($log->description, 'deleted')) + + @elseif(str_starts_with($log->description, 'gained')) + + @elseif(str_starts_with($log->description, 'updated')) + + @endif + {{ explode('\\', $log->subject_type)[2] }} + {{ ucfirst($log->description) }} + + + {{ $log->created_at->diffForHumans() }} + +
  • + @endforeach +
+
+ +
+ + @if ($referral_settings->enabled) +

- - {{ __('Activity Logs') }} + + {{ __('Partner program') }}

-
    - @foreach (Auth::user()->actions()->take(8)->orderBy('created_at', 'desc')->get() as $log) -
  • - - @if(str_starts_with($log->description,"created")) - - @elseif(str_starts_with($log->description,"redeemed")) - - @elseif(str_starts_with($log->description,"deleted")) - - @elseif(str_starts_with($log->description,"gained")) - - @elseif(str_starts_with($log->description,"updated")) - - @endif - {{ explode('\\', $log->subject_type)[2] }} - {{ ucfirst($log->description) }} + @if ( + ($referral_settings->allowed == 'client' && Auth::user()->role != 'member') || + $referral_settings->allowed == 'everyone') +
    +
    + + + {{ __('Your referral URL') }}: + + {{ __('Click to copy') }} + - - {{ $log->created_at->diffForHumans() }} - -
  • - @endforeach -
+
+
+ {{ __('Number of referred users:') }} + {{ $numberOfReferrals }} +
+
+ @if ($partnerDiscount) +
+ + + + + + + + + + + + + + + + + +
{{ __('Your discount') }}{{ __('Discount for your new users') }}{{ __('Reward per registered user') }}{{ __('New user payment commision') }}
{{ $partnerDiscount->partner_discount }}%{{ $partnerDiscount->registered_user_discount }}%{{ $referral_settings->reward }} + {{ $general_settings->credits_display_name }}{{ $partnerDiscount->referral_system_commission == -1 ? $referral_settings->percentage : $partnerDiscount->referral_system_commission }}% +
+
+ @else +
+ + + + + + + + + + + + + +
{{ __('Reward per registered user') }}{{ __('New user payment commision') }}
{{ $referral_settings->reward }} + {{ $general_settings->credits_display_name }}{{ $referral_settings->percentage }}%
+
+ @endif + @else + + {{ __('Make a purchase to reveal your referral-URL') }} + @endif
- - @if((config('SETTINGS::REFERRAL::ENABLED') ==true)) -
-
-

- - {{ __('Partner program') }} -

-
- -
- @if((config('SETTINGS::REFERRAL::ALLOWED') == "client" && Auth::user()->role != "member") || config('SETTINGS::REFERRAL::ALLOWED') == "everyone") -
-
- - - {{__("Your referral URL")}}: - - {{__('Click to copy')}} - - -
-
- {{__("Number of referred users:")}} {{$numberOfReferrals}} -
-
- @if($partnerDiscount) -
- - - - - - - - - - - - - - - - - -
{{__('Your discount')}}{{__('Discount for your new users')}}{{__('Reward per registered user')}}{{__('New user payment commision')}}
{{$partnerDiscount->partner_discount}}%{{$partnerDiscount->registered_user_discount}}%{{config('SETTINGS::REFERRAL::REWARD')}} {{config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME')}}{{($partnerDiscount->referral_system_commission==-1)?config('SETTINGS::REFERRAL:PERCENTAGE'):($partnerDiscount->referral_system_commission)}}%
-
- @else -
- - - - - - - - - - - - - -
{{__('Reward per registered user')}}{{__('New user payment commision')}}
{{config('SETTINGS::REFERRAL::REWARD')}} {{config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME')}}{{config('SETTINGS::REFERRAL:PERCENTAGE')}}%
-
- @endif - @else - - {{__("Make a purchase to reveal your referral-URL")}} - @endif -
- -
- @endif - -
- + @endif + +
+
@@ -276,24 +306,27 @@ diff --git a/themes/default/views/admin/store/index.blade.php b/themes/default/views/admin/store/index.blade.php index 66647030..45a0dbe2 100644 --- a/themes/default/views/admin/store/index.blade.php +++ b/themes/default/views/admin/store/index.blade.php @@ -83,7 +83,7 @@ document.addEventListener("DOMContentLoaded", function() { $('#datatable').DataTable({ language: { - url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{ config('app.datatable_locale') }}.json' + url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{ $locale_datatables }}.json' }, processing: true, serverSide: true, diff --git a/themes/default/views/admin/usefullinks/index.blade.php b/themes/default/views/admin/usefullinks/index.blade.php index 5146f10d..da71f1f5 100644 --- a/themes/default/views/admin/usefullinks/index.blade.php +++ b/themes/default/views/admin/usefullinks/index.blade.php @@ -68,7 +68,7 @@ document.addEventListener("DOMContentLoaded", function () { $('#datatable').DataTable({ language: { - url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("SETTINGS::LOCALE:DATATABLES")}}.json' + url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{ $locale_datatables }}.json' }, processing: true, serverSide: true, diff --git a/themes/default/views/admin/users/index.blade.php b/themes/default/views/admin/users/index.blade.php index c1912185..7aa15f09 100644 --- a/themes/default/views/admin/users/index.blade.php +++ b/themes/default/views/admin/users/index.blade.php @@ -75,7 +75,7 @@ document.addEventListener("DOMContentLoaded", function() { $('#datatable').DataTable({ language: { - url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{ config('SETTINGS::LOCALE:DATATABLES') }}.json' + url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{ $locale_datatables }}.json' }, processing: true, serverSide: true, //why was this set to false before? increased loadingtimes by 10 seconds diff --git a/themes/default/views/admin/vouchers/index.blade.php b/themes/default/views/admin/vouchers/index.blade.php index 1f60e9aa..2dd37dff 100644 --- a/themes/default/views/admin/vouchers/index.blade.php +++ b/themes/default/views/admin/vouchers/index.blade.php @@ -70,7 +70,7 @@ document.addEventListener("DOMContentLoaded", function () { $('#datatable').DataTable({ language: { - url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("SETTINGS::LOCALE:DATATABLES")}}.json' + url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{ $locale_datatables }}.json' }, processing: true, serverSide: true, diff --git a/themes/default/views/admin/vouchers/users.blade.php b/themes/default/views/admin/vouchers/users.blade.php index 284dc1c3..62b44358 100644 --- a/themes/default/views/admin/vouchers/users.blade.php +++ b/themes/default/views/admin/vouchers/users.blade.php @@ -63,7 +63,7 @@ document.addEventListener("DOMContentLoaded", function() { $('#datatable').DataTable({ language: { - url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("SETTINGS::LOCALE:DATATABLES")}}.json' + url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{ $locale_datatables }}.json' }, processing: true, serverSide: true, diff --git a/themes/default/views/auth/login.blade.php b/themes/default/views/auth/login.blade.php index d0f45635..720effd5 100644 --- a/themes/default/views/auth/login.blade.php +++ b/themes/default/views/auth/login.blade.php @@ -1,20 +1,20 @@ @extends('layouts.app') @section('content') - + @php($website_settings = app(App\Settings\WebsiteSettings::class))