Преглед изворни кода

Another ton of modifications

Ferks-FK пре 2 година
родитељ
комит
9cd25034fc
49 измењених фајлова са 390 додато и 213 уклоњено
  1. 5 12
      app/Classes/PterodactylClient.php
  2. 5 5
      app/Console/Commands/MakeUserCommand.php
  3. 7 0
      app/Http/Controllers/Admin/OverViewController.php
  4. 6 5
      app/Http/Controllers/Admin/PartnerController.php
  5. 10 11
      app/Http/Controllers/Admin/ProductController.php
  6. 11 2
      app/Http/Controllers/Admin/ServerController.php
  7. 11 2
      app/Http/Controllers/Admin/UserController.php
  8. 17 6
      app/Http/Controllers/Api/UserController.php
  9. 3 2
      app/Http/Controllers/Auth/ForgotPasswordController.php
  10. 3 2
      app/Http/Controllers/Auth/LoginController.php
  11. 20 11
      app/Http/Controllers/Auth/RegisterController.php
  12. 10 8
      app/Http/Controllers/Auth/SocialiteController.php
  13. 0 15
      app/Http/Controllers/Controller.php
  14. 4 2
      app/Http/Controllers/Moderation/TicketsController.php
  15. 10 1
      app/Http/Controllers/ProductController.php
  16. 18 3
      app/Http/Controllers/ProfileController.php
  17. 0 12
      app/Http/Controllers/Pterodactyl/PterodactylController.php
  18. 18 2
      app/Http/Controllers/ServerController.php
  19. 29 14
      app/Http/Controllers/TicketsController.php
  20. 0 2
      app/Http/Middleware/GlobalNames.php
  21. 12 5
      app/Http/Middleware/SetLocale.php
  22. 14 2
      app/Listeners/CreateInvoice.php
  23. 14 1
      app/Listeners/UnsuspendServers.php
  24. 35 10
      app/Listeners/UserPayment.php
  25. 11 4
      app/Listeners/Verified.php
  26. 3 2
      app/Models/PartnerDiscount.php
  27. 2 0
      app/Models/Product.php
  28. 16 5
      app/Models/Server.php
  29. 15 4
      app/Models/User.php
  30. 7 3
      app/Notifications/ReferralNotification.php
  31. 26 9
      app/Notifications/WelcomeMessage.php
  32. 1 1
      app/Settings/DiscordSettings.php
  33. 1 1
      app/Settings/InvoiceSettings.php
  34. 1 1
      app/Settings/LocaleSettings.php
  35. 1 1
      app/Settings/MailSettings.php
  36. 1 1
      app/Settings/PterodactylSettings.php
  37. 1 1
      app/Settings/ReferralSettings.php
  38. 1 1
      app/Settings/ServerSettings.php
  39. 1 1
      app/Settings/TicketSettings.php
  40. 1 1
      app/Settings/UserSettings.php
  41. 1 1
      app/Settings/WebsiteSettings.php
  42. 9 8
      app/Traits/Invoiceable.php
  43. 1 1
      themes/default/views/admin/products/index.blade.php
  44. 1 1
      themes/default/views/moderator/ticket/show.blade.php
  45. 4 4
      themes/default/views/profile/index.blade.php
  46. 3 3
      themes/default/views/servers/create.blade.php
  47. 18 16
      themes/default/views/servers/index.blade.php
  48. 1 5
      themes/default/views/servers/settings.blade.php
  49. 1 3
      themes/default/views/ticket/show.blade.php

+ 5 - 12
app/Classes/PterodactylClient.php

@@ -17,7 +17,9 @@ class PterodactylClient
 {
     //TODO: Extend error handling (maybe logger for more errors when debugging)
 
-    public int $per_page_limit = 200;
+    private int $per_page_limit = 200;
+
+    private int $allocation_limit = 200;
 
     public PendingRequest $client;
 
@@ -29,6 +31,7 @@ class PterodactylClient
             $this->client = $this->client($ptero_settings);
             $this->client_admin = $this->clientAdmin($ptero_settings);
             $this->per_page_limit = $ptero_settings->per_page_limit;
+            $this->allocation_limit = $ptero_settings->allocation_limit;
         }
         catch (Exception $exception) {
             logger('Failed to construct Pterodactyl client, Settings table not available?', ['exception' => $exception]);
@@ -233,9 +236,8 @@ class PterodactylClient
      */
     public function getAllocations(Node $node)
     {
-        $per_page = config('SETTINGS::SERVER:ALLOCATION_LIMIT', 200);
         try {
-            $response = $this->client_admin->get("application/nodes/{$node->id}/allocations?per_page={$per_page}");
+            $response = $this->client_admin->get("application/nodes/{$node->id}/allocations?per_page={$this->allocation_limit}");
         } catch (Exception $e) {
             throw self::getException($e->getMessage());
         }
@@ -246,15 +248,6 @@ class PterodactylClient
         return $response->json();
     }
 
-    /**
-     * @param  string  $route
-     * @return string
-     */
-    public function url(string $route): string
-    {
-        return config('SETTINGS::SYSTEM:PTERODACTYL:URL') . $route;
-    }
-
     /**
      * @param  Server  $server
      * @param  Egg  $egg

+ 5 - 5
app/Console/Commands/MakeUserCommand.php

@@ -4,16 +4,18 @@ namespace App\Console\Commands;
 
 use App\Classes\PterodactylClient;
 use App\Models\User;
+use App\Settings\PterodactylSettings;
 use App\Traits\Referral;
 use Illuminate\Console\Command;
 use Illuminate\Support\Facades\Hash;
 use Illuminate\Support\Facades\Validator;
-use Illuminate\Support\Str;
 
 class MakeUserCommand extends Command
 {
     use Referral;
 
+    private $pterodactyl;
+
     /**
      * The name and signature of the console command.
      *
@@ -28,17 +30,15 @@ class MakeUserCommand extends Command
      */
     protected $description = 'Create an admin account with the Artisan Console';
 
-    private PterodactylClient $pterodactyl;
-
     /**
      * Create a new command instance.
      *
      * @return void
      */
-    public function __construct(PterodactylClient $pterodactyl)
+    public function __construct(PterodactylSettings $ptero_settings)
     {
         parent::__construct();
-        $this->pterodactyl = $pterodactyl;
+        $this->pterodactyl = new PterodactylClient($ptero_settings);
     }
 
 

+ 7 - 0
app/Http/Controllers/Admin/OverViewController.php

@@ -20,6 +20,13 @@ class OverViewController extends Controller
 {
     public const TTL = 86400;
 
+    private $pterodactyl;
+
+    public function __construct(PterodactylSettings $ptero_settings)
+    {
+        $this->pterodactyl = new PterodactylClient($ptero_settings);
+    }
+    
     public function index()
     {
         //Get counters

+ 6 - 5
app/Http/Controllers/Admin/PartnerController.php

@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
 use App\Models\PartnerDiscount;
 use App\Models\User;
 use App\Settings\LocaleSettings;
+use App\Settings\ReferralSettings;
 use Illuminate\Http\Request;
 
 class PartnerController extends Controller
@@ -120,19 +121,19 @@ class PartnerController extends Controller
                 ';
             })
             ->addColumn('user', function (PartnerDiscount $partner) {
-                return ($user = User::where('id', $partner->user_id)->first()) ? '<a href="'.route('admin.users.show', $partner->user_id).'">'.$user->name.'</a>' : __('Unknown user');
+                return ($user = User::where('id', $partner->user_id)->first()) ? '<a href="'.route('admin.users.show', $partner->user_id) . '">' . $user->name . '</a>' : __('Unknown user');
             })
             ->editColumn('created_at', function (PartnerDiscount $partner) {
                 return $partner->created_at ? $partner->created_at->diffForHumans() : '';
             })
             ->editColumn('partner_discount', function (PartnerDiscount $partner) {
-                return $partner->partner_discount ? $partner->partner_discount.'%' : '0%';
+                return $partner->partner_discount ? $partner->partner_discount . '%' : '0%';
             })
             ->editColumn('registered_user_discount', function (PartnerDiscount $partner) {
-                return $partner->registered_user_discount ? $partner->registered_user_discount.'%' : '0%';
+                return $partner->registered_user_discount ? $partner->registered_user_discount . '%' : '0%';
             })
-            ->editColumn('referral_system_commission', function (PartnerDiscount $partner) {
-                return $partner->referral_system_commission >= 0 ? $partner->referral_system_commission.'%' : __('Default').' ('.config('SETTINGS::REFERRAL:PERCENTAGE').'%)';
+            ->editColumn('referral_system_commission', function (PartnerDiscount $partner, ReferralSettings $referral_settings) {
+                return $partner->referral_system_commission >= 0 ? $partner->referral_system_commission . '%' : __('Default') . ' ('.$referral_settings->percentage . '%)';
             })
             ->rawColumns(['user', 'actions'])
             ->make();

+ 10 - 11
app/Http/Controllers/Admin/ProductController.php

@@ -198,7 +198,6 @@ class ProductController extends Controller
     public function dataTable()
     {
         $query = Product::with(['servers']);
-
         return datatables($query)
             ->addColumn('actions', function (Product $product) {
                 return '
@@ -227,18 +226,18 @@ class ProductController extends Controller
                 $checked = $product->disabled == false ? 'checked' : '';
 
                 return '
-                                <form class="d-inline" onsubmit="return submitResult();" method="post" action="'.route('admin.products.disable', $product->id).'">
-                            '.csrf_field().'
-                            '.method_field('PATCH').'
-                            <div class="custom-control custom-switch">
-                            <input '.$checked.' name="disabled" onchange="this.form.submit()" type="checkbox" class="custom-control-input" id="switch'.$product->id.'">
-                            <label class="custom-control-label" for="switch'.$product->id.'"></label>
-                          </div>
-                       </form>
+                    <form class="d-inline" onsubmit="return submitResult();" method="post" action="'.route('admin.products.disable', $product->id).'">
+                        '.csrf_field().'
+                        '.method_field('PATCH').'
+                        <div class="custom-control custom-switch">
+                        <input '.$checked.' name="disabled" onchange="this.form.submit()" type="checkbox" class="custom-control-input" id="switch'.$product->id.'">
+                        <label class="custom-control-label" for="switch'.$product->id.'"></label>
+                        </div>
+                    </form>
                 ';
             })
-            ->editColumn('minimum_credits', function (Product $product) {
-                return $product->minimum_credits==-1 ? config('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER') : $product->minimum_credits;
+            ->editColumn('minimum_credits', function (Product $product, UserSettings $user_settings) {
+                return $product->minimum_credits==-1 ? $user_settings->min_credits_to_make_server : $product->minimum_credits;
             })
             ->editColumn('created_at', function (Product $product) {
                 return $product->created_at ? $product->created_at->diffForHumans() : '';

+ 11 - 2
app/Http/Controllers/Admin/ServerController.php

@@ -6,6 +6,8 @@ use App\Http\Controllers\Controller;
 use App\Models\Server;
 use App\Models\User;
 use App\Settings\LocaleSettings;
+use App\Settings\PterodactylSettings;
+use App\Classes\PterodactylClient;
 use Exception;
 use Illuminate\Contracts\Foundation\Application;
 use Illuminate\Contracts\View\Factory;
@@ -18,6 +20,13 @@ use Illuminate\Support\Facades\Log;
 
 class ServerController extends Controller
 {
+    private $pterodactyl;
+
+    public function __construct(PterodactylSettings $ptero_settings)
+    {
+        $this->pterodactyl = new PterodactylClient($ptero_settings);
+    }
+
     /**
      * Display a listing of the resource.
      *
@@ -217,8 +226,8 @@ class ServerController extends Controller
             ->editColumn('suspended', function (Server $server) {
                 return $server->suspended ? $server->suspended->diffForHumans() : '';
             })
-            ->editColumn('name', function (Server $server) {
-                return '<a class="text-info" target="_blank" href="' . config('SETTINGS::SYSTEM:PTERODACTYL:URL') . '/admin/servers/view/' . $server->pterodactyl_id . '">' . strip_tags($server->name) . '</a>';
+            ->editColumn('name', function (Server $server, PterodactylSettings $ptero_settings) {
+                return '<a class="text-info" target="_blank" href="' . $ptero_settings->panel_url . '/admin/servers/view/' . $server->pterodactyl_id . '">' . strip_tags($server->name) . '</a>';
             })
             ->rawColumns(['user', 'actions', 'status', 'name'])
             ->make();

+ 11 - 2
app/Http/Controllers/Admin/UserController.php

@@ -7,6 +7,8 @@ use App\Http\Controllers\Controller;
 use App\Models\User;
 use App\Notifications\DynamicNotification;
 use App\Settings\LocaleSettings;
+use App\Settings\PterodactylSettings;
+use App\Classes\PterodactylClient;
 use Exception;
 use Illuminate\Contracts\Foundation\Application;
 use Illuminate\Contracts\View\Factory;
@@ -26,6 +28,13 @@ use Spatie\QueryBuilder\QueryBuilder;
 
 class UserController extends Controller
 {
+    private $pterodactyl;
+
+    public function __construct(PterodactylSettings $ptero_settings)
+    {
+        $this->pterodactyl = new PterodactylClient($ptero_settings);
+    }
+    
     /**
      * Display a listing of the resource.
      *
@@ -328,8 +337,8 @@ class UserController extends Controller
             ->editColumn('last_seen', function (User $user) {
                 return $user->last_seen ? $user->last_seen->diffForHumans() : __('Never');
             })
-            ->editColumn('name', function (User $user) {
-                return '<a class="text-info" target="_blank" href="' . config('SETTINGS::SYSTEM:PTERODACTYL:URL') . '/admin/users/view/' . $user->pterodactyl_id . '">' . strip_tags($user->name) . '</a>';
+            ->editColumn('name', function (User $user, PterodactylSettings $ptero_settings) {
+                return '<a class="text-info" target="_blank" href="' . $ptero_settings->panel_url . '/admin/users/view/' . $user->pterodactyl_id . '">' . strip_tags($user->name) . '</a>';
             })
             ->rawColumns(['avatar', 'name', 'credits', 'role', 'usage',  'actions'])
             ->make();

+ 17 - 6
app/Http/Controllers/Api/UserController.php

@@ -8,6 +8,10 @@ use App\Models\DiscordUser;
 use App\Models\User;
 use App\Notifications\ReferralNotification;
 use App\Traits\Referral;
+use App\Settings\PterodactylSettings;
+use App\Classes\PterodactylClient;
+use App\Settings\ReferralSettings;
+use App\Settings\UserSettings;
 use Carbon\Carbon;
 use Illuminate\Contracts\Foundation\Application;
 use Illuminate\Contracts\Pagination\LengthAwarePaginator;
@@ -33,6 +37,13 @@ class UserController extends Controller
 
     const ALLOWED_FILTERS = ['name', 'server_limit', 'email', 'pterodactyl_id', 'role', 'suspended'];
 
+    private $pterodactyl;
+
+    public function __construct(PterodactylSettings $ptero_settings)
+    {
+        $this->pterodactyl = new PterodactylClient($ptero_settings);
+    }
+    
     /**
      * Display a listing of the resource.
      *
@@ -245,7 +256,7 @@ class UserController extends Controller
     /**
      * @throws ValidationException
      */
-    public function store(Request $request)
+    public function store(Request $request, UserSettings $user_settings, ReferralSettings $referral_settings)
     {
         $request->validate([
             'name' => ['required', 'string', 'max:30', 'min:4', 'alpha_num', 'unique:users'],
@@ -254,7 +265,7 @@ class UserController extends Controller
         ]);
 
         // Prevent the creation of new users via API if this is enabled.
-        if (!config('SETTINGS::SYSTEM:CREATION_OF_NEW_USERS', 'true')) {
+        if (!$user_settings->creation_enabled) {
             throw ValidationException::withMessages([
                 'error' => 'The creation of new users has been blocked by the system administrator.',
             ]);
@@ -263,8 +274,8 @@ class UserController extends Controller
         $user = User::create([
             'name' => $request->input('name'),
             'email' => $request->input('email'),
-            'credits' => config('SETTINGS::USER:INITIAL_CREDITS', 150),
-            'server_limit' => config('SETTINGS::USER:INITIAL_SERVER_LIMIT', 1),
+            'credits' => $user_settings->initial_credits,
+            'server_limit' => $user_settings->initial_server_limit,
             'password' => Hash::make($request->input('password')),
             'referral_code' => $this->createReferralCode(),
         ]);
@@ -296,8 +307,8 @@ class UserController extends Controller
             $ref_code = $request->input('referral_code');
             $new_user = $user->id;
             if ($ref_user = User::query()->where('referral_code', '=', $ref_code)->first()) {
-                if (config('SETTINGS::REFERRAL:MODE') == 'register' || config('SETTINGS::REFERRAL:MODE') == 'both') {
-                    $ref_user->increment('credits', config('SETTINGS::REFERRAL::REWARD'));
+                if ($referral_settings->mode === 'register' || $referral_settings->mode === 'both') {
+                    $ref_user->increment('credits', $referral_settings->reward);
                     $ref_user->notify(new ReferralNotification($ref_user->id, $new_user));
                 }
                 //INSERT INTO USER_REFERRALS TABLE

+ 3 - 2
app/Http/Controllers/Auth/ForgotPasswordController.php

@@ -3,6 +3,7 @@
 namespace App\Http\Controllers\Auth;
 
 use App\Http\Controllers\Controller;
+use App\Settings\GeneralSettings;
 use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
 use Illuminate\Http\Request;
 
@@ -31,13 +32,13 @@ class ForgotPasswordController extends Controller
         $this->middleware('guest');
     }
 
-    protected function validateEmail(Request $request)
+    protected function validateEmail(Request $request, GeneralSettings $general_settings)
     {
         $this->validate($request, [
             'email' => ['required', 'string', 'email', 'max:255'],
         ]);
 
-        if (config('SETTINGS::RECAPTCHA:ENABLED') == 'true') {
+        if ($general_settings->recaptcha_enabled) {
             $this->validate($request, [
                 'g-recaptcha-response' => 'required|recaptcha',
             ]);

+ 3 - 2
app/Http/Controllers/Auth/LoginController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Auth;
 
 use App\Http\Controllers\Controller;
 use App\Providers\RouteServiceProvider;
+use App\Settings\GeneralSettings;
 use Illuminate\Foundation\Auth\AuthenticatesUsers;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Auth;
@@ -53,13 +54,13 @@ class LoginController extends Controller
         return $field;
     }
 
-    public function login(Request $request)
+    public function login(Request $request, GeneralSettings $general_settings)
     {
         $validationRules = [
             $this->username() => 'required|string',
             'password' => 'required|string',
         ];
-        if (config('SETTINGS::RECAPTCHA:ENABLED') == 'true') {
+        if ($general_settings->recaptcha_enabled) {
             $validationRules['g-recaptcha-response'] = ['required', 'recaptcha'];
         }
         $request->validate($validationRules);

+ 20 - 11
app/Http/Controllers/Auth/RegisterController.php

@@ -8,6 +8,12 @@ use App\Notifications\ReferralNotification;
 use App\Providers\RouteServiceProvider;
 use App\Traits\Referral;
 use Carbon\Carbon;
+use App\Settings\PterodactylSettings;
+use App\Classes\PterodactylClient;
+use App\Settings\GeneralSettings;
+use App\Settings\ReferralSettings;
+use App\Settings\UserSettings;
+use App\Settings\WebsiteSettings;
 use Illuminate\Foundation\Auth\RegistersUsers;
 use Illuminate\Support\Facades\App;
 use Illuminate\Support\Facades\DB;
@@ -19,6 +25,8 @@ use Illuminate\Validation\ValidationException;
 
 class RegisterController extends Controller
 {
+    private $pterodactyl;
+
     /*
     |--------------------------------------------------------------------------
     | Register Controller
@@ -44,9 +52,10 @@ class RegisterController extends Controller
      *
      * @return void
      */
-    public function __construct()
+    public function __construct(PterodactylSettings $ptero_settings)
     {
         $this->middleware('guest');
+        $this->pterodactyl = new PterodactylClient($ptero_settings);
     }
 
     /**
@@ -55,21 +64,21 @@ class RegisterController extends Controller
      * @param  array  $data
      * @return \Illuminate\Contracts\Validation\Validator
      */
-    protected function validator(array $data)
+    protected function validator(array $data, GeneralSettings $general_settings, WebsiteSettings $website_settings, UserSettings $user_settings)
     {
         $validationRules = [
             'name' => ['required', 'string', 'max:30', 'min:4', 'alpha_num', 'unique:users'],
             'email' => ['required', 'string', 'email', 'max:64', 'unique:users'],
             'password' => ['required', 'string', 'min:8', 'confirmed'],
         ];
-        if (config('SETTINGS::RECAPTCHA:ENABLED') == 'true') {
+        if ($general_settings->recaptcha_enabled) {
             $validationRules['g-recaptcha-response'] = ['required', 'recaptcha'];
         }
-        if (config('SETTINGS::SYSTEM:SHOW_TOS') == 'true') {
+        if ($website_settings->show_tos) {
             $validationRules['terms'] = ['required'];
         }
 
-        if (config('SETTINGS::SYSTEM:REGISTER_IP_CHECK', 'true') == 'true') {
+        if ($user_settings->register_ip_check) {
 
             //check if ip has already made an account
             $data['ip'] = session()->get('ip') ?? request()->ip();
@@ -93,13 +102,13 @@ class RegisterController extends Controller
      * @param  array  $data
      * @return User
      */
-    protected function create(array $data)
+    protected function create(array $data, GeneralSettings $general_settings, UserSettings $user_settings, ReferralSettings $referral_settings)
     {
         $user = User::create([
             'name' => $data['name'],
             'email' => $data['email'],
-            'credits' => config('SETTINGS::USER:INITIAL_CREDITS', 150),
-            'server_limit' => config('SETTINGS::USER:INITIAL_SERVER_LIMIT', 1),
+            'credits' => $user_settings->initial_credits,
+            'server_limit' => $user_settings->initial_server_limit,
             'password' => Hash::make($data['password']),
             'referral_code' => $this->createReferralCode(),
 
@@ -133,15 +142,15 @@ class RegisterController extends Controller
             $ref_code = $data['referral_code'];
             $new_user = $user->id;
             if ($ref_user = User::query()->where('referral_code', '=', $ref_code)->first()) {
-                if (config('SETTINGS::REFERRAL:MODE') == 'sign-up' || config('SETTINGS::REFERRAL:MODE') == 'both') {
-                    $ref_user->increment('credits', config('SETTINGS::REFERRAL::REWARD'));
+                if ($referral_settings->mode === 'sign-up' || $referral_settings->mode === 'both') {
+                    $ref_user->increment('credits', $referral_settings->reward);
                     $ref_user->notify(new ReferralNotification($ref_user->id, $new_user));
 
                     //LOGS REFERRALS IN THE ACTIVITY LOG
                     activity()
                         ->performedOn($user)
                         ->causedBy($ref_user)
-                        ->log('gained ' . config('SETTINGS::REFERRAL::REWARD') . ' ' . config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME') . ' for sign-up-referral of ' . $user->name . ' (ID:' . $user->id . ')');
+                        ->log('gained ' . $referral_settings->reward . ' ' . $general_settings->credits_display_name . ' for sign-up-referral of ' . $user->name . ' (ID:' . $user->id . ')');
                 }
                 //INSERT INTO USER_REFERRALS TABLE
                 DB::table('user_referrals')->insert([

+ 10 - 8
app/Http/Controllers/Auth/SocialiteController.php

@@ -5,22 +5,24 @@ namespace App\Http\Controllers\Auth;
 use App\Http\Controllers\Controller;
 use App\Models\DiscordUser;
 use App\Models\User;
+use App\Settings\DiscordSettings;
+use App\Settings\UserSettings;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\Http;
 use Laravel\Socialite\Facades\Socialite;
 
 class SocialiteController extends Controller
 {
-    public function redirect()
+    public function redirect(DiscordSettings $discord_settings)
     {
-        $scopes = ! empty(config('SETTINGS::DISCORD:BOT_TOKEN')) && ! empty(config('SETTINGS::DISCORD:GUILD_ID')) ? ['guilds.join'] : [];
+        $scopes = !empty($discord_settings->bot_token) && !empty($discord_settings->guild_id) ? ['guilds.join'] : [];
 
         return Socialite::driver('discord')
             ->scopes($scopes)
             ->redirect();
     }
 
-    public function callback()
+    public function callback(DiscordSettings $discord_settings, UserSettings $user_settings)
     {
         if (Auth::guest()) {
             return abort(500);
@@ -29,9 +31,9 @@ class SocialiteController extends Controller
         /** @var User $user */
         $user = Auth::user();
         $discord = Socialite::driver('discord')->user();
-        $botToken = config('SETTINGS::DISCORD:BOT_TOKEN');
-        $guildId = config('SETTINGS::DISCORD:GUILD_ID');
-        $roleId = config('SETTINGS::DISCORD:ROLE_ID');
+        $botToken = $discord_settings->bot_token;
+        $guildId = $discord_settings->guild_id;
+        $roleId = $discord_settings->role_id;
 
         //save / update discord_users
 
@@ -49,8 +51,8 @@ class SocialiteController extends Controller
             DiscordUser::create(array_merge($discord->user, ['user_id' => Auth::user()->id]));
 
             //update user
-            Auth::user()->increment('credits', config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD'));
-            Auth::user()->increment('server_limit', config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD'));
+            Auth::user()->increment('credits', $user_settings->credits_reward_after_verify_discord);
+            Auth::user()->increment('server_limit', $user_settings->server_limit_after_verify_discord);
             Auth::user()->update(['discord_verified_at' => now()]);
         } else {
             $user->discordUser->update($discord->user);

+ 0 - 15
app/Http/Controllers/Controller.php

@@ -6,23 +6,8 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
 use Illuminate\Foundation\Bus\DispatchesJobs;
 use Illuminate\Foundation\Validation\ValidatesRequests;
 use Illuminate\Routing\Controller as BaseController;
-use App\Settings\PterodactylSettings;
-use App\Classes\PterodactylClient;
-use Exception;
 
 class Controller extends BaseController
 {
     use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
-
-    public $pterodactyl = null;
-
-    public function __construct(PterodactylSettings $ptero_settings)
-    {
-        try {
-            $this->pterodactyl = new PterodactylClient($ptero_settings);
-        }
-        catch (Exception $exception) {
-            
-        }
-    }
 }

+ 4 - 2
app/Http/Controllers/Moderation/TicketsController.php

@@ -11,6 +11,7 @@ use App\Models\TicketComment;
 use App\Models\User;
 use App\Notifications\Ticket\User\ReplyNotification;
 use App\Settings\LocaleSettings;
+use App\Settings\PterodactylSettings;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Auth;
 
@@ -25,7 +26,7 @@ class TicketsController extends Controller
         ]);
     }
 
-    public function show($ticket_id)
+    public function show($ticket_id, PterodactylSettings $ptero_settings)
     {
         try {
         $ticket = Ticket::where('ticket_id', $ticket_id)->firstOrFail();
@@ -36,8 +37,9 @@ class TicketsController extends Controller
         $ticketcomments = $ticket->ticketcomments;
         $ticketcategory = $ticket->ticketcategory;
         $server = Server::where('id', $ticket->server)->first();
+        $pterodactyl_url = $ptero_settings->panel_url;
 
-        return view('moderator.ticket.show', compact('ticket', 'ticketcategory', 'ticketcomments', 'server'));
+        return view('moderator.ticket.show', compact('ticket', 'ticketcategory', 'ticketcomments', 'server', 'pterodactyl_url'));
     }
 
     public function changeStatus($ticket_id)

+ 10 - 1
app/Http/Controllers/ProductController.php

@@ -2,17 +2,26 @@
 
 namespace App\Http\Controllers;
 
+use App\Classes\PterodactylClient;
 use App\Models\Pterodactyl\Egg;
 use App\Models\Pterodactyl\Location;
 use App\Models\Pterodactyl\Node;
 use App\Models\Product;
+use App\Settings\PterodactylSettings;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Http\JsonResponse;
 use Illuminate\Http\Request;
 use Illuminate\Support\Collection;
 
 class ProductController extends Controller
-{
+{   
+    private $pterodactyl;
+
+    public function __construct(PterodactylSettings $ptero_settings)
+    {
+        $this->pterodactyl = new PterodactylClient($ptero_settings);
+    }
+
     /**
      * @description get product locations based on selected egg
      *

+ 18 - 3
app/Http/Controllers/ProfileController.php

@@ -4,6 +4,10 @@ namespace App\Http\Controllers;
 
 use App\Models\User;
 use App\Settings\UserSettings;
+use App\Settings\PterodactylSettings;
+use App\Classes\PterodactylClient;
+use App\Settings\DiscordSettings;
+use App\Settings\ReferralSettings;
 use Illuminate\Http\RedirectResponse;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Auth;
@@ -12,8 +16,15 @@ use Illuminate\Validation\ValidationException;
 
 class ProfileController extends Controller
 {
+    private $pterodactyl;
+
+    public function __construct(PterodactylSettings $ptero_settings)
+    {
+        $this->pterodactyl = new PterodactylClient($ptero_settings);
+    }
+
     /** Display a listing of the resource. */
-    public function index(UserSettings $user_settings)
+    public function index(UserSettings $user_settings, DiscordSettings $discord_settings, ReferralSettings $referral_settings)
     {
         switch (Auth::user()->role) {
             case 'admin':
@@ -36,6 +47,10 @@ class ProfileController extends Controller
             'force_email_verification' => $user_settings->force_email_verification,
             'force_discord_verification' => $user_settings->force_discord_verification,
             'badgeColor' => $badgeColor,
+            'discord_client_id' => $discord_settings->client_id,
+            'discord_client_secret' => $discord_settings->client_secret,
+            'referral_enabled' => $referral_settings->enabled,
+            'referral_allowed' => $referral_settings->allowed
         ]);
     }
 
@@ -81,7 +96,7 @@ class ProfileController extends Controller
 
             //Update Users Password on Pterodactyl
             //Username,Mail,First and Lastname are required aswell
-            $response = $this->pterodactyl->client_admin->patch('/application/users/'.$user->pterodactyl_id, [
+            $response = $this->pterodactyl->client_admin->patch('/application/users/' . $user->pterodactyl_id, [
                 'password' => $request->input('new_password'),
                 'username' => $request->input('name'),
                 'first_name' => $request->input('name'),
@@ -125,7 +140,7 @@ class ProfileController extends Controller
         }
 
         //update name and email on Pterodactyl
-        $response = $this->pterodactyl->client_admin->patch('/application/users/'.$user->pterodactyl_id, [
+        $response = $this->pterodactyl->client_admin->patch('/application/users/' . $user->pterodactyl_id, [
             'username' => $request->input('name'),
             'first_name' => $request->input('name'),
             'last_name' => $request->input('name'),

+ 0 - 12
app/Http/Controllers/Pterodactyl/PterodactylController.php

@@ -1,12 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Pterodactyl;
-
-use App\Http\Controllers\Controller;
-use App\Classes\PterodactylClient;
-use Illuminate\Http\Request;
-
-abstract class PterodactylController extends PterodactylClient
-{
-    //
-}

+ 18 - 2
app/Http/Controllers/ServerController.php

@@ -11,6 +11,9 @@ use App\Models\Server;
 use App\Notifications\ServerCreationError;
 use App\Settings\UserSettings;
 use App\Settings\ServerSettings;
+use App\Settings\PterodactylSettings;
+use App\Classes\PterodactylClient;
+use App\Settings\GeneralSettings;
 use Exception;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Http\Client\Response;
@@ -21,8 +24,15 @@ use Illuminate\Support\Facades\Request as FacadesRequest;
 
 class ServerController extends Controller
 {
+    private $pterodactyl;
+
+    public function __construct(PterodactylSettings $ptero_settings)
+    {
+        $this->pterodactyl = new PterodactylClient($ptero_settings);
+    }
+
     /** Display a listing of the resource. */
-    public function index()
+    public function index(GeneralSettings $general_settings, PterodactylSettings $ptero_settings)
     {
         $servers = Auth::user()->servers;
 
@@ -62,6 +72,9 @@ class ServerController extends Controller
 
         return view('servers.index')->with([
             'servers' => $servers,
+            'credits_display_name' => $general_settings->credits_display_name,
+            'pterodactyl_url' => $ptero_settings->panel_url,
+            'phpmyadmin_url' => $general_settings->phpmyadmin_url
         ]);
     }
 
@@ -101,6 +114,8 @@ class ServerController extends Controller
             'locations' => $locations,
             'eggs' => $eggs,
             'user' => Auth::user(),
+            'server_creation_enabled' => $server_settings->creation_enabled,
+            'min_credits_to_make_server' => $user_settings->min_credits_to_make_server
         ]);
     }
 
@@ -253,7 +268,7 @@ class ServerController extends Controller
     }
 
     /** Show Server Settings */
-    public function show(Server $server)
+    public function show(Server $server, ServerSettings $server_settings)
     {
         if ($server->user_id != Auth::user()->id) {
             return back()->with('error', __('This is not your Server!'));
@@ -293,6 +308,7 @@ class ServerController extends Controller
         return view('servers.settings')->with([
             'server' => $server,
             'products' => $products,
+            'server_enable_upgrade' => $server_settings->enable_upgrade
         ]);
     }
 

+ 29 - 14
app/Http/Controllers/TicketsController.php

@@ -12,6 +12,8 @@ use App\Notifications\Ticket\Admin\AdminCreateNotification;
 use App\Notifications\Ticket\Admin\AdminReplyNotification;
 use App\Notifications\Ticket\User\CreateNotification;
 use App\Settings\LocaleSettings;
+use App\Settings\PterodactylSettings;
+use App\Settings\TicketSettings;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\Notification;
@@ -28,7 +30,20 @@ class TicketsController extends Controller
         ]);
     }
 
-    public function store(Request $request)
+    public function create()
+    {
+        //check in blacklist
+        $check = TicketBlacklist::where('user_id', Auth::user()->id)->first();
+        if ($check && $check->status == 'True') {
+            return redirect()->route('ticket.index')->with('error', __("You can't make a ticket because you're on the blacklist for a reason: '".$check->reason."', please contact the administrator"));
+        }
+        $ticketcategories = TicketCategory::all();
+        $servers = Auth::user()->servers;
+
+        return view('ticket.create', compact('ticketcategories', 'servers'));
+    }
+
+    public function store(Request $request, TicketSettings $ticket_settings)
     {
         $this->validate($request, [
                 'title' => 'required',
@@ -48,24 +63,23 @@ class TicketsController extends Controller
         );
         $ticket->save();
         $user = Auth::user();
-        if (config('SETTINGS::TICKET:NOTIFY') == "all") {
-            $admin = User::where('role', 'admin')->orWhere('role', 'mod')->get();
-        }
-        if (config('SETTINGS::TICKET:NOTIFY') == "admin") {
-            $admin = User::where('role', 'admin')->get();
-        }
-        if (config('SETTINGS::TICKET:NOTIFY') == "moderator") {
-            $admin = User::where('role', 'mod')->get();
+        switch ($ticket_settings->notify) {
+            case 'all':
+                $admin = User::where('role', 'admin')->orWhere('role', 'mod')->get();
+                Notification::send($admin, new AdminCreateNotification($ticket, $user));
+            case 'admin':
+                $admin = User::where('role', 'admin')->get();
+                Notification::send($admin, new AdminCreateNotification($ticket, $user));
+            case 'moderator':
+                $admin = User::where('role', 'mod')->get();
+                Notification::send($admin, new AdminCreateNotification($ticket, $user));
         }
         $user->notify(new CreateNotification($ticket));
-        if (config('SETTINGS::TICKET:NOTIFY') != "none") {
-            Notification::send($admin, new AdminCreateNotification($ticket, $user));
-        }
 
         return redirect()->route('ticket.index')->with('success', __('A ticket has been opened, ID: #') . $ticket->ticket_id);
     }
 
-    public function show($ticket_id)
+    public function show($ticket_id, PterodactylSettings $ptero_settings)
     {
         try {
             $ticket = Ticket::where('ticket_id', $ticket_id)->firstOrFail();
@@ -75,8 +89,9 @@ class TicketsController extends Controller
         $ticketcomments = $ticket->ticketcomments;
         $ticketcategory = $ticket->ticketcategory;
         $server = Server::where('id', $ticket->server)->first();
+        $pterodactyl_url = $ptero_settings->panel_url;
 
-        return view('ticket.show', compact('ticket', 'ticketcategory', 'ticketcomments', 'server'));
+        return view('ticket.show', compact('ticket', 'ticketcategory', 'ticketcomments', 'server', 'pterodactyl_url'));
     }
 
     public function reply(Request $request)

+ 0 - 2
app/Http/Middleware/GlobalNames.php

@@ -16,8 +16,6 @@ class GlobalNames
      */
     public function handle(Request $request, Closure $next)
     {
-        define('CREDITS_DISPLAY_NAME', config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME', 'Credits'));
-
         $unsupported_lang_array = explode(',', config('app.unsupported_locales'));
         $unsupported_lang_array = array_map('strtolower', $unsupported_lang_array);
         define('UNSUPPORTED_LANGS', $unsupported_lang_array);

+ 12 - 5
app/Http/Middleware/SetLocale.php

@@ -2,6 +2,7 @@
 
 namespace App\Http\Middleware;
 
+use App\Settings\LocaleSettings;
 use Closure;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\App;
@@ -9,6 +10,12 @@ use Illuminate\Support\Facades\Session;
 
 class SetLocale
 {
+    private $locale_settings;
+
+    public function __construct(LocaleSettings $locale_settings)
+    {
+        $this->locale_settings = $locale_settings;
+    }
     /**
      * Handle an incoming request.
      *
@@ -19,15 +26,15 @@ class SetLocale
     public function handle($request, Closure $next)
     {
         if (Session::has('locale')) {
-            $locale = Session::get('locale', config('SETTINGS::LOCALE:DEFAULT'));
+            $locale = Session::get('locale', $this->locale_settings->default);
         } else {
-            if (config('SETTINGS::LOCALE:DYNAMIC') !== 'true') {
-                $locale = config('SETTINGS::LOCALE:DEFAULT');
+            if (!$this->locale_settings->dynamic) {
+                $locale = $this->locale_settings->default;
             } else {
                 $locale = substr($request->server('HTTP_ACCEPT_LANGUAGE'), 0, 2);
 
-                if (! in_array($locale, explode(',', config('SETTINGS::LOCALE:AVAILABLE')))) {
-                    $locale = config('SETTINGS::LOCALE:DEFAULT');
+                if (! in_array($locale, explode(',', $this->locale_settings->available))) {
+                    $locale = $this->locale_settings->default;
                 }
             }
         }

+ 14 - 2
app/Listeners/CreateInvoice.php

@@ -3,13 +3,25 @@
 namespace App\Listeners;
 
 use App\Events\PaymentEvent;
+use App\Settings\InvoiceSettings;
 use App\Traits\Invoiceable;
 
 class CreateInvoice
 {
-
     use Invoiceable;
 
+    private $invoice_enabled;
+
+    /**
+     * Create the event listener.
+     *
+     * @return void
+     */
+    public function __construct(InvoiceSettings $invoice_settings)
+    {
+        $this->invoice_enabled = $invoice_settings->enabled;
+    }
+
     /**
      * Handle the event.
      *
@@ -18,7 +30,7 @@ class CreateInvoice
      */
     public function handle(PaymentEvent $event)
     {
-        if (config('SETTINGS::INVOICE:ENABLED') == 'true') {
+        if ($this->invoice_enabled) {
             // create invoice using the trait
             $this->createInvoice($event->payment, $event->shopProduct);
         }

+ 14 - 1
app/Listeners/UnsuspendServers.php

@@ -4,11 +4,24 @@ namespace App\Listeners;
 
 use App\Events\UserUpdateCreditsEvent;
 use App\Models\Server;
+use App\Settings\UserSettings;
 use Exception;
 use Illuminate\Contracts\Queue\ShouldQueue;
 
 class UnsuspendServers implements ShouldQueue
 {
+    private $min_credits_to_make_server;
+
+    /**
+     * Create the event listener.
+     *
+     * @return void
+     */
+    public function __construct(UserSettings $user_settings)
+    {
+        $this->min_credits_to_make_server = $user_settings->min_credits_to_make_server;
+    }
+
     /**
      * Handle the event.
      *
@@ -19,7 +32,7 @@ class UnsuspendServers implements ShouldQueue
      */
     public function handle(UserUpdateCreditsEvent $event)
     {
-        if ($event->user->credits > config('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', 50)) {
+        if ($event->user->credits > $this->min_credits_to_make_server) {
             /** @var Server $server */
             foreach ($event->user->servers as $server) {
                 if ($server->isSuspended()) {

+ 35 - 10
app/Listeners/UserPayment.php

@@ -6,11 +6,36 @@ use App\Events\PaymentEvent;
 use App\Models\User;
 use Illuminate\Support\Facades\DB;
 use App\Models\PartnerDiscount;
-use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Queue\InteractsWithQueue;
+use App\Settings\GeneralSettings;
+use App\Settings\ReferralSettings;
+use App\Settings\UserSettings;
 
 class UserPayment
 {
+    private $server_limit_after_irl_purchase;
+
+    private $referral_mode;
+
+    private $referral_percentage;
+
+    private $referral_always_give_commission;
+
+    private $credits_display_name;
+
+    /**
+     * Create the event listener.
+     *
+     * @return void
+     */
+    public function __construct(UserSettings $user_settings, ReferralSettings $referral_settings, GeneralSettings $general_settings)
+    {
+        $this->server_limit_after_irl_purchase = $user_settings->server_limit_after_irl_purchase;
+        $this->referral_mode = $referral_settings->mode;
+        $this->referral_percentage = $referral_settings->percentage;
+        $this->referral_always_give_commission = $referral_settings->always_give_commission;
+        $this->credits_display_name = $general_settings->credits_display_name;
+    }
+    
     /**
      * Handle the event.
      *
@@ -28,8 +53,8 @@ class UserPayment
         }
 
         //update server limit
-        if (config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0 && $user->server_limit < config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')) {
-            $user->update(['server_limit' => config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')]);
+        if ($this->server_limit_after_irl_purchase !== 0 && $user->server_limit < $this->server_limit_after_irl_purchase) {
+            $user->update(['server_limit' => $this->server_limit_after_irl_purchase]);
         }
 
         //update User with bought item
@@ -40,17 +65,17 @@ class UserPayment
         }
 
         //give referral commission always
-        if ((config("SETTINGS::REFERRAL:MODE") == "commission" || config("SETTINGS::REFERRAL:MODE") == "both") && $shopProduct->type == "Credits" && config("SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION") == "true") {
+        if (($this->referral_mode === "commission" || $this->referral_mode === "both") && $shopProduct->type == "Credits" && $this->referral_always_give_commission) {
             if ($ref_user = DB::table("user_referrals")->where('registered_user_id', '=', $user->id)->first()) {
                 $ref_user = User::findOrFail($ref_user->referral_id);
-                $increment = number_format($shopProduct->quantity * (PartnerDiscount::getCommission($ref_user->id)) / 100, 0, "", "");
+                $increment = number_format($shopProduct->quantity * (PartnerDiscount::getCommission($ref_user->id, $this->referral_percentage)) / 100, 0, "", "");
                 $ref_user->increment('credits', $increment);
 
                 //LOGS REFERRALS IN THE ACTIVITY LOG
                 activity()
                     ->performedOn($user)
                     ->causedBy($ref_user)
-                    ->log('gained ' . $increment . ' ' . config("SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME") . ' for commission-referral of ' . $user->name . ' (ID:' . $user->id . ')');
+                    ->log('gained ' . $increment . ' ' . $this->credits_display_name . ' for commission-referral of ' . $user->name . ' (ID:' . $user->id . ')');
             }
         }
         //update role give Referral-reward
@@ -58,17 +83,17 @@ class UserPayment
             $user->update(['role' => 'client']);
 
             //give referral commission only on first purchase
-            if ((config("SETTINGS::REFERRAL:MODE") == "commission" || config("SETTINGS::REFERRAL:MODE") == "both") && $shopProduct->type == "Credits" && config("SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION") == "false") {
+            if (($this->referral_mode === "commission" || $this->referral_mode === "both") && $shopProduct->type == "Credits" && !$this->referral_always_give_commission) {
                 if ($ref_user = DB::table("user_referrals")->where('registered_user_id', '=', $user->id)->first()) {
                     $ref_user = User::findOrFail($ref_user->referral_id);
-                    $increment = number_format($shopProduct->quantity * (PartnerDiscount::getCommission($ref_user->id)) / 100, 0, "", "");
+                    $increment = number_format($shopProduct->quantity * (PartnerDiscount::getCommission($ref_user->id, $this->referral_percentage)) / 100, 0, "", "");
                     $ref_user->increment('credits', $increment);
 
                     //LOGS REFERRALS IN THE ACTIVITY LOG
                     activity()
                         ->performedOn($user)
                         ->causedBy($ref_user)
-                        ->log('gained ' . $increment . ' ' . config("SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME") . ' for commission-referral of ' . $user->name . ' (ID:' . $user->id . ')');
+                        ->log('gained ' . $increment . ' ' . $this->credits_display_name . ' for commission-referral of ' . $user->name . ' (ID:' . $user->id . ')');
                 }
             }
         }

+ 11 - 4
app/Listeners/Verified.php

@@ -2,16 +2,23 @@
 
 namespace App\Listeners;
 
+use App\Settings\UserSettings;
+
 class Verified
 {
+    private $server_limit_after_verify_email;
+
+    private $credits_reward_after_verify_email;
+
     /**
      * Create the event listener.
      *
      * @return void
      */
-    public function __construct()
+    public function __construct(UserSettings $user_settings)
     {
-        //
+        $this->server_limit_after_verify_email = $user_settings->server_limit_after_verify_email;
+        $this->credits_reward_after_verify_email = $user_settings->credits_reward_after_verify_email;
     }
 
     /**
@@ -23,8 +30,8 @@ class Verified
     public function handle($event)
     {
         if (! $event->user->email_verified_reward) {
-            $event->user->increment('server_limit', config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL'));
-            $event->user->increment('credits', config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL'));
+            $event->user->increment('server_limit', $this->server_limit_after_verify_email);
+            $event->user->increment('credits', $this->credits_reward_after_verify_email);
         }
     }
 }

+ 3 - 2
app/Models/PartnerDiscount.php

@@ -2,6 +2,7 @@
 
 namespace App\Models;
 
+use App\Settings\ReferralSettings;
 use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Facades\Auth;
@@ -33,7 +34,7 @@ class PartnerDiscount extends Model
         return 0;
     }
 
-    public static function getCommission($user_id)
+    public static function getCommission($user_id, $percentage)
     {
         if ($partnerDiscount = PartnerDiscount::where('user_id', $user_id)->first()) {
             if ($partnerDiscount->referral_system_commission >= 0) {
@@ -41,6 +42,6 @@ class PartnerDiscount extends Model
             }
         }
 
-        return config('SETTINGS::REFERRAL:PERCENTAGE');
+        return $percentage;
     }
 }

+ 2 - 0
app/Models/Product.php

@@ -9,6 +9,8 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
 use Illuminate\Database\Eloquent\Relations\BelongsToMany;
 use Spatie\Activitylog\LogOptions;
 use Spatie\Activitylog\Traits\LogsActivity;
+use App\Models\Pterodactyl\Egg;
+use App\Models\Pterodactyl\Node;
 
 class Product extends Model
 {

+ 16 - 5
app/Models/Server.php

@@ -2,7 +2,8 @@
 
 namespace App\Models;
 
-use App\Classes\Pterodactyl;
+use App\Classes\PterodactylClient;
+use App\Settings\PterodactylSettings;
 use Exception;
 use GuzzleHttp\Promise\PromiseInterface;
 use Hidehalo\Nanoid\Client;
@@ -21,6 +22,9 @@ class Server extends Model
 {
     use HasFactory;
     use LogsActivity;
+
+    private PterodactylClient $pterodactyl;
+
     public function getActivitylogOptions(): LogOptions
     {
         return LogOptions::defaults()
@@ -28,6 +32,7 @@ class Server extends Model
             -> logOnly(['*'])
             -> dontSubmitEmptyLogs();
     }
+
     /**
      * @var bool
      */
@@ -62,6 +67,12 @@ class Server extends Model
         'suspended' => 'datetime',
     ];
 
+    public function __construct()
+    {
+        $ptero_settings = new PterodactylSettings();
+        $this->pterodactyl = new PterodactylClient($ptero_settings);
+    }
+
     public static function boot()
     {
         parent::boot();
@@ -73,7 +84,7 @@ class Server extends Model
         });
 
         static::deleting(function (Server $server) {
-            $response = Pterodactyl::client()->delete("/application/servers/{$server->pterodactyl_id}");
+            $response = $server->pterodactyl->client_admin->delete("/application/servers/{$server->pterodactyl_id}");
             if ($response->failed() && ! is_null($server->pterodactyl_id)) {
                 //only return error when it's not a 404 error
                 if ($response['errors'][0]['status'] != '404') {
@@ -96,7 +107,7 @@ class Server extends Model
      */
     public function getPterodactylServer()
     {
-        return Pterodactyl::client()->get("/application/servers/{$this->pterodactyl_id}");
+        return $this->pterodactyl->client_admin->get("/application/servers/{$this->pterodactyl_id}");
     }
 
     /**
@@ -104,7 +115,7 @@ class Server extends Model
      */
     public function suspend()
     {
-        $response = Pterodactyl::suspendServer($this);
+        $response = $this->pterodactyl->suspendServer($this);
 
         if ($response->successful()) {
             $this->update([
@@ -120,7 +131,7 @@ class Server extends Model
      */
     public function unSuspend()
     {
-        $response = Pterodactyl::unSuspendServer($this);
+        $response = $this->pterodactyl->unSuspendServer($this);
 
         if ($response->successful()) {
             $this->update([

+ 15 - 4
app/Models/User.php

@@ -2,9 +2,12 @@
 
 namespace App\Models;
 
-use App\Classes\Pterodactyl;
 use App\Notifications\Auth\QueuedVerifyEmail;
 use App\Notifications\WelcomeMessage;
+use App\Settings\GeneralSettings;
+use App\Settings\UserSettings;
+use App\Classes\PterodactylClient;
+use App\Settings\PterodactylSettings;
 use Illuminate\Contracts\Auth\MustVerifyEmail;
 use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Database\Eloquent\Relations\BelongsToMany;
@@ -23,6 +26,8 @@ class User extends Authenticatable implements MustVerifyEmail
 {
     use HasFactory, Notifiable, LogsActivity, CausesActivity;
 
+    private PterodactylClient $pterodactyl;
+
     /**
      * @var string[]
      */
@@ -85,12 +90,18 @@ class User extends Authenticatable implements MustVerifyEmail
         'server_limit' => 'float',
     ];
 
+    public function __construct()
+    {
+        $ptero_settings = new PterodactylSettings();
+        $this->pterodactyl = new PterodactylClient($ptero_settings);
+    }
+
     public static function boot()
     {
         parent::boot();
 
-        static::created(function (User $user) {
-            $user->notify(new WelcomeMessage($user));
+        static::created(function (User $user, GeneralSettings $general_settings, UserSettings $user_settings) {
+            $user->notify(new WelcomeMessage($user, $general_settings, $user_settings));
         });
 
         static::deleting(function (User $user) {
@@ -111,7 +122,7 @@ class User extends Authenticatable implements MustVerifyEmail
 
             $user->discordUser()->delete();
 
-            Pterodactyl::client()->delete("/application/users/{$user->pterodactyl_id}");
+            $user->pterodactyl->client_admin->delete("/application/users/{$user->pterodactyl_id}");
         });
     }
 

+ 7 - 3
app/Notifications/ReferralNotification.php

@@ -3,6 +3,8 @@
 namespace App\Notifications;
 
 use App\Models\User;
+use App\Settings\GeneralSettings;
+use App\Settings\ReferralSettings;
 use Illuminate\Bus\Queueable;
 use Illuminate\Notifications\Notification;
 
@@ -15,6 +17,8 @@ class ReferralNotification extends Notification
      */
     private $user;
 
+    private $ref_user;
+
     /**
      * Create a new notification instance.
      *
@@ -43,13 +47,13 @@ class ReferralNotification extends Notification
      * @param  mixed  $notifiable
      * @return array
      */
-    public function toArray($notifiable)
+    public function toArray($notifiable, GeneralSettings $general_settings, ReferralSettings $referral_settings)
     {
         return [
             'title' => __('Someone registered using your Code!'),
             'content' => '
-                <p>You received '.config('SETTINGS::REFERRAL::REWARD').' '.config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME').'</p>
-                <p>because '.$this->ref_user->name.' registered with your Referral-Code!</p>
+                <p>You received '. $referral_settings->reward . ' ' . $general_settings->credits_display_name . '</p>
+                <p>because ' . $this->ref_user->name . ' registered with your Referral-Code!</p>
                 <p>Thank you very much for supporting us!.</p>
                 <p>'.config('app.name', 'Laravel').'</p>
             ',

+ 26 - 9
app/Notifications/WelcomeMessage.php

@@ -3,6 +3,8 @@
 namespace App\Notifications;
 
 use App\Models\User;
+use App\Settings\GeneralSettings;
+use App\Settings\UserSettings;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Notifications\Notification;
@@ -16,14 +18,29 @@ class WelcomeMessage extends Notification implements ShouldQueue
      */
     private $user;
 
+    private $credits_display_name;
+
+    private $credits_reward_after_verify_discord;
+
+    private $credits_reward_after_verify_email;
+
+    private $server_limit_after_verify_discord;
+
+    private $server_limit_after_verify_email;
+
     /**
      * Create a new notification instance.
      *
      * @param  User  $user
      */
-    public function __construct(User $user)
+    public function __construct(User $user, GeneralSettings $general_settings, UserSettings $user_settings)
     {
         $this->user = $user;
+        $this->credits_display_name = $general_settings->credits_display_name;
+        $this->credits_reward_after_verify_discord = $user_settings->credits_reward_after_verify_discord;
+        $this->credits_reward_after_verify_email = $user_settings->credits_reward_after_verify_email;
+        $this->server_limit_after_verify_discord = $user_settings->server_limit_after_verify_discord;
+        $this->server_limit_after_verify_email = $user_settings->server_limit_after_verify_email;
     }
 
     /**
@@ -40,18 +57,18 @@ class WelcomeMessage extends Notification implements ShouldQueue
     public function AdditionalLines()
     {
         $AdditionalLine = '';
-        if (config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL') != 0) {
-            $AdditionalLine .= __('Verifying your e-mail address will grant you ').config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL').' '.__('additional').' '.config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME').'. <br />';
+        if ($this->credits_reward_after_verify_email != 0) {
+            $AdditionalLine .= __('Verifying your e-mail address will grant you ').$this->credits_reward_after_verify_email.' '.__('additional').' '.$this->credits_display_name.'. <br />';
         }
-        if (config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL') != 0) {
-            $AdditionalLine .= __('Verifying your e-mail will also increase your Server Limit by ').config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL').'. <br />';
+        if ($this->server_limit_after_verify_email != 0) {
+            $AdditionalLine .= __('Verifying your e-mail will also increase your Server Limit by ').$this->server_limit_after_verify_email.'. <br />';
         }
         $AdditionalLine .= '<br />';
-        if (config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD') != 0) {
-            $AdditionalLine .= __('You can also verify your discord account to get another ').config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD').' '.config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME').'. <br />';
+        if ($this->credits_reward_after_verify_discord != 0) {
+            $AdditionalLine .= __('You can also verify your discord account to get another ').$this->credits_reward_after_verify_discord.' '.$this->credits_display_name.'. <br />';
         }
-        if (config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD') != 0) {
-            $AdditionalLine .= __('Verifying your Discord account will also increase your Server Limit by ').config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD').'. <br />';
+        if ($this->server_limit_after_verify_discord != 0) {
+            $AdditionalLine .= __('Verifying your Discord account will also increase your Server Limit by ').$this->server_limit_after_verify_discord.'. <br />';
         }
 
         return $AdditionalLine;

+ 1 - 1
app/Settings/DiscordSettings.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace app\Settings;
+namespace App\Settings;
 
 use Spatie\LaravelSettings\Settings;
 

+ 1 - 1
app/Settings/InvoiceSettings.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace app\Settings;
+namespace App\Settings;
 
 use Spatie\LaravelSettings\Settings;
 

+ 1 - 1
app/Settings/LocaleSettings.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace app\Settings;
+namespace App\Settings;
 
 use Spatie\LaravelSettings\Settings;
 

+ 1 - 1
app/Settings/MailSettings.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace app\Settings;
+namespace App\Settings;
 
 use Spatie\LaravelSettings\Settings;
 

+ 1 - 1
app/Settings/PterodactylSettings.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace app\Settings;
+namespace App\Settings;
 
 use Spatie\LaravelSettings\Settings;
 

+ 1 - 1
app/Settings/ReferralSettings.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace app\Settings;
+namespace App\Settings;
 
 use Spatie\LaravelSettings\Settings;
 

+ 1 - 1
app/Settings/ServerSettings.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace app\Settings;
+namespace App\Settings;
 
 use Spatie\LaravelSettings\Settings;
 

+ 1 - 1
app/Settings/TicketSettings.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace app\Settings;
+namespace App\Settings;
 
 use Spatie\LaravelSettings\Settings;
 

+ 1 - 1
app/Settings/UserSettings.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace app\Settings;
+namespace App\Settings;
 
 use Spatie\LaravelSettings\Settings;
 

+ 1 - 1
app/Settings/WebsiteSettings.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace app\Settings;
+namespace App\Settings;
 
 use Spatie\LaravelSettings\Settings;
 

+ 9 - 8
app/Traits/Invoiceable.php

@@ -6,6 +6,7 @@ use App\Models\PartnerDiscount;
 use App\Models\Payment;
 use App\Models\ShopProduct;
 use App\Notifications\InvoiceNotification;
+use App\Settings\InvoiceSettings;
 use Illuminate\Support\Facades\Storage;
 use LaravelDaily\Invoices\Classes\Buyer;
 use LaravelDaily\Invoices\Classes\InvoiceItem;
@@ -15,7 +16,7 @@ use Symfony\Component\Intl\Currencies;
 
 trait Invoiceable
 {
-    public function createInvoice(Payment $payment, ShopProduct $shopProduct)
+    public function createInvoice(Payment $payment, ShopProduct $shopProduct, InvoiceSettings $invoice_settings)
     {
         $user = $payment->user;
         //create invoice
@@ -24,13 +25,13 @@ trait Invoiceable
         $logoPath = storage_path('app/public/logo.png');
 
         $seller = new Party([
-            'name' => config("SETTINGS::INVOICE:COMPANY_NAME"),
-            'phone' => config("SETTINGS::INVOICE:COMPANY_PHONE"),
-            'address' => config("SETTINGS::INVOICE:COMPANY_ADDRESS"),
-            'vat' => config("SETTINGS::INVOICE:COMPANY_VAT"),
+            'name' => $invoice_settings->company_name,
+            'phone' => $invoice_settings->company_phone,
+            'address' => $invoice_settings->company_address,
+            'vat' => $invoice_settings->company_vat,
             'custom_fields' => [
-                'E-Mail' => config("SETTINGS::INVOICE:COMPANY_MAIL"),
-                "Web" => config("SETTINGS::INVOICE:COMPANY_WEBSITE")
+                'E-Mail' => $invoice_settings->company_mail,
+                "Web" => $invoice_settings->company_website
             ],
         ]);
 
@@ -64,7 +65,7 @@ trait Invoiceable
             ->series(now()->format('mY'))
             ->delimiter("-")
             ->sequence($newInvoiceID)
-            ->serialNumberFormat(config("SETTINGS::INVOICE:PREFIX") . '{DELIMITER}{SERIES}{SEQUENCE}')
+            ->serialNumberFormat($invoice_settings->prefix . '{DELIMITER}{SERIES}{SEQUENCE}')
             ->currencyCode(strtoupper($payment->currency_code))
             ->currencySymbol(Currencies::getSymbol(strtoupper($payment->currency_code)))
             ->notes($notes);

+ 1 - 1
themes/default/views/admin/products/index.blade.php

@@ -55,7 +55,7 @@
                             <th>{{__('Min Credits')}}</th>
                             <th>{{__('Servers')}}</th>
                             <th>{{__('Created at')}}</th>
-                            <th></th>
+                            <th>{{ __('Actions') }}</th>
                         </tr>
                         </thead>
                         <tbody></tbody>

+ 1 - 1
themes/default/views/moderator/ticket/show.blade.php

@@ -35,7 +35,7 @@
                         <div class="card-body">
                             <div class="ticket-info">
                                 @if(!empty($server))
-                                <p><b>{{__("Server")}}:</b> <a href="{{ config("SETTINGS::SYSTEM:PTERODACTYL:URL") . '/admin/servers/view/' . $server->pterodactyl_id }}" target="__blank">{{ $server->name }}</a></p>
+                                <p><b>{{__("Server")}}:</b> <a href="{{ $pterodactyl_url . '/admin/servers/view/' . $server->pterodactyl_id }}" target="__blank">{{ $server->name }}</a></p>
                                 @endif
                                 <p><b>{{__("Title")}}:</b> {{ $ticket->title }}</p>
                                 <p><b>{{__("Category")}}:</b> {{ $ticketcategory->name }}</p>

+ 4 - 4
themes/default/views/profile/index.blade.php

@@ -41,7 +41,7 @@
                     @endif
 
                     @if (is_null(Auth::user()->discordUser) && strtolower($force_discord_verification) == 'true')
-                        @if (!empty(config('SETTINGS::DISCORD:CLIENT_ID')) && !empty(config('SETTINGS::DISCORD:CLIENT_SECRET')))
+                        @if (!empty($discord_client_id) && !empty($discord_client_secret))
                             <div class="alert alert-warning p-2 m-2">
                                 <h5>
                                     <i class="icon fas fa-exclamation-circle"></i>{{ __('Required Discord verification!') }}
@@ -100,8 +100,8 @@
                                                     class="fa fa-coins mr-2"></i>{{ $user->Credits() }}</span>
                                         </div>
 
-                                    @if(config('SETTINGS::REFERRAL::ENABLED') == "true")
-                                        @if((config('SETTINGS::REFERRAL::ALLOWED') == "client" && $user->role != "member") || config('SETTINGS::REFERRAL::ALLOWED') == "everyone")
+                                    @if($referral_enabled)
+                                        @if(($referral_allowed === "client" && $user->role != "member") || $referral_allowed === "everyone")
                                             <div class="mt-1">
                                                     <span class="badge badge-success"><i
                                                             class="fa fa-user-check mr-2"></i>
@@ -239,7 +239,7 @@
                                                     </div>
                                                 </div>
                                             </div>
-                                            @if (!empty(config('SETTINGS::DISCORD:CLIENT_ID')) && !empty(config('SETTINGS::DISCORD:CLIENT_SECRET')))
+                                            @if (!empty($discord_client_id) && !empty($discord_client_secret))
                                                 <div class="col-12 col-sm-5 offset-sm-1 mb-3">
                                                     @if (is_null(Auth::user()->discordUser))
                                                         <b>{{ __('Link your discord account!') }}</b>

+ 3 - 3
themes/default/views/servers/create.blade.php

@@ -35,9 +35,9 @@
                             <div class="card-title"><i class="fas fa-cogs mr-2"></i>{{ __('Server configuration') }}
                             </div>
                         </div>
-                        @if (!config('SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS'))
+                        @if (!$server_creation_enabled)
                             <div class="alert alert-warning p-2 m-2">
-                                The creation of new servers has been disabled for regular users, enable it again
+                                {{ __('The creation of new servers has been disabled for regular users, enable it again') }}
                                 <a href="{{ route('admin.settings.system') }}">{{ __('here') }}</a>.
                             </div>
                         @endif
@@ -212,7 +212,7 @@
                                                         {{ __('Required') }} {{ CREDITS_DISPLAY_NAME }}
                                                         {{ __('to create this server') }}</span>
                                                     <span class="d-inline-block"
-                                                        x-text="product.minimum_credits == -1 ? {{ config('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER') }} : product.minimum_credits"></span>
+                                                        x-text="product.minimum_credits == -1 ? {{ $min_credits_to_make_server }} : product.minimum_credits"></span>
                                                 </li>
                                             </ul>
                                         </div>

+ 18 - 16
themes/default/views/servers/index.blade.php

@@ -36,9 +36,9 @@
                         class="fa fa-plus mr-2"></i>
                     {{ __('Create Server') }}
                 </a>
-                @if (Auth::user()->Servers->count() > 0&&!empty(config('SETTINGS::MISC:PHPMYADMIN:URL')))
+                @if (Auth::user()->Servers->count() > 0 && !empty($phpmyadmin_url))
                     <a 
-                        href="{{ config('SETTINGS::MISC:PHPMYADMIN:URL') }}" target="_blank"
+                        href="{{ $phpmyadmin_url }}" target="_blank"
                         class="btn btn-secondary ml-2"><i title="manage"
                         class="fas fa-database mr-2"></i><span>{{ __('Database') }}</span>
                     </a>
@@ -47,8 +47,8 @@
 
             <div class="row d-flex flex-row justify-content-center justify-content-md-start">
                 @foreach ($servers as $server)
-                    @if($server->location&&$server->node&&$server->nest&&$server->egg)
-                        <div class="col-xl-3 col-lg-5 col-md-6 col-sm-6 col-xs-12 card pr-0 pl-0 ml-sm-2 mr-sm-3"
+                    @if($server->location && $server->node && $server->nest && $server->egg)
+                        <div class="col-xl-4 col-lg-5 col-md-6 col-sm-6 col-xs-12 card pr-0 pl-0 ml-sm-2 mr-sm-3"
                             style="max-width: 350px">
                             <div class="card-header">
                                 <div class="d-flex justify-content-between align-items-center">
@@ -112,7 +112,7 @@
                                         <div class="col-4">
                                             {{ __('Price') }}:
                                             <span class="text-muted">
-                                                ({{ CREDITS_DISPLAY_NAME }})
+                                                {{ $credits_display_name }}
                                             </span>
                                         </div>
                                         <div class="col-8">
@@ -136,17 +136,19 @@
                                 </div>
                             </div>
 
-                            <div class="card-footer d-flex align-items-center justify-content-between">
-                                <a href="{{ config('SETTINGS::SYSTEM:PTERODACTYL:URL') }}/server/{{ $server->identifier }}"
-                                    target="__blank"
-                                    class="btn btn-info mx-3 w-100 align-items-center justify-content-center d-flex">
-                                    <i class="fas fa-tools mr-2"></i>
-                                    <span>{{ __('Manage') }}</span>
-                                </a>
-                                <a href="{{ route('servers.show', ['server' => $server->id])}}" class="btn btn-warning mx-3 w-100 align-items-center justify-content-center d-flex">
-                                    <i class="fas fa-cog mr-2"></i>
-                                    <span>{{ __('Settings') }}</span>
-                                </a>
+                            <div class="card-footer d-flex align-items-center justify-content-center w-auto">
+                                <div class="d-flex w-100" style="justify-content: space-evenly">
+                                    <a href="{{ $pterodactyl_url }}/server/{{ $server->identifier }}"
+                                        target="__blank"
+                                        class="btn btn-info align-items-center justify-content-center d-flex">
+                                        <i class="fas fa-tools mr-2"></i>
+                                        <span>{{ __('Manage') }}</span>
+                                    </a>
+                                    <a href="{{ route('servers.show', ['server' => $server->id])}}" class="btn btn-warning align-items-center justify-content-center d-flex">
+                                        <i class="fas fa-cog mr-2"></i>
+                                        <span>{{ __('Settings') }}</span>
+                                    </a>
+                                </div>
                             </div>
                         </div>
                     @endif

+ 1 - 5
themes/default/views/servers/settings.blade.php

@@ -222,16 +222,12 @@
                 <div class="card-footer">
                     <div class="col-md-12 text-center">
                         <!-- Upgrade Button trigger modal -->
-                        @if(config("SETTINGS::SYSTEM:ENABLE_UPGRADE"))
+                        @if($server_enable_upgrade)
                             <button type="button" data-toggle="modal" data-target="#UpgradeModal{{ $server->id }}" target="__blank"
                                 class="btn btn-info btn-md">
                                 <i class="fas fa-upload mr-2"></i>
                                 <span>{{ __('Upgrade / Downgrade') }}</span>
                             </button>
-
-
-
-
                         <!-- Upgrade Modal -->
                         <div style="width: 100%; margin-block-start: 100px;" class="modal fade" id="UpgradeModal{{ $server->id }}" tabindex="-1">
                             <div class="modal-dialog">

+ 1 - 3
themes/default/views/ticket/show.blade.php

@@ -35,9 +35,7 @@
                         <div class="card-body">
                             <div class="ticket-info">
                                 @if(!empty($server))
-                                    <p><b>{{__("Server")}}:</b> <a
-                                            href="{{ config('SETTINGS::SYSTEM:PTERODACTYL:URL') }}/server/{{ $server->identifier }}"
-                                            target="__blank">{{ $server->name }} </a></p>
+                                <p><b>{{__("Server")}}:</b> <a href="{{ $pterodactyl_url }}/server/{{ $server->identifier }}" target="__blank">{{ $server->name }} </a></p>
                                 @endif
                                 <p><b>{{__("Title")}}:</b> {{ $ticket->title }}</p>
                                 <p><b>{{__("Category")}}:</b> {{ $ticketcategory->name }}</p>