feat: implement laravel-settings
This commit is contained in:
parent
c8e82ca57b
commit
2229586b58
19 changed files with 1366 additions and 710 deletions
|
@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
29
app/Settings/GeneralSettings.php
Normal file
29
app/Settings/GeneralSettings.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Settings;
|
||||
|
||||
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;
|
||||
|
||||
//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_user_role; wait for Roles & Permissions PR.
|
||||
|
||||
public static function group(): string
|
||||
{
|
||||
return 'general';
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@
|
|||
"socialiteproviders/discord": "^4.1",
|
||||
"spatie/laravel-activitylog": "^4.4",
|
||||
"spatie/laravel-query-builder": "^5.0",
|
||||
"spatie/laravel-settings": "^2.7",
|
||||
"spatie/laravel-validation-rules": "^3.2",
|
||||
"stripe/stripe-php": "^7.107",
|
||||
"symfony/http-client": "^6.2",
|
||||
|
|
261
composer.lock
generated
261
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "d98e4be75e05c71049fe452b69b54901",
|
||||
"content-hash": "b50b40434baf04e2debcda249af7b595",
|
||||
"packages": [
|
||||
{
|
||||
"name": "aws/aws-crt-php",
|
||||
|
@ -3672,6 +3672,114 @@
|
|||
},
|
||||
"time": "2022-09-06T12:16:56+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/reflection-common",
|
||||
"version": "2.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpDocumentor/ReflectionCommon.git",
|
||||
"reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b",
|
||||
"reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2 || ^8.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-2.x": "2.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"phpDocumentor\\Reflection\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jaap van Otterdijk",
|
||||
"email": "opensource@ijaap.nl"
|
||||
}
|
||||
],
|
||||
"description": "Common reflection classes used by phpdocumentor to reflect the code structure",
|
||||
"homepage": "http://www.phpdoc.org",
|
||||
"keywords": [
|
||||
"FQSEN",
|
||||
"phpDocumentor",
|
||||
"phpdoc",
|
||||
"reflection",
|
||||
"static analysis"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/phpDocumentor/ReflectionCommon/issues",
|
||||
"source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x"
|
||||
},
|
||||
"time": "2020-06-27T09:03:43+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/type-resolver",
|
||||
"version": "1.6.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpDocumentor/TypeResolver.git",
|
||||
"reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/48f445a408c131e38cab1c235aa6d2bb7a0bb20d",
|
||||
"reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.4 || ^8.0",
|
||||
"phpdocumentor/reflection-common": "^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-tokenizer": "*",
|
||||
"phpstan/extension-installer": "^1.1",
|
||||
"phpstan/phpstan": "^1.8",
|
||||
"phpstan/phpstan-phpunit": "^1.1",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"rector/rector": "^0.13.9",
|
||||
"vimeo/psalm": "^4.25"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-1.x": "1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"phpDocumentor\\Reflection\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Mike van Riel",
|
||||
"email": "me@mikevanriel.com"
|
||||
}
|
||||
],
|
||||
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
|
||||
"support": {
|
||||
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
|
||||
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.2"
|
||||
},
|
||||
"time": "2022-10-14T12:47:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpoption/phpoption",
|
||||
"version": "1.9.0",
|
||||
|
@ -4922,6 +5030,94 @@
|
|||
],
|
||||
"time": "2022-12-02T21:28:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/laravel-settings",
|
||||
"version": "2.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/spatie/laravel-settings.git",
|
||||
"reference": "de44cabab1c3ae4f973214c24816db4750c80bd9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/spatie/laravel-settings/zipball/de44cabab1c3ae4f973214c24816db4750c80bd9",
|
||||
"reference": "de44cabab1c3ae4f973214c24816db4750c80bd9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/dbal": "^2.13|^3.2",
|
||||
"ext-json": "*",
|
||||
"illuminate/database": "^8.73|^9.0|^10.0",
|
||||
"php": "^7.4|^8.0",
|
||||
"phpdocumentor/type-resolver": "^1.5",
|
||||
"spatie/temporary-directory": "^1.3|^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-redis": "*",
|
||||
"mockery/mockery": "^1.4",
|
||||
"nunomaduro/larastan": "^2.0",
|
||||
"orchestra/testbench": "^6.23|^7.0|^8.0",
|
||||
"pestphp/pest": "^1.21",
|
||||
"pestphp/pest-plugin-laravel": "^1.2",
|
||||
"phpstan/extension-installer": "^1.1",
|
||||
"phpstan/phpstan-deprecation-rules": "^1.0",
|
||||
"phpstan/phpstan-phpunit": "^1.0",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"spatie/laravel-data": "^1.0.0|^2.0.0",
|
||||
"spatie/pest-plugin-snapshots": "^1.1",
|
||||
"spatie/phpunit-snapshot-assertions": "^4.2",
|
||||
"spatie/ray": "^1.36"
|
||||
},
|
||||
"suggest": {
|
||||
"spatie/data-transfer-object": "Allows for DTO casting to settings. (deprecated)"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Spatie\\LaravelSettings\\LaravelSettingsServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Spatie\\LaravelSettings\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ruben Van Assche",
|
||||
"email": "ruben@spatie.be",
|
||||
"homepage": "https://spatie.be",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Store your application settings",
|
||||
"homepage": "https://github.com/spatie/laravel-settings",
|
||||
"keywords": [
|
||||
"laravel-settings",
|
||||
"spatie"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/spatie/laravel-settings/issues",
|
||||
"source": "https://github.com/spatie/laravel-settings/tree/2.7.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://spatie.be/open-source/support-us",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/spatie",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2023-02-01T12:37:09+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/laravel-validation-rules",
|
||||
"version": "3.2.1",
|
||||
|
@ -4994,6 +5190,67 @@
|
|||
],
|
||||
"time": "2022-08-01T11:52:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/temporary-directory",
|
||||
"version": "2.1.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/spatie/temporary-directory.git",
|
||||
"reference": "e2818d871783d520b319c2d38dc37c10ecdcde20"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/spatie/temporary-directory/zipball/e2818d871783d520b319c2d38dc37c10ecdcde20",
|
||||
"reference": "e2818d871783d520b319c2d38dc37c10ecdcde20",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.5"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Spatie\\TemporaryDirectory\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Alex Vanderbist",
|
||||
"email": "alex@spatie.be",
|
||||
"homepage": "https://spatie.be",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Easily create, use and destroy temporary directories",
|
||||
"homepage": "https://github.com/spatie/temporary-directory",
|
||||
"keywords": [
|
||||
"php",
|
||||
"spatie",
|
||||
"temporary-directory"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/spatie/temporary-directory/issues",
|
||||
"source": "https://github.com/spatie/temporary-directory/tree/2.1.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://spatie.be/open-source/support-us",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/spatie",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2022-08-23T07:15:15+00:00"
|
||||
},
|
||||
{
|
||||
"name": "stripe/stripe-php",
|
||||
"version": "v7.128.0",
|
||||
|
@ -10462,5 +10719,5 @@
|
|||
"platform-overrides": {
|
||||
"php": "8.1"
|
||||
},
|
||||
"plugin-api-version": "2.1.0"
|
||||
"plugin-api-version": "2.3.0"
|
||||
}
|
||||
|
|
88
config/settings.php
Normal file
88
config/settings.php
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
use App\Settings\GeneralSettings;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
* Each settings class used in your application must be registered, you can
|
||||
* put them (manually) here.
|
||||
*/
|
||||
'settings' => [
|
||||
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'),
|
||||
];
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->rename('settings_old');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->rename("settings");
|
||||
});
|
||||
}
|
||||
};
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('settings', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
};
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateGeneralSettings extends SettingsMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
// 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', "");
|
||||
}
|
||||
|
||||
public function getOldValue(string $key)
|
||||
{
|
||||
if (DB::table('settings_old')->exists()) {
|
||||
return DB::table('settings_old')->where('key', '=', $key)->get(['value']);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
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->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;
|
||||
}
|
||||
}
|
30
database/settings/2023_02_01_181453_create_mail_settings.php
Normal file
30
database/settings/2023_02_01_181453_create_mail_settings.php
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateMailSettings extends SettingsMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
// Get the user-set configuration values from the old table.
|
||||
$this->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;
|
||||
}
|
||||
}
|
31
database/settings/2023_02_01_181925_create_user_settings.php
Normal file
31
database/settings/2023_02_01_181925_create_user_settings.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateUserSettings extends SettingsMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
public function getOldValue(string $key)
|
||||
{
|
||||
if (DB::table('settings_old')->exists()) {
|
||||
return DB::table('settings_old')->where('key', '=', $key)->get(['value']);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateServerSettings extends SettingsMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
// Get the user-set configuration values from the old table.
|
||||
$this->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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateInvoiceSettings extends SettingsMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
// 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');
|
||||
}
|
||||
|
||||
public function getOldValue(string $key)
|
||||
{
|
||||
if (DB::table('settings_old')->exists()) {
|
||||
return DB::table('settings_old')->where('key', '=', $key)->get(['value']);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
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->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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateLocaleSettings extends SettingsMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
public function getOldValue(string $key)
|
||||
{
|
||||
if (DB::table('settings_old')->exists()) {
|
||||
return DB::table('settings_old')->where('key', '=', $key)->get(['value']);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateReferralSettings extends SettingsMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
public function getOldValue(string $key)
|
||||
{
|
||||
if (DB::table('settings_old')->exists()) {
|
||||
return DB::table('settings_old')->where('key', '=', $key)->get(['value']);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
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) ?: '');
|
||||
}
|
||||
|
||||
public function getOldValue(string $key)
|
||||
{
|
||||
if (DB::table('settings_old')->exists()) {
|
||||
return DB::table('settings_old')->where('key', '=', $key)->get(['value']);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue