diff --git a/app/Classes/Pterodactyl.php b/app/Classes/Pterodactyl.php index 20caa00a..1e5bd646 100644 --- a/app/Classes/Pterodactyl.php +++ b/app/Classes/Pterodactyl.php @@ -2,11 +2,11 @@ namespace App\Classes; -use App\Models\Configuration; use App\Models\Egg; use App\Models\Nest; use App\Models\Node; use App\Models\Server; +use App\Models\Settings; use Exception; use Illuminate\Http\Client\PendingRequest; use Illuminate\Http\Client\Response; @@ -141,7 +141,7 @@ class Pterodactyl */ public static function getAllocations(Node $node) { - $per_page = Configuration::getValueByKey('ALLOCATION_LIMIT', 200); + $per_page = Settings::getValueByKey('SETTINGS::SERVER:ALLOCATION_LIMIT', 200); try { $response = self::client()->get("/application/nodes/{$node->id}/allocations?per_page={$per_page}"); } catch (Exception $e) { diff --git a/app/Http/Controllers/Admin/ConfigurationController.php b/app/Http/Controllers/Admin/ConfigurationController.php deleted file mode 100644 index 1be4bafe..00000000 --- a/app/Http/Controllers/Admin/ConfigurationController.php +++ /dev/null @@ -1,54 +0,0 @@ -input('key')); - - $request->validate([ - 'key' => 'required|string|max:191', - 'value' => 'required|string|max:191', - ]); - - $configuration->update($request->all()); - - return redirect()->route('admin.settings.index')->with('success', __('configuration has been updated!')); - } - - /** - * Remove the specified resource from storage. - * - * @param Configuration $configuration - * @return Response - */ - public function destroy(Configuration $configuration) - { - // - } - - public function datatable() - { - $query = Configuration::query(); - - return datatables($query) - ->addColumn('actions', function (Configuration $configuration) { - return ' '; - }) - ->editColumn('created_at', function (Configuration $configuration) { - return $configuration->created_at ? $configuration->created_at->diffForHumans() : ''; - }) - ->rawColumns(['actions']) - ->make(); - } -} diff --git a/app/Http/Controllers/Admin/PaymentController.php b/app/Http/Controllers/Admin/PaymentController.php index ff882da6..a08dddc7 100644 --- a/app/Http/Controllers/Admin/PaymentController.php +++ b/app/Http/Controllers/Admin/PaymentController.php @@ -4,10 +4,10 @@ namespace App\Http\Controllers\Admin; use App\Events\UserUpdateCreditsEvent; use App\Http\Controllers\Controller; -use App\Models\Configuration; use App\Models\InvoiceSettings; use App\Models\Payment; use App\Models\CreditProduct; +use App\Models\Settings; use App\Models\User; use App\Notifications\InvoiceNotification; use App\Notifications\ConfirmPaymentNotification; @@ -167,9 +167,9 @@ class PaymentController extends Controller $user->increment('credits', $creditProduct->quantity); //update server limit - if (Configuration::getValueByKey('SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) { - if ($user->server_limit < Configuration::getValueByKey('SERVER_LIMIT_AFTER_IRL_PURCHASE')) { - $user->update(['server_limit' => Configuration::getValueByKey('SERVER_LIMIT_AFTER_IRL_PURCHASE')]); + if (Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) { + if ($user->server_limit < Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')) { + $user->update(['server_limit' => Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')]); } } @@ -304,9 +304,9 @@ class PaymentController extends Controller $user->increment('credits', $creditProduct->quantity); //update server limit - if (Configuration::getValueByKey('SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) { - if ($user->server_limit < Configuration::getValueByKey('SERVER_LIMIT_AFTER_IRL_PURCHASE')) { - $user->update(['server_limit' => Configuration::getValueByKey('SERVER_LIMIT_AFTER_IRL_PURCHASE')]); + if (Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) { + if ($user->server_limit < Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')) { + $user->update(['server_limit' => Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')]); } } @@ -398,9 +398,9 @@ class PaymentController extends Controller $user->increment('credits', $payment->amount); //update server limit - if (Configuration::getValueByKey('SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) { - if ($user->server_limit < Configuration::getValueByKey('SERVER_LIMIT_AFTER_IRL_PURCHASE')) { - $user->update(['server_limit' => Configuration::getValueByKey('SERVER_LIMIT_AFTER_IRL_PURCHASE')]); + if (Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) { + if ($user->server_limit < Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')) { + $user->update(['server_limit' => Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')]); } } diff --git a/app/Http/Controllers/Admin/ProductController.php b/app/Http/Controllers/Admin/ProductController.php index bf32069f..6386fe0a 100644 --- a/app/Http/Controllers/Admin/ProductController.php +++ b/app/Http/Controllers/Admin/ProductController.php @@ -3,12 +3,10 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; -use App\Models\Egg; use App\Models\Location; use App\Models\Nest; -use App\Models\Node; -use App\Models\Configuration; use App\Models\Product; +use App\Models\Settings; use Exception; use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\View\Factory; @@ -16,7 +14,6 @@ use Illuminate\Contracts\View\View; use Illuminate\Http\JsonResponse; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class ProductController extends Controller { @@ -97,7 +94,7 @@ class ProductController extends Controller { return view('admin.products.show', [ 'product' => $product, - 'minimum_credits' => Configuration::getValueByKey("MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER"), + 'minimum_credits' => Settings::getValueByKey("SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER"), ]); } diff --git a/app/Http/Controllers/Admin/SettingsControllers/SettingsController.php b/app/Http/Controllers/Admin/SettingsControllers/SettingsController.php index a4b2edc6..e5107e66 100644 --- a/app/Http/Controllers/Admin/SettingsControllers/SettingsController.php +++ b/app/Http/Controllers/Admin/SettingsControllers/SettingsController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin\SettingsControllers; use App\Http\Controllers\Controller; use App\Models\InvoiceSettings; +use App\Models\Settings; use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\View; @@ -85,4 +86,44 @@ class SettingsController extends Controller return redirect()->route('admin.settings.index')->with('success', 'Invoice settings updated!'); } + public function updatevalue(Request $request) + { + $setting = Settings::findOrFail($request->input('key')); + + $request->validate([ + 'key' => 'required|string|max:191', + 'value' => 'required|string|max:191', + ]); + + $setting->update($request->all()); + + return redirect()->route('admin.settings.index')->with('success', __('configuration has been updated!')); + } + + /** + * Remove the specified resource from storage. + * + * @param Settings $setting + * @return Response + */ + public function destroy(Settings $setting) + { + // + } + + public function datatable() + { + $query = Settings::query(); + + return datatables($query) + ->addColumn('actions', function (Settings $setting) { + return ' '; + }) + ->editColumn('created_at', function (Settings $setting) { + return $setting->created_at ? $setting->created_at->diffForHumans() : ''; + }) + ->rawColumns(['actions']) + ->make(); + } + } diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index ff12d850..68757c00 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/app/Http/Controllers/Api/UserController.php @@ -5,8 +5,8 @@ namespace App\Http\Controllers\Api; use App\Classes\Pterodactyl; use App\Events\UserUpdateCreditsEvent; use App\Http\Controllers\Controller; -use App\Models\Configuration; use App\Models\DiscordUser; +use App\Models\Settings; use App\Models\User; use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\Pagination\LengthAwarePaginator; @@ -180,8 +180,8 @@ class UserController extends Controller $user = User::create([ 'name' => $request->input('name'), 'email' => $request->input('email'), - 'credits' => Configuration::getValueByKey('INITIAL_CREDITS', 150), - 'server_limit' => Configuration::getValueByKey('INITIAL_SERVER_LIMIT', 1), + 'credits' => Settings::getValueByKey('SETTINGS::USER:INITIAL_CREDITS', 150), + 'server_limit' => Settings::getValueByKey('SETTINGS::USER:INITIAL_SERVER_LIMIT', 1), 'password' => Hash::make($request->input('password')), ]); diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 4073adef..813e7b02 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -4,7 +4,7 @@ namespace App\Http\Controllers\Auth; use App\Classes\Pterodactyl; use App\Http\Controllers\Controller; -use App\Models\Configuration; +use App\Models\Settings; use App\Models\User; use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Auth\RegistersUsers; @@ -53,7 +53,7 @@ class RegisterController extends Controller */ protected function validator(array $data) { - if (Configuration::getValueByKey('REGISTER_IP_CHECK', 'true') == 'true') { + if (Settings::getValueByKey('SETTINGS::SYSTEM:REGISTER_IP_CHECK', 'true') == 'true') { //check if ip has already made an account $data['ip'] = session()->get('ip') ?? request()->ip(); @@ -90,8 +90,8 @@ class RegisterController extends Controller $user = User::create([ 'name' => $data['name'], 'email' => $data['email'], - 'credits' => Configuration::getValueByKey('INITIAL_CREDITS', 150), - 'server_limit' => Configuration::getValueByKey('INITIAL_SERVER_LIMIT', 1), + 'credits' => Settings::getValueByKey('SETTINGS::USER:INITIAL_CREDITS', 150), + 'server_limit' => Settings::getValueByKey('SETTINGS::USER:INITIAL_SERVER_LIMIT', 1), 'password' => Hash::make($data['password']), ]); diff --git a/app/Http/Controllers/Auth/SocialiteController.php b/app/Http/Controllers/Auth/SocialiteController.php index aa8b93c2..08310231 100644 --- a/app/Http/Controllers/Auth/SocialiteController.php +++ b/app/Http/Controllers/Auth/SocialiteController.php @@ -3,8 +3,8 @@ namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; -use App\Models\Configuration; use App\Models\DiscordUser; +use App\Models\Settings; use App\Models\User; use App\Models\Voucher; use Illuminate\Support\Facades\Auth; @@ -40,8 +40,8 @@ class SocialiteController extends Controller //create discord user in db DiscordUser::create(array_merge($discord->user, ['user_id' => Auth::user()->id])); //update user - Auth::user()->increment('credits', Configuration::getValueByKey('CREDITS_REWARD_AFTER_VERIFY_DISCORD')); - Auth::user()->increment('server_limit', Configuration::getValueByKey('SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD')); + Auth::user()->increment('credits', Settings::getValueByKey('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD')); + Auth::user()->increment('server_limit', Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD')); Auth::user()->update(['discord_verified_at' => now()]); } else { $user->discordUser->update($discord->user); diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 646293ac..d6b2fd18 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -2,10 +2,7 @@ namespace App\Http\Controllers; -use App\Models\Egg; -use App\Models\Product; use App\Models\UsefulLink; -use App\Models\Configuration; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 3ddc1655..f8ac085a 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -2,13 +2,10 @@ namespace App\Http\Controllers; -use App\Models\Configuration; +use App\Models\Settings; use App\Models\User; -use Illuminate\Contracts\View\Factory; -use Illuminate\Contracts\View\View; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; @@ -19,9 +16,9 @@ class ProfileController extends Controller { return view('profile.index')->with([ 'user' => Auth::user(), - 'credits_reward_after_verify_discord' => Configuration::getValueByKey('CREDITS_REWARD_AFTER_VERIFY_DISCORD'), - 'force_email_verification' => Configuration::getValueByKey('FORCE_EMAIL_VERIFICATION'), - 'force_discord_verification' => Configuration::getValueByKey('FORCE_DISCORD_VERIFICATION'), + 'credits_reward_after_verify_discord' => Settings::getValueByKey('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD'), + 'force_email_verification' => Settings::getValueByKey('SETTINGS::USER:FORCE_EMAIL_VERIFICATION'), + 'force_discord_verification' => Settings::getValueByKey('SETTINGS::USER:FORCE_DISCORD_VERIFICATION'), ]); } diff --git a/app/Http/Controllers/ServerController.php b/app/Http/Controllers/ServerController.php index ff096502..61aab37f 100644 --- a/app/Http/Controllers/ServerController.php +++ b/app/Http/Controllers/ServerController.php @@ -3,13 +3,13 @@ namespace App\Http\Controllers; use App\Classes\Pterodactyl; -use App\Models\Configuration; use App\Models\Egg; use App\Models\Location; use App\Models\Nest; use App\Models\Node; use App\Models\Product; use App\Models\Server; +use App\Models\Settings; use App\Notifications\ServerCreationError; use Exception; use Illuminate\Database\Eloquent\Builder; @@ -107,7 +107,7 @@ class ServerController extends Controller if ( Auth::user()->credits < ($product->minimum_credits == -1 - ? Configuration::getValueByKey('MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', 50) + ? Settings::getValueByKey('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', 50) : $product->minimum_credits) ) { return redirect()->route('servers.index')->with('error', "You do not have the required amount of " . CREDITS_DISPLAY_NAME . " to use this product!"); @@ -115,12 +115,12 @@ class ServerController extends Controller } //Required Verification for creating an server - if (Configuration::getValueByKey('FORCE_EMAIL_VERIFICATION', 'false') === 'true' && !Auth::user()->hasVerifiedEmail()) { + if (Settings::getValueByKey('SETTINGS::USER:FORCE_EMAIL_VERIFICATION', 'false') === 'true' && !Auth::user()->hasVerifiedEmail()) { return redirect()->route('profile.index')->with('error', __("You are required to verify your email address before you can create a server.")); } //Required Verification for creating an server - if (Configuration::getValueByKey('FORCE_DISCORD_VERIFICATION', 'false') === 'true' && !Auth::user()->discordUser) { + if (Settings::getValueByKey('SETTINGS::USER:FORCE_DISCORD_VERIFICATION', 'false') === 'true' && !Auth::user()->discordUser) { return redirect()->route('profile.index')->with('error', __("You are required to link your discord account before you can create a server.")); } @@ -168,7 +168,7 @@ class ServerController extends Controller 'identifier' => $serverAttributes['identifier'] ]); - if (Configuration::getValueByKey('SERVER_CREATE_CHARGE_FIRST_HOUR', 'true') == 'true') { + if (Settings::getValueByKey('SETTINGS::SYSTEM:SERVER_CREATE_CHARGE_FIRST_HOUR', 'true') == 'true') { if ($request->user()->credits >= $server->product->getHourlyPrice()) { $request->user()->decrement('credits', $server->product->getHourlyPrice()); } diff --git a/app/Http/Controllers/StoreController.php b/app/Http/Controllers/StoreController.php index c2ce00e8..eac70f98 100644 --- a/app/Http/Controllers/StoreController.php +++ b/app/Http/Controllers/StoreController.php @@ -2,8 +2,8 @@ namespace App\Http\Controllers; -use App\Models\Configuration; use App\Models\CreditProduct; +use App\Models\Settings; use Illuminate\Support\Facades\Auth; class StoreController extends Controller @@ -20,12 +20,12 @@ class StoreController extends Controller ) $isPaymentSetup = true; //Required Verification for creating an server - if (Configuration::getValueByKey('FORCE_EMAIL_VERIFICATION', false) === 'true' && !Auth::user()->hasVerifiedEmail()) { + if (Settings::getValueByKey('SETTINGS::USER:FORCE_EMAIL_VERIFICATION', false) === 'true' && !Auth::user()->hasVerifiedEmail()) { return redirect()->route('profile.index')->with('error', __("You are required to verify your email address before you can purchase credits.")); } //Required Verification for creating an server - if (Configuration::getValueByKey('FORCE_DISCORD_VERIFICATION', false) === 'true' && !Auth::user()->discordUser) { + if (Settings::getValueByKey('SETTINGS::USER:FORCE_DISCORD_VERIFICATION', false) === 'true' && !Auth::user()->discordUser) { return redirect()->route('profile.index')->with('error', __("You are required to link your discord account before you can purchase Credits")); } diff --git a/app/Http/Middleware/GlobalNames.php b/app/Http/Middleware/GlobalNames.php index 519b111d..24d77c27 100644 --- a/app/Http/Middleware/GlobalNames.php +++ b/app/Http/Middleware/GlobalNames.php @@ -3,6 +3,7 @@ namespace App\Http\Middleware; use App\Models\Configuration; +use App\Models\Settings; use Closure; use Illuminate\Http\Request; @@ -17,7 +18,7 @@ class GlobalNames */ public function handle(Request $request, Closure $next) { - define('CREDITS_DISPLAY_NAME' , Configuration::getValueByKey('CREDITS_DISPLAY_NAME' , 'Credits')); + define('CREDITS_DISPLAY_NAME' , Settings::getValueByKey('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME' , 'Credits')); $unsupported_lang_array = explode(',', config("app.unsupported_locales")); $unsupported_lang_array = array_map( 'strtolower', $unsupported_lang_array ); diff --git a/app/Listeners/UnsuspendServers.php b/app/Listeners/UnsuspendServers.php index 51f1ad60..5d8ce069 100644 --- a/app/Listeners/UnsuspendServers.php +++ b/app/Listeners/UnsuspendServers.php @@ -3,11 +3,10 @@ namespace App\Listeners; use App\Events\UserUpdateCreditsEvent; -use App\Models\Configuration; use App\Models\Server; +use App\Models\Settings; use Exception; use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Queue\InteractsWithQueue; class UnsuspendServers implements ShouldQueue { @@ -20,7 +19,7 @@ class UnsuspendServers implements ShouldQueue */ public function handle(UserUpdateCreditsEvent $event) { - if ($event->user->credits > Configuration::getValueByKey('MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER' , 50)){ + if ($event->user->credits > Settings::getValueByKey('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER' , 50)){ /** @var Server $server */ foreach ($event->user->servers as $server){ if ($server->isSuspended()) $server->unSuspend(); diff --git a/app/Listeners/Verified.php b/app/Listeners/Verified.php index b87ff058..875bd4c0 100644 --- a/app/Listeners/Verified.php +++ b/app/Listeners/Verified.php @@ -2,9 +2,7 @@ namespace App\Listeners; -use App\Models\Configuration; -use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Queue\InteractsWithQueue; +use App\Models\Settings; class Verified { @@ -26,7 +24,7 @@ class Verified */ public function handle($event) { - $event->user->increment('server_limit' , Configuration::getValueByKey('SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL')); - $event->user->increment('credits' , Configuration::getValueByKey('CREDITS_REWARD_AFTER_VERIFY_EMAIL')); + $event->user->increment('server_limit' , Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL')); + $event->user->increment('credits' , Settings::getValueByKey('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL')); } } diff --git a/app/Models/CreditProduct.php b/app/Models/CreditProduct.php index 1effeb6f..5fa07b59 100644 --- a/app/Models/CreditProduct.php +++ b/app/Models/CreditProduct.php @@ -59,7 +59,7 @@ class CreditProduct extends Model */ public function getTaxPercent() { - $tax = Configuration::getValueByKey("SALES_TAX"); + $tax = Settings::getValueByKey("SETTINGS::PAYMENTS:SALES_TAX"); return $tax < 0 ? 0 : $tax; } diff --git a/app/Models/Configuration.php b/app/Models/Settings.php similarity index 69% rename from app/Models/Configuration.php rename to app/Models/Settings.php index a07846f2..d0f97cc8 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Settings.php @@ -6,11 +6,11 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Cache; -class Configuration extends Model +class Settings extends Model { use HasFactory; - public const CACHE_TAG = 'configuration'; + public const CACHE_TAG = 'setting'; public $primaryKey = 'key'; @@ -28,8 +28,8 @@ class Configuration extends Model { parent::boot(); - static::updated(function (Configuration $configuration) { - Cache::forget(self::CACHE_TAG .':'. $configuration->key); + static::updated(function (Settings $settings) { + Cache::forget(self::CACHE_TAG .':'. $settings->key); }); } @@ -41,8 +41,8 @@ class Configuration extends Model public static function getValueByKey(string $key, $default = null) { return Cache::rememberForever(self::CACHE_TAG .':'. $key, function () use ($default, $key) { - $configuration = self::find($key); - return $configuration ? $configuration->value : $default; + $settings = self::find($key); + return $settings ? $settings->value : $default; }); } } diff --git a/app/Notifications/ServersSuspendedNotification.php b/app/Notifications/ServersSuspendedNotification.php index c73f8c0d..c6ed279b 100644 --- a/app/Notifications/ServersSuspendedNotification.php +++ b/app/Notifications/ServersSuspendedNotification.php @@ -2,7 +2,6 @@ namespace App\Notifications; -use App\Models\Configuration; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; diff --git a/app/Notifications/WelcomeMessage.php b/app/Notifications/WelcomeMessage.php index 3c730486..d68a517b 100644 --- a/app/Notifications/WelcomeMessage.php +++ b/app/Notifications/WelcomeMessage.php @@ -2,7 +2,7 @@ namespace App\Notifications; -use App\Models\Configuration; +use App\Models\Settings; use App\Models\User; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; @@ -41,18 +41,18 @@ class WelcomeMessage extends Notification implements ShouldQueue { $AdditionalLine = ""; - if(Configuration::getValueByKey('CREDITS_REWARD_AFTER_VERIFY_EMAIL') != 0) { - $AdditionalLine .= "Verifying your e-mail address will grant you ".Configuration::getValueByKey('CREDITS_REWARD_AFTER_VERIFY_EMAIL')." additional " . Configuration::getValueByKey('CREDITS_DISPLAY_NAME') . ".
"; + if(Settings::getValueByKey('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL') != 0) { + $AdditionalLine .= "Verifying your e-mail address will grant you ".Settings::getValueByKey('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL')." additional " . Settings::getValueByKey('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME') . ".
"; } - if(Configuration::getValueByKey('SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL') != 0) { - $AdditionalLine .= "Verifying your e-mail will also increase your Server Limit by " . Configuration::getValueByKey('SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL') . ".
"; + if(Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL') != 0) { + $AdditionalLine .= "Verifying your e-mail will also increase your Server Limit by " . Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL') . ".
"; } $AdditionalLine .="
"; - if(Configuration::getValueByKey('CREDITS_REWARD_AFTER_VERIFY_DISCORD') != 0) { - $AdditionalLine .= "You can also verify your discord account to get another " . Configuration::getValueByKey('CREDITS_REWARD_AFTER_VERIFY_DISCORD') . " " . Configuration::getValueByKey('CREDITS_DISPLAY_NAME') . ".
"; + if(Settings::getValueByKey('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD') != 0) { + $AdditionalLine .= "You can also verify your discord account to get another " . Settings::getValueByKey('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD') . " " . Settings::getValueByKey('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME') . ".
"; } - if(Configuration::getValueByKey('SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD') != 0) { - $AdditionalLine .= "Verifying your Discord account will also increase your Server Limit by " . Configuration::getValueByKey('SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD') . ".
"; + if(Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD') != 0) { + $AdditionalLine .= "Verifying your Discord account will also increase your Server Limit by " . Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD') . ".
"; } return $AdditionalLine; diff --git a/database/migrations/2021_05_08_164658_create_configurations_table.php b/database/migrations/2022_01_05_071039_settings.php similarity index 57% rename from database/migrations/2021_05_08_164658_create_configurations_table.php rename to database/migrations/2022_01_05_071039_settings.php index f353c4aa..d7c0a52a 100644 --- a/database/migrations/2021_05_08_164658_create_configurations_table.php +++ b/database/migrations/2022_01_05_071039_settings.php @@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateConfigurationsTable extends Migration +class Settings extends Migration { /** * Run the migrations. @@ -13,11 +13,12 @@ class CreateConfigurationsTable extends Migration */ public function up() { - Schema::create('configurations', function (Blueprint $table) { - $table->string('key')->primary(); + Schema::create('settings', function (Blueprint $table) { + $table->id(); + $table->string('key'); $table->string('value'); - $table->string('type')->default('string'); - $table->text('description')->nullable(); + $table->string('type'); + $table->string('description'); $table->timestamps(); }); } @@ -29,6 +30,6 @@ class CreateConfigurationsTable extends Migration */ public function down() { - Schema::dropIfExists('configurations'); + Schema::dropIfExists('settings'); } } diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index f275ede7..25db0f88 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -2,7 +2,7 @@ namespace Database\Seeders; -use Database\Seeders\Seeds\ConfigurationSeeder; +use Database\Seeders\Seeds\SettingsSeeder; use Database\Seeders\Seeds\InvoiceSettingsSeeder; use Illuminate\Database\Seeder; @@ -16,7 +16,7 @@ class DatabaseSeeder extends Seeder public function run() { $this->call([ - ConfigurationSeeder::class, + SettingsSeeder::class, ]); } diff --git a/database/seeders/Seeds/ConfigurationSeeder.php b/database/seeders/Seeds/SettingsSeeder.php similarity index 70% rename from database/seeders/Seeds/ConfigurationSeeder.php rename to database/seeders/Seeds/SettingsSeeder.php index 98d3a57a..6e57b1fc 100644 --- a/database/seeders/Seeds/ConfigurationSeeder.php +++ b/database/seeders/Seeds/SettingsSeeder.php @@ -2,10 +2,10 @@ namespace Database\Seeders\Seeds; -use App\Models\Configuration; +use App\Models\Settings; use Illuminate\Database\Seeder; -class ConfigurationSeeder extends Seeder +class SettingsSeeder extends Seeder { /** * Run the database seeds. @@ -15,16 +15,16 @@ class ConfigurationSeeder extends Seeder public function run() { //initials - Configuration::firstOrCreate([ - 'key' => 'INITIAL_CREDITS', + Settings::firstOrCreate([ + 'key' => 'SETTINGS::USER:INITIAL_CREDITS', ], [ 'value' => '250', 'type' => 'integer', 'description' => 'The initial amount of credits the user starts with.' ]); - Configuration::firstOrCreate([ - 'key' => 'INITIAL_SERVER_LIMIT', + Settings::firstOrCreate([ + 'key' => 'SETTINGS::USER:NITIAL_SERVER_LIMIT', ], [ 'value' => '1', 'type' => 'integer', @@ -32,16 +32,16 @@ class ConfigurationSeeder extends Seeder ]); //verify email event - Configuration::firstOrCreate([ - 'key' => 'CREDITS_REWARD_AFTER_VERIFY_EMAIL', + 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.' ]); - Configuration::firstOrCreate([ - 'key' => 'SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL', + Settings::firstOrCreate([ + 'key' => 'SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL', ], [ 'value' => '2', 'type' => 'integer', @@ -49,16 +49,16 @@ class ConfigurationSeeder extends Seeder ]); //verify discord event - Configuration::firstOrCreate([ - 'key' => 'CREDITS_REWARD_AFTER_VERIFY_DISCORD', + 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.' ]); - Configuration::firstOrCreate([ - 'key' => 'SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD', + Settings::firstOrCreate([ + 'key' => 'SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD', ], [ 'value' => '2', 'type' => 'integer', @@ -66,8 +66,8 @@ class ConfigurationSeeder extends Seeder ]); //other - Configuration::firstOrCreate([ - 'key' => 'MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', + Settings::firstOrCreate([ + 'key' => 'SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', ], [ 'value' => '50', 'type' => 'integer', @@ -75,8 +75,8 @@ class ConfigurationSeeder extends Seeder ]); //purchasing - Configuration::firstOrCreate([ - 'key' => 'SERVER_LIMIT_AFTER_IRL_PURCHASE', + Settings::firstOrCreate([ + 'key' => 'SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE', ], [ 'value' => '10', 'type' => 'integer', @@ -85,16 +85,16 @@ class ConfigurationSeeder extends Seeder //force email and discord verification - Configuration::firstOrCreate([ - 'key' => 'FORCE_EMAIL_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.' ]); - Configuration::firstOrCreate([ - 'key' => 'FORCE_DISCORD_VERIFICATION', + Settings::firstOrCreate([ + 'key' => 'SETTINGS::USER:FORCE_DISCORD_VERIFICATION', ], [ 'value' => 'false', 'type' => 'boolean', @@ -102,8 +102,8 @@ class ConfigurationSeeder extends Seeder ]); //disable ip check on register - Configuration::firstOrCreate([ - 'key' => 'REGISTER_IP_CHECK', + Settings::firstOrCreate([ + 'key' => 'SETTINGS::SYSTEM:REGISTER_IP_CHECK', ], [ 'value' => 'true', 'type' => 'boolean', @@ -111,8 +111,8 @@ class ConfigurationSeeder extends Seeder ]); //per_page on allocations request - Configuration::firstOrCreate([ - 'key' => 'ALLOCATION_LIMIT', + Settings::firstOrCreate([ + 'key' => 'SETTINGS::SERVER:ALLOCATION_LIMIT', ], [ 'value' => '200', 'type' => 'integer', @@ -120,8 +120,8 @@ class ConfigurationSeeder extends Seeder ]); //credits display name - Configuration::firstOrCreate([ - 'key' => 'CREDITS_DISPLAY_NAME', + Settings::firstOrCreate([ + 'key' => 'SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME', ], [ 'value' => 'Credits', 'type' => 'string', @@ -129,16 +129,16 @@ class ConfigurationSeeder extends Seeder ]); //credits display name - Configuration::firstOrCreate([ - 'key' => 'SERVER_CREATE_CHARGE_FIRST_HOUR', + 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 - Configuration::firstOrCreate([ - 'key' => 'SALES_TAX', + Settings::firstOrCreate([ + 'key' => 'SETTINGS::PAYMENTS:SALES_TAX', ], [ 'value' => '0', 'type' => 'integer', diff --git a/resources/views/admin/settings/tabs/configurations.blade.php b/resources/views/admin/settings/tabs/configurations.blade.php index 526acd5d..0d7e8ccc 100644 --- a/resources/views/admin/settings/tabs/configurations.blade.php +++ b/resources/views/admin/settings/tabs/configurations.blade.php @@ -22,7 +22,7 @@