浏览代码

ability to slam all settings into one database

1Day 3 年之前
父节点
当前提交
63888f11e5

+ 2 - 2
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) {

+ 0 - 54
app/Http/Controllers/Admin/ConfigurationController.php

@@ -1,54 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Admin;
-
-use App\Models\Configuration;
-use Illuminate\Http\Request;
-use Illuminate\Http\Response;
-
-class ConfigurationController
-{
-    /**
-     * @param Request $request
-     * @return \Illuminate\Http\RedirectResponse
-     */
-    public function updatevalue(Request $request)
-    {
-        $configuration = Configuration::findOrFail($request->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 '<button data-content="' . __("Edit") . '" data-toggle="popover" data-trigger="hover" data-placement="top" onclick="configuration.parse(\'' . $configuration->key . '\',\'' . $configuration->value . '\',\'' . $configuration->type . '\')" data-content="Edit" data-trigger="hover" data-toggle="tooltip" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></button> ';
-            })
-            ->editColumn('created_at', function (Configuration $configuration) {
-                return $configuration->created_at ? $configuration->created_at->diffForHumans() : '';
-            })
-            ->rawColumns(['actions'])
-            ->make();
-    }
-}

+ 10 - 10
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')]);
                     }
                 }
 

+ 2 - 5
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"),
         ]);
     }
 

+ 41 - 0
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 '<button data-content="' . __("Edit") . '" data-toggle="popover" data-trigger="hover" data-placement="top" onclick="configuration.parse(\'' . $setting->key . '\',\'' . $setting->value . '\',\'' . $setting->type . '\')" data-content="Edit" data-trigger="hover" data-toggle="tooltip" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></button> ';
+            })
+            ->editColumn('created_at', function (Settings $setting) {
+                return $setting->created_at ? $setting->created_at->diffForHumans() : '';
+            })
+            ->rawColumns(['actions'])
+            ->make();
+    }
+
 }

+ 3 - 3
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')),
         ]);
 

+ 4 - 4
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']),
         ]);
 

+ 3 - 3
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);

+ 0 - 3
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;
 

+ 4 - 7
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'),
         ]);
     }
 

+ 5 - 5
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());
             }

+ 3 - 3
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"));
         }
 

+ 2 - 1
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 );

+ 2 - 3
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();

+ 3 - 5
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'));
     }
 }

+ 1 - 1
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;
     }
 

+ 6 - 6
app/Models/Configuration.php → 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;
         });
     }
 }

+ 0 - 1
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;

+ 9 - 9
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') . ". <br />";
+            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') . ". <br />";
             }
-            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') . ". <br />";
+            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') . ". <br />";
             }
             $AdditionalLine .="<br />";
-            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') . ". <br />";
+            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') . ". <br />";
             }
-            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') . ". <br />";
+            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') . ". <br />";
             }
 
             return $AdditionalLine;

+ 7 - 6
database/migrations/2021_05_08_164658_create_configurations_table.php → 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');
     }
 }

+ 2 - 2
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,
         ]);
 
     }

+ 32 - 32
database/seeders/Seeds/ConfigurationSeeder.php → 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',

+ 2 - 2
resources/views/admin/settings/tabs/configurations.blade.php

@@ -22,7 +22,7 @@
     <div class="modal-dialog">
         <div class="modal-content ">
 
-            <form method="post" action="{{ route('admin.configurations.updatevalue') }}">
+            <form method="post" action="{{ route('admin.settings.updatevalue') }}">
                 @csrf
                 @method('PATCH')
                 <!-- Modal Header -->
@@ -92,7 +92,7 @@
             processing: true,
             serverSide: true,
             stateSave: true,
-            ajax: "{{ route('admin.configurations.datatable') }}",
+            ajax: "{{ route('admin.settings.datatable') }}",
             columns: [{
                     data: 'key'
                 },

+ 3 - 4
routes/web.php

@@ -2,7 +2,6 @@
 
 use App\Http\Controllers\Admin\ActivityLogController;
 use App\Http\Controllers\Admin\ApplicationApiController;
-use App\Http\Controllers\Admin\ConfigurationController;
 use App\Http\Controllers\Admin\InvoiceController;
 use App\Http\Controllers\Admin\OverViewController;
 use App\Http\Controllers\Admin\PaymentController;
@@ -126,9 +125,9 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () {
         Route::get('payments/datatable', [PaymentController::class, 'datatable'])->name('payments.datatable');
         Route::get('payments', [PaymentController::class, 'index'])->name('payments.index');
 
-        #configuration
-        Route::get('configurations/datatable', [ConfigurationController::class, 'datatable'])->name('configurations.datatable');
-        Route::patch('configurations/updatevalue', [ConfigurationController::class, 'updatevalue'])->name('configurations.updatevalue');
+        #settings
+        Route::get('settings/datatable', [SettingsController::class, 'datatable'])->name('settings.datatable');
+        Route::patch('settings/updatevalue', [SettingsController::class, 'updatevalue'])->name('settings.updatevalue');
 
         #settings
         Route::patch('settings/update/icons', [SettingsController::class, 'updateIcons'])->name('settings.update.icons');