diff --git a/app/Classes/PterodactylClient.php b/app/Classes/PterodactylClient.php index 8aa85a35..d196c26c 100644 --- a/app/Classes/PterodactylClient.php +++ b/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 diff --git a/app/Console/Commands/MakeUserCommand.php b/app/Console/Commands/MakeUserCommand.php index a9cf66b8..bef0a6a0 100644 --- a/app/Console/Commands/MakeUserCommand.php +++ b/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); } diff --git a/app/Http/Controllers/Admin/OverViewController.php b/app/Http/Controllers/Admin/OverViewController.php index 7dc3653c..f5f67c99 100644 --- a/app/Http/Controllers/Admin/OverViewController.php +++ b/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 diff --git a/app/Http/Controllers/Admin/PartnerController.php b/app/Http/Controllers/Admin/PartnerController.php index 0a793904..cea2aec2 100644 --- a/app/Http/Controllers/Admin/PartnerController.php +++ b/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()) ? ''.$user->name.'' : __('Unknown user'); + return ($user = User::where('id', $partner->user_id)->first()) ? '' . $user->name . '' : __('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(); diff --git a/app/Http/Controllers/Admin/ProductController.php b/app/Http/Controllers/Admin/ProductController.php index 62b233d4..f26691e3 100644 --- a/app/Http/Controllers/Admin/ProductController.php +++ b/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 ' -
- '.csrf_field().' - '.method_field('PATCH').' -
- - -
-
+
+ '.csrf_field().' + '.method_field('PATCH').' +
+ + +
+
'; }) - ->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() : ''; diff --git a/app/Http/Controllers/Admin/ServerController.php b/app/Http/Controllers/Admin/ServerController.php index 65fdfa23..8e2475f5 100644 --- a/app/Http/Controllers/Admin/ServerController.php +++ b/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 '' . strip_tags($server->name) . ''; + ->editColumn('name', function (Server $server, PterodactylSettings $ptero_settings) { + return '' . strip_tags($server->name) . ''; }) ->rawColumns(['user', 'actions', 'status', 'name']) ->make(); diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index a20dd3a8..b99ec841 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/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 '' . strip_tags($user->name) . ''; + ->editColumn('name', function (User $user, PterodactylSettings $ptero_settings) { + return '' . strip_tags($user->name) . ''; }) ->rawColumns(['avatar', 'name', 'credits', 'role', 'usage', 'actions']) ->make(); diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index ae36b9bd..797ae7b7 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/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 diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index bd9df2d8..79f1e99f 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/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', ]); diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 848db48a..2889dafd 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/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); diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index bbc1c8ad..35136f50 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/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([ diff --git a/app/Http/Controllers/Auth/SocialiteController.php b/app/Http/Controllers/Auth/SocialiteController.php index 101a367a..4e495d43 100644 --- a/app/Http/Controllers/Auth/SocialiteController.php +++ b/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); diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 384dac8c..a0a2a8a3 100644 --- a/app/Http/Controllers/Controller.php +++ b/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) { - - } - } } diff --git a/app/Http/Controllers/Moderation/TicketsController.php b/app/Http/Controllers/Moderation/TicketsController.php index 897cb7f4..cb05f36f 100644 --- a/app/Http/Controllers/Moderation/TicketsController.php +++ b/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) diff --git a/app/Http/Controllers/ProductController.php b/app/Http/Controllers/ProductController.php index e2e01cad..5f3d94dc 100644 --- a/app/Http/Controllers/ProductController.php +++ b/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 * diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 1c0fd9ad..ea6ffcf6 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/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'), diff --git a/app/Http/Controllers/Pterodactyl/PterodactylController.php b/app/Http/Controllers/Pterodactyl/PterodactylController.php deleted file mode 100644 index 350b7b0d..00000000 --- a/app/Http/Controllers/Pterodactyl/PterodactylController.php +++ /dev/null @@ -1,12 +0,0 @@ -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 ]); } diff --git a/app/Http/Controllers/TicketsController.php b/app/Http/Controllers/TicketsController.php index a3dadc06..7cdea7b1 100644 --- a/app/Http/Controllers/TicketsController.php +++ b/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) diff --git a/app/Http/Middleware/GlobalNames.php b/app/Http/Middleware/GlobalNames.php index 4874a2f6..9250f23b 100644 --- a/app/Http/Middleware/GlobalNames.php +++ b/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); diff --git a/app/Http/Middleware/SetLocale.php b/app/Http/Middleware/SetLocale.php index 64174677..692944d1 100644 --- a/app/Http/Middleware/SetLocale.php +++ b/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; } } } diff --git a/app/Listeners/CreateInvoice.php b/app/Listeners/CreateInvoice.php index 3b447657..f81364a3 100644 --- a/app/Listeners/CreateInvoice.php +++ b/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); } diff --git a/app/Listeners/UnsuspendServers.php b/app/Listeners/UnsuspendServers.php index 587cd84f..f67cdcc9 100644 --- a/app/Listeners/UnsuspendServers.php +++ b/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()) { diff --git a/app/Listeners/UserPayment.php b/app/Listeners/UserPayment.php index be947087..4fbe9ba8 100644 --- a/app/Listeners/UserPayment.php +++ b/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 . ')'); } } } diff --git a/app/Listeners/Verified.php b/app/Listeners/Verified.php index 6863e462..9ed9bf37 100644 --- a/app/Listeners/Verified.php +++ b/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); } } } diff --git a/app/Models/PartnerDiscount.php b/app/Models/PartnerDiscount.php index 01f93b2d..b08a89af 100644 --- a/app/Models/PartnerDiscount.php +++ b/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; } } diff --git a/app/Models/Product.php b/app/Models/Product.php index a31ebf50..31703aa5 100644 --- a/app/Models/Product.php +++ b/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 { diff --git a/app/Models/Server.php b/app/Models/Server.php index 94365dd4..ca7761c3 100644 --- a/app/Models/Server.php +++ b/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([ diff --git a/app/Models/User.php b/app/Models/User.php index 85e2b240..2b510e45 100644 --- a/app/Models/User.php +++ b/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}"); }); } diff --git a/app/Notifications/ReferralNotification.php b/app/Notifications/ReferralNotification.php index dec1ea0e..a1eaff0c 100644 --- a/app/Notifications/ReferralNotification.php +++ b/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' => ' -

You received '.config('SETTINGS::REFERRAL::REWARD').' '.config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME').'

-

because '.$this->ref_user->name.' registered with your Referral-Code!

+

You received '. $referral_settings->reward . ' ' . $general_settings->credits_display_name . '

+

because ' . $this->ref_user->name . ' registered with your Referral-Code!

Thank you very much for supporting us!.

'.config('app.name', 'Laravel').'

', diff --git a/app/Notifications/WelcomeMessage.php b/app/Notifications/WelcomeMessage.php index d6aa073b..ac33e1c1 100644 --- a/app/Notifications/WelcomeMessage.php +++ b/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').'.
'; + 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.'.
'; } - 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').'.
'; + 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.'.
'; } $AdditionalLine .= '
'; - 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').'.
'; + 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.'.
'; } - 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').'.
'; + 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.'.
'; } return $AdditionalLine; diff --git a/app/Settings/DiscordSettings.php b/app/Settings/DiscordSettings.php index 84decf3f..49d4aece 100644 --- a/app/Settings/DiscordSettings.php +++ b/app/Settings/DiscordSettings.php @@ -1,6 +1,6 @@ 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); diff --git a/themes/default/views/admin/products/index.blade.php b/themes/default/views/admin/products/index.blade.php index 6475e842..130a2e1d 100644 --- a/themes/default/views/admin/products/index.blade.php +++ b/themes/default/views/admin/products/index.blade.php @@ -55,7 +55,7 @@ {{__('Min Credits')}} {{__('Servers')}} {{__('Created at')}} - + {{ __('Actions') }} diff --git a/themes/default/views/moderator/ticket/show.blade.php b/themes/default/views/moderator/ticket/show.blade.php index dda8c1f9..b7d992b5 100644 --- a/themes/default/views/moderator/ticket/show.blade.php +++ b/themes/default/views/moderator/ticket/show.blade.php @@ -35,7 +35,7 @@
@if(!empty($server)) -

{{__("Server")}}: pterodactyl_id }}" target="__blank">{{ $server->name }}

+

{{__("Server")}}: {{ $server->name }}

@endif

{{__("Title")}}: {{ $ticket->title }}

{{__("Category")}}: {{ $ticketcategory->name }}

diff --git a/themes/default/views/profile/index.blade.php b/themes/default/views/profile/index.blade.php index 41682761..82d09e14 100644 --- a/themes/default/views/profile/index.blade.php +++ b/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))
{{ __('Required Discord verification!') }} @@ -100,8 +100,8 @@ class="fa fa-coins mr-2">{{ $user->Credits() }}
- @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")
@@ -239,7 +239,7 @@
- @if (!empty(config('SETTINGS::DISCORD:CLIENT_ID')) && !empty(config('SETTINGS::DISCORD:CLIENT_SECRET'))) + @if (!empty($discord_client_id) && !empty($discord_client_secret))
@if (is_null(Auth::user()->discordUser)) {{ __('Link your discord account!') }} diff --git a/themes/default/views/servers/create.blade.php b/themes/default/views/servers/create.blade.php index a613c29f..e75f7756 100644 --- a/themes/default/views/servers/create.blade.php +++ b/themes/default/views/servers/create.blade.php @@ -35,9 +35,9 @@
{{ __('Server configuration') }}
- @if (!config('SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS')) + @if (!$server_creation_enabled)
- 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') }} {{ __('here') }}.
@endif @@ -212,7 +212,7 @@ {{ __('Required') }} {{ CREDITS_DISPLAY_NAME }} {{ __('to create this server') }} + x-text="product.minimum_credits == -1 ? {{ $min_credits_to_make_server }} : product.minimum_credits"> diff --git a/themes/default/views/servers/index.blade.php b/themes/default/views/servers/index.blade.php index ef856b6a..4b9b7df1 100644 --- a/themes/default/views/servers/index.blade.php +++ b/themes/default/views/servers/index.blade.php @@ -36,9 +36,9 @@ class="fa fa-plus mr-2"> {{ __('Create Server') }} - @if (Auth::user()->Servers->count() > 0&&!empty(config('SETTINGS::MISC:PHPMYADMIN:URL'))) + @if (Auth::user()->Servers->count() > 0 && !empty($phpmyadmin_url)) {{ __('Database') }} @@ -47,8 +47,8 @@
@foreach ($servers as $server) - @if($server->location&&$server->node&&$server->nest&&$server->egg) -
location && $server->node && $server->nest && $server->egg) +
@@ -112,7 +112,7 @@
{{ __('Price') }}: - ({{ CREDITS_DISPLAY_NAME }}) + {{ $credits_display_name }}
@@ -136,17 +136,19 @@
- @endif diff --git a/themes/default/views/servers/settings.blade.php b/themes/default/views/servers/settings.blade.php index 9fead681..efe9f647 100644 --- a/themes/default/views/servers/settings.blade.php +++ b/themes/default/views/servers/settings.blade.php @@ -222,16 +222,12 @@