Merge branch 'ControlPanel-gg:development' into development

This commit is contained in:
Dennis 2022-01-26 07:10:23 +01:00 committed by GitHub
commit 701beefd54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 95 additions and 88 deletions

View file

@ -26,8 +26,8 @@ class CreditProductController extends Controller
if (
env('APP_ENV') == 'local' ||
Settings::getValueByKey("SETTINGS::PAYMENTS:PAYPAL:SECRET") && Settings::getValueByKey("SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID") ||
Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:SECRET") && Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET") && Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:METHODS")
config("SETTINGS::PAYMENTS:PAYPAL:SECRET") && config("SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID") ||
config("SETTINGS::PAYMENTS:STRIPE:SECRET") && config("SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET") && config("SETTINGS::PAYMENTS:STRIPE:METHODS")
) $isPaymentSetup = true;
return view('admin.store.index', [

View file

@ -134,7 +134,7 @@ class PaymentController extends Controller
*/
protected function getPaypalClientId()
{
return env('APP_ENV') == 'local' ? Settings::getValueByKey("SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID") : Settings::getValueByKey("SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID");
return env('APP_ENV') == 'local' ? config("SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID") : config("SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID");
}
/**
@ -142,7 +142,7 @@ class PaymentController extends Controller
*/
protected function getPaypalClientSecret()
{
return env('APP_ENV') == 'local' ? Settings::getValueByKey("SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET") : Settings::getValueByKey("SETTINGS::PAYMENTS:PAYPAL:SECRET");
return env('APP_ENV') == 'local' ? config("SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET") : config("SETTINGS::PAYMENTS:PAYPAL:SECRET");
}
/**
@ -167,9 +167,9 @@ class PaymentController extends Controller
$user->increment('credits', $creditProduct->quantity);
//update server limit
if (Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) {
if ($user->server_limit < Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')) {
$user->update(['server_limit' => Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')]);
if (config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) {
if ($user->server_limit < config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')) {
$user->update(['server_limit' => config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')]);
}
}
@ -308,9 +308,9 @@ class PaymentController extends Controller
$user->increment('credits', $creditProduct->quantity);
//update server limit
if (Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) {
if ($user->server_limit < Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')) {
$user->update(['server_limit' => Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')]);
if (config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) {
if ($user->server_limit < config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')) {
$user->update(['server_limit' => config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')]);
}
}
@ -408,9 +408,9 @@ class PaymentController extends Controller
$user->increment('credits', $payment->amount);
//update server limit
if (Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) {
if ($user->server_limit < Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')) {
$user->update(['server_limit' => Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')]);
if (config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) {
if ($user->server_limit < config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')) {
$user->update(['server_limit' => config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')]);
}
}
@ -487,8 +487,8 @@ class PaymentController extends Controller
protected function getStripeSecret()
{
return env('APP_ENV') == 'local'
? Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:TEST_SECRET")
: Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:SECRET");
? config("SETTINGS::PAYMENTS:STRIPE:TEST_SECRET")
: config("SETTINGS::PAYMENTS:STRIPE:SECRET");
}
/**
@ -497,8 +497,8 @@ class PaymentController extends Controller
protected function getStripeEndpointSecret()
{
return env('APP_ENV') == 'local'
? Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET")
: Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET");
? config("SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET")
: config("SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET");
}
@ -511,13 +511,13 @@ class PaymentController extends Controller
$logoPath = storage_path('app/public/logo.png');
$seller = new Party([
'name' => Settings::getValueByKey("SETTINGS::INVOICE:COMPANY_NAME"),
'phone' => Settings::getValueByKey("SETTINGS::INVOICE:COMPANY_PHONE"),
'address' => Settings::getValueByKey("SETTINGS::INVOICE:COMPANY_ADDRESS"),
'vat' => Settings::getValueByKey("SETTINGS::INVOICE:COMPANY_VAT"),
'name' => config("SETTINGS::INVOICE:COMPANY_NAME"),
'phone' => config("SETTINGS::INVOICE:COMPANY_PHONE"),
'address' => config("SETTINGS::INVOICE:COMPANY_ADDRESS"),
'vat' => config("SETTINGS::INVOICE:COMPANY_VAT"),
'custom_fields' => [
'E-Mail' => Settings::getValueByKey("SETTINGS::INVOICE:COMPANY_MAIL"),
"Web" => Settings::getValueByKey("SETTINGS::INVOICE:COMPANY_WEBSITE")
'E-Mail' => config("SETTINGS::INVOICE:COMPANY_MAIL"),
"Web" => config("SETTINGS::INVOICE:COMPANY_WEBSITE")
],
]);
@ -552,7 +552,7 @@ class PaymentController extends Controller
->series(now()->format('mY'))
->delimiter("-")
->sequence($newInvoiceID)
->serialNumberFormat(Settings::getValueByKey("SETTINGS::INVOICE:PREFIX") . '{DELIMITER}{SERIES}{SEQUENCE}')
->serialNumberFormat(config("SETTINGS::INVOICE:PREFIX") . '{DELIMITER}{SERIES}{SEQUENCE}')
->notes($notes);
if (file_exists($logoPath)) {

View file

@ -40,7 +40,8 @@ class ProductController extends Controller
]);
}
public function clone(Request $request , Product $product){
public function clone(Request $request, Product $product)
{
return view('admin.products.create', [
'product' => $product,
'locations' => Location::with('nodes')->get(),
@ -94,7 +95,7 @@ class ProductController extends Controller
{
return view('admin.products.show', [
'product' => $product,
'minimum_credits' => Settings::getValueByKey("SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER"),
'minimum_credits' => config("SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER"),
]);
}

View file

@ -103,7 +103,8 @@ class ServerController extends Controller
* @param Server $server
* @return RedirectResponse
*/
public function toggleSuspended(Server $server){
public function toggleSuspended(Server $server)
{
try {
$server->isSuspended() ? $server->unSuspend() : $server->suspend();
} catch (Exception $exception) {
@ -162,7 +163,7 @@ class ServerController extends Controller
return $server->suspended ? $server->suspended->diffForHumans() : '';
})
->editColumn('name', function (Server $server) {
return '<a class="text-info" target="_blank" href="' . Settings::getValueByKey("SETTINGS::SYSTEM:PTERODACTYL:URL") . '/admin/servers/view/' . $server->pterodactyl_id . '">' . $server->name . '</a>';
return '<a class="text-info" target="_blank" href="' . config("SETTINGS::SYSTEM:PTERODACTYL:URL") . '/admin/servers/view/' . $server->pterodactyl_id . '">' . $server->name . '</a>';
})
->rawColumns(['user', 'actions', 'status', 'name'])
->make();

View file

@ -226,7 +226,8 @@ class UserController extends Controller
* @param User $user
* @return RedirectResponse
*/
public function toggleSuspended(User $user){
public function toggleSuspended(User $user)
{
try {
!$user->isSuspended() ? $user->suspend() : $user->unSuspend();
} catch (Exception $exception) {
@ -301,7 +302,7 @@ class UserController extends Controller
return '<span class="badge ' . $badgeColor . '">' . $user->role . '</span>';
})
->editColumn('name', function (User $user) {
return '<a class="text-info" target="_blank" href="' . Settings::getValueByKey("SETTINGS::SYSTEM:PTERODACTYL:URL") . '/admin/users/view/' . $user->pterodactyl_id . '">' . $user->name . '</a>';
return '<a class="text-info" target="_blank" href="' . config("SETTINGS::SYSTEM:PTERODACTYL:URL") . '/admin/users/view/' . $user->pterodactyl_id . '">' . $user->name . '</a>';
})
->orderColumn('last_seen', function ($query, $order) {
$query->orderBy('last_seen', $order);

View file

@ -242,8 +242,8 @@ class UserController extends Controller
$user = User::create([
'name' => $request->input('name'),
'email' => $request->input('email'),
'credits' => Settings::getValueByKey('SETTINGS::USER:INITIAL_CREDITS', 150),
'server_limit' => Settings::getValueByKey('SETTINGS::USER:INITIAL_SERVER_LIMIT', 1),
'credits' => config('SETTINGS::USER:INITIAL_CREDITS', 150),
'server_limit' => config('SETTINGS::USER:INITIAL_SERVER_LIMIT', 1),
'password' => Hash::make($request->input('password')),
]);

View file

@ -15,7 +15,7 @@ class SocialiteController extends Controller
{
public function redirect()
{
$scopes = !empty(Settings::getValueByKey("SETTINGS::DISCORD:BOT_TOKEN")) && !empty(Settings::getValueByKey("SETTINGS::DISCORD:GUILD_ID")) ? ['guilds.join'] : [];
$scopes = !empty(config("SETTINGS::DISCORD:BOT_TOKEN")) && !empty(config("SETTINGS::DISCORD:GUILD_ID")) ? ['guilds.join'] : [];
return Socialite::driver('discord')
->scopes($scopes)
@ -31,17 +31,17 @@ class SocialiteController extends Controller
/** @var User $user */
$user = Auth::user();
$discord = Socialite::driver('discord')->user();
$botToken = Settings::getValueByKey("SETTINGS::DISCORD:BOT_TOKEN");
$guildId = Settings::getValueByKey("SETTINGS::DISCORD:GUILD_ID");
$roleId = Settings::getValueByKey("SETTINGS::DISCORD:ROLE_ID");
$botToken = config("SETTINGS::DISCORD:BOT_TOKEN");
$guildId = config("SETTINGS::DISCORD:GUILD_ID");
$roleId = config("SETTINGS::DISCORD:ROLE_ID");
//save / update discord_users
if (is_null($user->discordUser)) {
//create discord user in db
DiscordUser::create(array_merge($discord->user, ['user_id' => Auth::user()->id]));
//update user
Auth::user()->increment('credits', Settings::getValueByKey('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD'));
Auth::user()->increment('server_limit', Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD'));
Auth::user()->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()->update(['discord_verified_at' => now()]);
} else {
$user->discordUser->update($discord->user);
@ -55,8 +55,10 @@ class SocialiteController extends Controller
'Authorization' => 'Bot ' . $botToken,
'Content-Type' => 'application/json',
]
)->put("https://discord.com/api/guilds/{$guildId}/members/{$discord->id}",
['access_token' => $discord->token]);
)->put(
"https://discord.com/api/guilds/{$guildId}/members/{$discord->id}",
['access_token' => $discord->token]
);
//give user a role in the discord server
if (!empty($roleId)) {
@ -65,8 +67,10 @@ class SocialiteController extends Controller
'Authorization' => 'Bot ' . $botToken,
'Content-Type' => 'application/json',
]
)->put("https://discord.com/api/guilds/{$guildId}/members/{$discord->id}/roles/{$roleId}",
['access_token' => $discord->token]);
)->put(
"https://discord.com/api/guilds/{$guildId}/members/{$discord->id}/roles/{$roleId}",
['access_token' => $discord->token]
);
}
}

View file

@ -15,17 +15,17 @@ class StoreController extends Controller
if (
env('APP_ENV') == 'local' ||
Settings::getValueByKey("SETTINGS::PAYMENTS:PAYPAL:SECRET") && Settings::getValueByKey("SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID") ||
Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:SECRET") && Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET") && Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:METHODS")
config("SETTINGS::PAYMENTS:PAYPAL:SECRET") && config("SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID") ||
config("SETTINGS::PAYMENTS:STRIPE:SECRET") && config("SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET") && config("SETTINGS::PAYMENTS:STRIPE:METHODS")
) $isPaymentSetup = true;
//Required Verification for creating an server
if (Settings::getValueByKey('SETTINGS::USER:FORCE_EMAIL_VERIFICATION', false) === 'true' && !Auth::user()->hasVerifiedEmail()) {
if (config('SETTINGS::USER:FORCE_EMAIL_VERIFICATION', false) === 'true' && !Auth::user()->hasVerifiedEmail()) {
return redirect()->route('profile.index')->with('error', __("You are required to verify your email address before you can purchase credits."));
}
//Required Verification for creating an server
if (Settings::getValueByKey('SETTINGS::USER:FORCE_DISCORD_VERIFICATION', false) === 'true' && !Auth::user()->discordUser) {
if (config('SETTINGS::USER:FORCE_DISCORD_VERIFICATION', false) === 'true' && !Auth::user()->discordUser) {
return redirect()->route('profile.index')->with('error', __("You are required to link your discord account before you can purchase Credits"));
}

View file

@ -19,7 +19,7 @@ class UnsuspendServers implements ShouldQueue
*/
public function handle(UserUpdateCreditsEvent $event)
{
if ($event->user->credits > Settings::getValueByKey('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER' , 50)){
if ($event->user->credits > config('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', 50)) {
/** @var Server $server */
foreach ($event->user->servers as $server) {
if ($server->isSuspended()) $server->unSuspend();

View file

@ -24,7 +24,7 @@ class Verified
*/
public function handle($event)
{
$event->user->increment('server_limit' , Settings::getValueByKey('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL'));
$event->user->increment('credits' , Settings::getValueByKey('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL'));
$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'));
}
}

View file

@ -59,7 +59,7 @@ class CreditProduct extends Model
*/
public function getTaxPercent()
{
$tax = Settings::getValueByKey("SETTINGS::PAYMENTS:SALES_TAX");
$tax = config("SETTINGS::PAYMENTS:SALES_TAX");
return $tax < 0 ? 0 : $tax;
}