Too many changes to mention.
This commit is contained in:
parent
1d2548a174
commit
cfd370eb6d
26 changed files with 194 additions and 91 deletions
|
@ -15,7 +15,7 @@ class InvoiceController extends Controller
|
|||
$zip = new ZipArchive;
|
||||
$zip_safe_path = storage_path('invoices.zip');
|
||||
$res = $zip->open($zip_safe_path, ZipArchive::CREATE | ZipArchive::OVERWRITE);
|
||||
$result = $this::rglob(storage_path('app/invoice/*'));
|
||||
$result = $this->rglob(storage_path('app/invoice/*'));
|
||||
if ($res === true) {
|
||||
$zip->addFromString('1. Info.txt', __('Created at').' '.now()->format('d.m.Y'));
|
||||
foreach ($result as $file) {
|
||||
|
@ -38,7 +38,7 @@ class InvoiceController extends Controller
|
|||
{
|
||||
$files = glob($pattern, $flags);
|
||||
foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
|
||||
$files = array_merge($files, $this::rglob($dir.'/'.basename($pattern), $flags));
|
||||
$files = array_merge($files, $this->rglob($dir.'/'.basename($pattern), $flags));
|
||||
}
|
||||
|
||||
return $files;
|
||||
|
|
|
@ -20,10 +20,8 @@ class OverViewController extends Controller
|
|||
{
|
||||
public const TTL = 86400;
|
||||
|
||||
public function index(PterodactylSettings $ptero_settings)
|
||||
public function index()
|
||||
{
|
||||
//Prepare pterodactyl client
|
||||
$pterodactyl_client = new PterodactylClient($ptero_settings);
|
||||
//Get counters
|
||||
$counters = collect();
|
||||
//Set basic variables in the collection
|
||||
|
@ -137,7 +135,7 @@ class OverViewController extends Controller
|
|||
|
||||
//Get node information and prepare collection
|
||||
$pteroNodeIds = [];
|
||||
foreach ($pterodactyl_client->getNodes() as $pteroNode) {
|
||||
foreach ($this->pterodactyl->getNodes() as $pteroNode) {
|
||||
array_push($pteroNodeIds, $pteroNode['attributes']['id']);
|
||||
}
|
||||
$nodes = collect();
|
||||
|
@ -148,7 +146,7 @@ class OverViewController extends Controller
|
|||
} //Check if node exists on pterodactyl too, if not, skip
|
||||
$nodes->put($nodeId, collect());
|
||||
$nodes[$nodeId]->name = $DBnode['name'];
|
||||
$pteroNode = $pterodactyl_client->getNode($nodeId);
|
||||
$pteroNode = $this->pterodactyl->getNode($nodeId);
|
||||
$nodes[$nodeId]->usagePercent = round(max($pteroNode['allocated_resources']['memory'] / ($pteroNode['memory'] * ($pteroNode['memory_overallocate'] + 100) / 100), $pteroNode['allocated_resources']['disk'] / ($pteroNode['disk'] * ($pteroNode['disk_overallocate'] + 100) / 100)) * 100, 2);
|
||||
$counters['totalUsagePercent'] += $nodes[$nodeId]->usagePercent;
|
||||
|
||||
|
@ -159,7 +157,7 @@ class OverViewController extends Controller
|
|||
}
|
||||
$counters['totalUsagePercent'] = ($DBnodes->count()) ? round($counters['totalUsagePercent'] / $DBnodes->count(), 2) : 0;
|
||||
|
||||
foreach ($pterodactyl_client->getServers() as $server) { //gets all servers from Pterodactyl and calculates total of credit usage for each node separately + total
|
||||
foreach ($this->pterodactyl->getServers() as $server) { //gets all servers from Pterodactyl and calculates total of credit usage for each node separately + total
|
||||
$nodeId = $server['attributes']['node'];
|
||||
|
||||
if ($CPServer = Server::query()->where('pterodactyl_id', $server['attributes']['id'])->first()) {
|
||||
|
|
|
@ -58,11 +58,6 @@ class PaymentController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return view('store.checkout')->with([
|
||||
'product' => $shopProduct,
|
||||
'discountpercent' => $discount,
|
||||
|
|
|
@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
|
|||
use App\Models\Pterodactyl\Location;
|
||||
use App\Models\Pterodactyl\Nest;
|
||||
use App\Models\Product;
|
||||
use App\Settings\UserSettings;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
|
@ -39,7 +40,7 @@ class ProductController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
public function clone(Request $request, Product $product)
|
||||
public function clone(Product $product)
|
||||
{
|
||||
return view('admin.products.create', [
|
||||
'product' => $product,
|
||||
|
@ -90,11 +91,11 @@ class ProductController extends Controller
|
|||
* @param Product $product
|
||||
* @return Application|Factory|View
|
||||
*/
|
||||
public function show(Product $product)
|
||||
public function show(Product $product, UserSettings $user_settings)
|
||||
{
|
||||
return view('admin.products.show', [
|
||||
'product' => $product,
|
||||
'minimum_credits' => config('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER'),
|
||||
'minimum_credits' => $user_settings->min_credits_to_make_server,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -157,7 +158,7 @@ class ProductController extends Controller
|
|||
* @param Product $product
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function disable(Request $request, Product $product)
|
||||
public function disable(Product $product)
|
||||
{
|
||||
$product->update(['disabled' => ! $product->disabled]);
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ class ServerController extends Controller
|
|||
|
||||
// try to update the owner on pterodactyl
|
||||
try {
|
||||
$response = $this->client->updateServerOwner($server, $user->pterodactyl_id);
|
||||
$response = $this->pterodactyl->updateServerOwner($server, $user->pterodactyl_id);
|
||||
if ($response->getStatusCode() != 200) {
|
||||
return redirect()->back()->with('error', 'Failed to update server owner on pterodactyl');
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ class ServerController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
foreach ($this->client->getServers() as $server) { //go thru all ptero servers, if server exists, change value to true in array.
|
||||
foreach ($this->pterodactyl->getServers() as $server) { //go thru all ptero servers, if server exists, change value to true in array.
|
||||
if (isset($CPIDArray[$server['attributes']['id']])) {
|
||||
$CPIDArray[$server['attributes']['id']] = true;
|
||||
|
||||
|
@ -147,7 +147,7 @@ class ServerController extends Controller
|
|||
}, ARRAY_FILTER_USE_BOTH); //Array of servers, that dont exist on ptero (value == false)
|
||||
$deleteCount = 0;
|
||||
foreach ($filteredArray as $key => $CPID) { //delete servers that dont exist on ptero anymore
|
||||
if (!$this->client->getServerAttributes($key, true)) {
|
||||
if (!$this->pterodactyl->getServerAttributes($key, true)) {
|
||||
$deleteCount++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ class ShopProductController extends Controller
|
|||
* @param ShopProduct $shopProduct
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function disable(Request $request, ShopProduct $shopProduct)
|
||||
public function disable(ShopProduct $shopProduct)
|
||||
{
|
||||
$shopProduct->update(['disabled' => !$shopProduct->disabled]);
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class UserController extends Controller
|
|||
* @param Request $request
|
||||
* @return Application|Factory|View|Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
public function index()
|
||||
{
|
||||
return view('admin.users.index');
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ class UserController extends Controller
|
|||
'referral_code' => "required|string|min:2|max:32|unique:users,referral_code,{$user->id}",
|
||||
]);
|
||||
|
||||
if (isset($this->client->getUser($request->input('pterodactyl_id'))['errors'])) {
|
||||
if (isset($this->pterodactyl->getUser($request->input('pterodactyl_id'))['errors'])) {
|
||||
throw ValidationException::withMessages([
|
||||
'pterodactyl_id' => [__("User does not exists on pterodactyl's panel")],
|
||||
]);
|
||||
|
@ -160,7 +160,7 @@ class UserController extends Controller
|
|||
* @param User $user
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function verifyEmail(Request $request, User $user)
|
||||
public function verifyEmail(User $user)
|
||||
{
|
||||
$user->verifyEmail();
|
||||
|
||||
|
@ -198,7 +198,7 @@ class UserController extends Controller
|
|||
* @param User $user
|
||||
* @return Application|Factory|View|Response
|
||||
*/
|
||||
public function notifications(User $user)
|
||||
public function notifications()
|
||||
{
|
||||
return view('admin.users.notifications');
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Classes\Pterodactyl;
|
||||
use App\Events\UserUpdateCreditsEvent;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\DiscordUser;
|
||||
|
@ -95,7 +94,7 @@ class UserController extends Controller
|
|||
|
||||
//Update Users Password on Pterodactyl
|
||||
//Username,Mail,First and Lastname are required aswell
|
||||
$response = Pterodactyl::client()->patch('/application/users/' . $user->pterodactyl_id, [
|
||||
$response = $this->pterodactyl->client_admin->patch('/application/users/' . $user->pterodactyl_id, [
|
||||
'username' => $request->name,
|
||||
'first_name' => $request->name,
|
||||
'last_name' => $request->name,
|
||||
|
@ -203,7 +202,7 @@ class UserController extends Controller
|
|||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function suspend(Request $request, int $id)
|
||||
public function suspend(int $id)
|
||||
{
|
||||
$discordUser = DiscordUser::find($id);
|
||||
$user = $discordUser ? $discordUser->user : User::findOrFail($id);
|
||||
|
@ -227,7 +226,7 @@ class UserController extends Controller
|
|||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function unsuspend(Request $request, int $id)
|
||||
public function unsuspend(int $id)
|
||||
{
|
||||
$discordUser = DiscordUser::find($id);
|
||||
$user = $discordUser ? $discordUser->user : User::findOrFail($id);
|
||||
|
@ -270,7 +269,7 @@ class UserController extends Controller
|
|||
'referral_code' => $this->createReferralCode(),
|
||||
]);
|
||||
|
||||
$response = Pterodactyl::client()->post('/application/users', [
|
||||
$response = $this->pterodactyl->client_admin->post('/application/users', [
|
||||
'external_id' => App::environment('local') ? Str::random(16) : (string) $user->id,
|
||||
'username' => $user->name,
|
||||
'email' => $user->email,
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Classes\Pterodactyl;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use App\Notifications\ReferralNotification;
|
||||
|
@ -106,7 +105,7 @@ class RegisterController extends Controller
|
|||
|
||||
]);
|
||||
|
||||
$response = Pterodactyl::client()->post('/application/users', [
|
||||
$response = $this->pterodactyl->client_admin->post('/application/users', [
|
||||
'external_id' => App::environment('local') ? Str::random(16) : (string) $user->id,
|
||||
'username' => $user->name,
|
||||
'email' => $user->email,
|
||||
|
|
|
@ -14,12 +14,12 @@ class Controller extends BaseController
|
|||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
|
||||
public $client = null;
|
||||
public $pterodactyl = null;
|
||||
|
||||
public function __construct(PterodactylSettings $ptero_settings)
|
||||
{
|
||||
try {
|
||||
$this->client = new PterodactylClient($ptero_settings);
|
||||
$this->pterodactyl = new PterodactylClient($ptero_settings);
|
||||
}
|
||||
catch (Exception $exception) {
|
||||
|
||||
|
|
|
@ -2,12 +2,10 @@
|
|||
|
||||
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;
|
||||
|
@ -61,7 +59,7 @@ class ProductController extends Controller
|
|||
{
|
||||
$nodes = $this->getNodesBasedOnEgg($request, $egg);
|
||||
foreach ($nodes as $key => $node) {
|
||||
$pteroNode = $this->client->getNode($node->id);
|
||||
$pteroNode = $this->pterodactyl->getNode($node->id);
|
||||
if ($pteroNode['allocated_resources']['memory'] >= ($pteroNode['memory'] * ($pteroNode['memory_overallocate'] + 100) / 100) || $pteroNode['allocated_resources']['disk'] >= ($pteroNode['disk'] * ($pteroNode['disk_overallocate'] + 100) / 100)) {
|
||||
$nodes->forget($key);
|
||||
}
|
||||
|
@ -110,7 +108,7 @@ class ProductController extends Controller
|
|||
})
|
||||
->get();
|
||||
|
||||
$pteroNode = $this->client->getNode($node->id);
|
||||
$pteroNode = $this->pterodactyl->getNode($node->id);
|
||||
foreach ($products as $key => $product) {
|
||||
if ($product->memory > ($pteroNode['memory'] * ($pteroNode['memory_overallocate'] + 100) / 100) - $pteroNode['allocated_resources']['memory'] || $product->disk > ($pteroNode['disk'] * ($pteroNode['disk_overallocate'] + 100) / 100) - $pteroNode['allocated_resources']['disk']) {
|
||||
$product->doesNotFit = true;
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Classes\Pterodactyl;
|
||||
use App\Models\User;
|
||||
use App\Settings\UserSettings;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
@ -13,7 +13,7 @@ use Illuminate\Validation\ValidationException;
|
|||
class ProfileController extends Controller
|
||||
{
|
||||
/** Display a listing of the resource. */
|
||||
public function index()
|
||||
public function index(UserSettings $user_settings)
|
||||
{
|
||||
switch (Auth::user()->role) {
|
||||
case 'admin':
|
||||
|
@ -32,9 +32,9 @@ class ProfileController extends Controller
|
|||
|
||||
return view('profile.index')->with([
|
||||
'user' => Auth::user(),
|
||||
'credits_reward_after_verify_discord' => config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD'),
|
||||
'force_email_verification' => config('SETTINGS::USER:FORCE_EMAIL_VERIFICATION'),
|
||||
'force_discord_verification' => config('SETTINGS::USER:FORCE_DISCORD_VERIFICATION'),
|
||||
'credits_reward_after_verify_discord' => $user_settings->credits_reward_after_verify_discord,
|
||||
'force_email_verification' => $user_settings->force_email_verification,
|
||||
'force_discord_verification' => $user_settings->force_discord_verification,
|
||||
'badgeColor' => $badgeColor,
|
||||
]);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ class ProfileController extends Controller
|
|||
|
||||
//Update Users Password on Pterodactyl
|
||||
//Username,Mail,First and Lastname are required aswell
|
||||
$response = Pterodactyl::client()->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 +125,7 @@ class ProfileController extends Controller
|
|||
}
|
||||
|
||||
//update name and email on Pterodactyl
|
||||
$response = Pterodactyl::client()->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'),
|
||||
|
|
|
@ -30,7 +30,7 @@ class ServerController extends Controller
|
|||
foreach ($servers as $server) {
|
||||
|
||||
//Get server infos from ptero
|
||||
$serverAttributes = $this->client->getServerAttributes($server->pterodactyl_id, true);
|
||||
$serverAttributes = $this->pterodactyl->getServerAttributes($server->pterodactyl_id, true);
|
||||
if (! $serverAttributes) {
|
||||
continue;
|
||||
}
|
||||
|
@ -123,18 +123,15 @@ class ServerController extends Controller
|
|||
$nodeName = $node->name;
|
||||
|
||||
// Check if node has enough memory and disk space
|
||||
$checkResponse = $this->client->checkNodeResources($node, $product->memory, $product->disk);
|
||||
$checkResponse = $this->pterodactyl->checkNodeResources($node, $product->memory, $product->disk);
|
||||
if ($checkResponse == false) {
|
||||
return redirect()->route('servers.index')->with('error', __("The node '".$nodeName."' doesn't have the required memory or disk left to allocate this product."));
|
||||
}
|
||||
|
||||
// Min. Credits
|
||||
if (
|
||||
Auth::user()->credits <
|
||||
($product->minimum_credits == -1
|
||||
? config('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', 50)
|
||||
: $product->minimum_credits)
|
||||
) {
|
||||
if (Auth::user()->credits < ($product->minimum_credits == -1
|
||||
? $user_settings->min_credits_to_make_server
|
||||
: $product->minimum_credits)) {
|
||||
return redirect()->route('servers.index')->with('error', 'You do not have the required amount of '.CREDITS_DISPLAY_NAME.' to use this product!');
|
||||
}
|
||||
}
|
||||
|
@ -158,13 +155,15 @@ class ServerController extends Controller
|
|||
}
|
||||
|
||||
/** Store a newly created resource in storage. */
|
||||
public function store(Request $request)
|
||||
public function store(Request $request, UserSettings $user_settings, ServerSettings $server_settings)
|
||||
{
|
||||
/** @var Node $node */
|
||||
/** @var Egg $egg */
|
||||
/** @var Product $product */
|
||||
if (! is_null($this->validateConfigurationRules())) {
|
||||
return $this->validateConfigurationRules();
|
||||
$validate_configuration = $this->validateConfigurationRules($user_settings, $server_settings);
|
||||
|
||||
if (!is_null($validate_configuration)) {
|
||||
return $validate_configuration;
|
||||
}
|
||||
|
||||
$request->validate([
|
||||
|
@ -185,13 +184,13 @@ class ServerController extends Controller
|
|||
]);
|
||||
|
||||
//get free allocation ID
|
||||
$allocationId = $this->client->getFreeAllocationId($node);
|
||||
$allocationId = $this->pterodactyl->getFreeAllocationId($node);
|
||||
if (! $allocationId) {
|
||||
return $this->noAllocationsError($server);
|
||||
}
|
||||
|
||||
//create server on pterodactyl
|
||||
$response = $this->client->createServer($server, $egg, $allocationId);
|
||||
$response = $this->pterodactyl->createServer($server, $egg, $allocationId);
|
||||
if ($response->failed()) {
|
||||
return $this->serverCreationFailed($response, $server);
|
||||
}
|
||||
|
@ -203,7 +202,7 @@ class ServerController extends Controller
|
|||
'identifier' => $serverAttributes['identifier'],
|
||||
]);
|
||||
|
||||
if (config('SETTINGS::SYSTEM:SERVER_CREATE_CHARGE_FIRST_HOUR', 'true') == 'true') {
|
||||
if ($server_settings->charge_first_hour) {
|
||||
if ($request->user()->credits >= $server->product->getHourlyPrice()) {
|
||||
$request->user()->decrement('credits', $server->product->getHourlyPrice());
|
||||
}
|
||||
|
@ -257,9 +256,9 @@ class ServerController extends Controller
|
|||
public function show(Server $server)
|
||||
{
|
||||
if ($server->user_id != Auth::user()->id) {
|
||||
return back()->with('error', __('´This is not your Server!'));
|
||||
return back()->with('error', __('This is not your Server!'));
|
||||
}
|
||||
$serverAttributes = $this->client->getServerAttributes($server->pterodactyl_id);
|
||||
$serverAttributes = $this->pterodactyl->getServerAttributes($server->pterodactyl_id);
|
||||
$serverRelationships = $serverAttributes['relationships'];
|
||||
$serverLocationAttributes = $serverRelationships['location']['attributes'];
|
||||
|
||||
|
@ -275,7 +274,7 @@ class ServerController extends Controller
|
|||
$server->name = $serverAttributes['name'];
|
||||
$server->egg = $serverRelationships['egg']['attributes']['name'];
|
||||
|
||||
$pteroNode = $this->client->getNode($serverRelationships['node']['attributes']['id']);
|
||||
$pteroNode = $this->pterodactyl->getNode($serverRelationships['node']['attributes']['id']);
|
||||
|
||||
$products = Product::orderBy('created_at')
|
||||
->whereHas('nodes', function (Builder $builder) use ($serverRelationships) { //Only show products for that node
|
||||
|
@ -308,7 +307,7 @@ class ServerController extends Controller
|
|||
$user = Auth::user();
|
||||
$oldProduct = Product::where('id', $server->product->id)->first();
|
||||
$newProduct = Product::where('id', $request->product_upgrade)->first();
|
||||
$serverAttributes = $this->client->getServerAttributes($server->pterodactyl_id);
|
||||
$serverAttributes = $this->pterodactyl->getServerAttributes($server->pterodactyl_id);
|
||||
$serverRelationships = $serverAttributes['relationships'];
|
||||
|
||||
// Get node resource allocation info
|
||||
|
@ -319,7 +318,7 @@ class ServerController extends Controller
|
|||
// Check if node has enough memory and disk space
|
||||
$requireMemory = $newProduct->memory - $oldProduct->memory;
|
||||
$requiredisk = $newProduct->disk - $oldProduct->disk;
|
||||
$checkResponse = $this->client->checkNodeResources($node, $requireMemory, $requiredisk);
|
||||
$checkResponse = $this->pterodactyl->checkNodeResources($node, $requireMemory, $requiredisk);
|
||||
if ($checkResponse == false) {
|
||||
return redirect()->route('servers.index')->with('error', __("The node '".$nodeName."' doesn't have the required memory or disk left to upgrade the server."));
|
||||
}
|
||||
|
@ -333,14 +332,14 @@ class ServerController extends Controller
|
|||
$server->product_id = $request->product_upgrade;
|
||||
$server->update();
|
||||
$server->allocation = $serverAttributes['allocation'];
|
||||
$response = $this->client->updateServer($server, $newProduct);
|
||||
$response = $this->pterodactyl->updateServer($server, $newProduct);
|
||||
if ($response->failed()) {
|
||||
return $this->serverCreationFailed($response, $server);
|
||||
}
|
||||
//update user balance
|
||||
$user->decrement('credits', $priceupgrade);
|
||||
//restart the server
|
||||
$response = $this->client->powerAction($server, 'restart');
|
||||
$response = $this->pterodactyl->powerAction($server, 'restart');
|
||||
if ($response->failed()) {
|
||||
return redirect()->route('servers.index')->with('error', $response->json()['errors'][0]['detail']);
|
||||
}
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\ShopProduct;
|
||||
use App\Settings\UserSettings;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class StoreController extends Controller
|
||||
{
|
||||
/** Display a listing of the resource. */
|
||||
public function index()
|
||||
public function index(UserSettings $user_settings)
|
||||
{
|
||||
$isPaymentSetup = false;
|
||||
|
||||
|
@ -21,12 +22,12 @@ class StoreController extends Controller
|
|||
}
|
||||
|
||||
//Required Verification for creating an server
|
||||
if (config('SETTINGS::USER:FORCE_EMAIL_VERIFICATION', false) === 'true' && ! Auth::user()->hasVerifiedEmail()) {
|
||||
if ($user_settings->force_email_verification && ! 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 (config('SETTINGS::USER:FORCE_DISCORD_VERIFICATION', false) === 'true' && ! Auth::user()->discordUser) {
|
||||
if ($user_settings->force_discord_verification && ! Auth::user()->discordUser) {
|
||||
return redirect()->route('profile.index')->with('error', __('You are required to link your discord account before you can purchase Credits'));
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ class ServerSettings extends Settings
|
|||
|
||||
public bool $enable_upgrade;
|
||||
|
||||
public bool $charge_first_hour;
|
||||
|
||||
public static function group(): string
|
||||
{
|
||||
return 'server';
|
||||
|
|
|
@ -14,6 +14,6 @@ class DatabaseSeeder extends Seeder
|
|||
*/
|
||||
public function run()
|
||||
{
|
||||
Schema::dropIfExists('settings_old');
|
||||
// Schema::dropIfExists('settings_old');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,17 @@ class CreateGeneralSettings extends SettingsMigration
|
|||
public function getOldValue(string $key)
|
||||
{
|
||||
// Always get the first value of the key.
|
||||
return DB::table('settings_old')->where('key', '=', $key)->get(['value'])->first()->value;
|
||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
||||
|
||||
// Handle the old values to return without it being a string in all cases.
|
||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
||||
return $old_value->value;
|
||||
}
|
||||
|
||||
if ($old_value->type === "boolean") {
|
||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
||||
}
|
||||
|
||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
||||
}
|
||||
}
|
|
@ -19,6 +19,17 @@ class CreatePterodactylSettings extends SettingsMigration
|
|||
public function getOldValue(string $key)
|
||||
{
|
||||
// Always get the first value of the key.
|
||||
return DB::table('settings_old')->where('key', '=', $key)->get(['value'])->first()->value;
|
||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
||||
|
||||
// Handle the old values to return without it being a string in all cases.
|
||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
||||
return $old_value->value;
|
||||
}
|
||||
|
||||
if ($old_value->type === "boolean") {
|
||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
||||
}
|
||||
|
||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ class CreateMailSettings extends SettingsMigration
|
|||
|
||||
// Get the user-set configuration values from the old table.
|
||||
$this->migrator->add('mail.mail_host', $table_exists ? $this->getOldValue('SETTINGS::MAIL:HOST') : env('MAIL_HOST', 'localhost'));
|
||||
$this->migrator->add('mail.mail_port', $table_exists ? $this->getOldValue('SETTINGS::MAIL:PORT') : env('MAIL_PORT', '25'));
|
||||
$this->migrator->add('mail.mail_port', $table_exists ? $this->getOldValue('SETTINGS::MAIL:PORT') : env('MAIL_PORT', 25));
|
||||
$this->migrator->add('mail.mail_username', $table_exists ? $this->getOldValue('SETTINGS::MAIL:USERNAME') : env('MAIL_USERNAME', ''));
|
||||
$this->migrator->addEncrypted('mail.mail_password', $table_exists ? $this->getOldValue('SETTINGS::MAIL:PASSWORD') : env('MAIL_PASSWORD', ''));
|
||||
$this->migrator->add('mail.mail_encryption', $table_exists ? $this->getOldValue('SETTINGS::MAIL:ENCRYPTION') : env('MAIL_ENCRYPTION', 'tls'));
|
||||
|
@ -24,6 +24,17 @@ class CreateMailSettings extends SettingsMigration
|
|||
public function getOldValue(string $key)
|
||||
{
|
||||
// Always get the first value of the key.
|
||||
return DB::table('settings_old')->where('key', '=', $key)->get(['value'])->first()->value;
|
||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
||||
|
||||
// Handle the old values to return without it being a string in all cases.
|
||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
||||
return $old_value->value;
|
||||
}
|
||||
|
||||
if ($old_value->type === "boolean") {
|
||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
||||
}
|
||||
|
||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
||||
}
|
||||
}
|
|
@ -27,6 +27,17 @@ class CreateUserSettings extends SettingsMigration
|
|||
public function getOldValue(string $key)
|
||||
{
|
||||
// Always get the first value of the key.
|
||||
return DB::table('settings_old')->where('key', '=', $key)->get(['value'])->first()->value;
|
||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
||||
|
||||
// Handle the old values to return without it being a string in all cases.
|
||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
||||
return $old_value->value;
|
||||
}
|
||||
|
||||
if ($old_value->type === "boolean") {
|
||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
||||
}
|
||||
|
||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
||||
}
|
||||
}
|
|
@ -13,11 +13,23 @@ class CreateServerSettings extends SettingsMigration
|
|||
$this->migrator->add('server.allocation_limit', $table_exists ? $this->getOldValue('SETTINGS::SERVER:ALLOCATION_LIMIT'): 200);
|
||||
$this->migrator->add('server.creation_enabled', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS'): true);
|
||||
$this->migrator->add('server.enable_upgrade', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:ENABLE_UPGRADE'): false);
|
||||
$this->migrator->add('server.charge_first_hour', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:SERVER_CREATE_CHARGE_FIRST_HOUR'): false);
|
||||
}
|
||||
|
||||
public function getOldValue(string $key)
|
||||
{
|
||||
// Always get the first value of the key.
|
||||
return DB::table('settings_old')->where('key', '=', $key)->get(['value'])->first()->value;
|
||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
||||
|
||||
// Handle the old values to return without it being a string in all cases.
|
||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
||||
return $old_value->value;
|
||||
}
|
||||
|
||||
if ($old_value->type === "boolean") {
|
||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
||||
}
|
||||
|
||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
||||
}
|
||||
}
|
|
@ -10,12 +10,12 @@ class CreateInvoiceSettings extends SettingsMigration
|
|||
$table_exists = DB::table('settings_old')->exists();
|
||||
|
||||
// Get the user-set configuration values from the old table.
|
||||
$this->migrator->add('invoice.company_address', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_ADDRESS'): null);
|
||||
$this->migrator->add('invoice.company_mail', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_MAIL'): null);
|
||||
$this->migrator->add('invoice.company_name', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_NAME'): null);
|
||||
$this->migrator->add('invoice.company_phone', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_PHONE'): null);
|
||||
$this->migrator->add('invoice.company_vat', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_VAT'): null);
|
||||
$this->migrator->add('invoice.company_website', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_WEBSITE'): null);
|
||||
$this->migrator->add('invoice.company_address', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_ADDRESS'): '');
|
||||
$this->migrator->add('invoice.company_mail', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_MAIL'): '');
|
||||
$this->migrator->add('invoice.company_name', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_NAME'): '');
|
||||
$this->migrator->add('invoice.company_phone', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_PHONE'): '');
|
||||
$this->migrator->add('invoice.company_vat', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_VAT'): '');
|
||||
$this->migrator->add('invoice.company_website', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_WEBSITE'): '');
|
||||
$this->migrator->add('invoice.enabled', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:ENABLED'): true);
|
||||
$this->migrator->add('invoice.prefix', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:PREFIX'): 'INV');
|
||||
}
|
||||
|
@ -23,6 +23,17 @@ class CreateInvoiceSettings extends SettingsMigration
|
|||
public function getOldValue(string $key)
|
||||
{
|
||||
// Always get the first value of the key.
|
||||
return DB::table('settings_old')->where('key', '=', $key)->get(['value'])->first()->value;
|
||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
||||
|
||||
// Handle the old values to return without it being a string in all cases.
|
||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
||||
return $old_value->value;
|
||||
}
|
||||
|
||||
if ($old_value->type === "boolean") {
|
||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
||||
}
|
||||
|
||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
||||
}
|
||||
}
|
|
@ -10,17 +10,28 @@ class CreateDiscordSettings extends SettingsMigration
|
|||
$table_exists = DB::table('settings_old')->exists();
|
||||
|
||||
// Get the user-set configuration values from the old table.
|
||||
$this->migrator->addEncrypted('discord.bot_token', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:BOT_TOKEN'): null);
|
||||
$this->migrator->addEncrypted('discord.client_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:CLIENT_ID'): null);
|
||||
$this->migrator->addEncrypted('discord.client_secret', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:CLIENT_SECRET'): null);
|
||||
$this->migrator->addEncrypted('discord.bot_token', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:BOT_TOKEN'): '');
|
||||
$this->migrator->addEncrypted('discord.client_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:CLIENT_ID'): '');
|
||||
$this->migrator->addEncrypted('discord.client_secret', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:CLIENT_SECRET'): '');
|
||||
$this->migrator->add('discord.guild_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:GUILD_ID'): null);
|
||||
$this->migrator->add('discord.invite_url', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:INVITE_URL'): null);
|
||||
$this->migrator->add('discord.invite_url', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:INVITE_URL'): '');
|
||||
$this->migrator->add('discord.role_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:ROLE_ID'): null);
|
||||
}
|
||||
|
||||
public function getOldValue(string $key)
|
||||
{
|
||||
// Always get the first value of the key.
|
||||
return DB::table('settings_old')->where('key', '=', $key)->get(['value'])->first()->value;
|
||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
||||
|
||||
// Handle the old values to return without it being a string in all cases.
|
||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
||||
return $old_value->value;
|
||||
}
|
||||
|
||||
if ($old_value->type === "boolean") {
|
||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
||||
}
|
||||
|
||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
||||
}
|
||||
}
|
|
@ -20,6 +20,17 @@ class CreateLocaleSettings extends SettingsMigration
|
|||
public function getOldValue(string $key)
|
||||
{
|
||||
// Always get the first value of the key.
|
||||
return DB::table('settings_old')->where('key', '=', $key)->get(['value'])->first()->value;
|
||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
||||
|
||||
// Handle the old values to return without it being a string in all cases.
|
||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
||||
return $old_value->value;
|
||||
}
|
||||
|
||||
if ($old_value->type === "boolean") {
|
||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
||||
}
|
||||
|
||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
||||
}
|
||||
}
|
|
@ -21,6 +21,17 @@ class CreateReferralSettings extends SettingsMigration
|
|||
public function getOldValue(string $key)
|
||||
{
|
||||
// Always get the first value of the key.
|
||||
return DB::table('settings_old')->where('key', '=', $key)->get(['value'])->first()->value;
|
||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
||||
|
||||
// Handle the old values to return without it being a string in all cases.
|
||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
||||
return $old_value->value;
|
||||
}
|
||||
|
||||
if ($old_value->type === "boolean") {
|
||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
||||
}
|
||||
|
||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
||||
}
|
||||
}
|
|
@ -29,6 +29,17 @@ class CreateWebsiteSettings extends SettingsMigration
|
|||
public function getOldValue(string $key)
|
||||
{
|
||||
// Always get the first value of the key.
|
||||
return DB::table('settings_old')->where('key', '=', $key)->get(['value'])->first()->value;
|
||||
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
||||
|
||||
// Handle the old values to return without it being a string in all cases.
|
||||
if ($old_value->type === "string" || $old_value->type === "text") {
|
||||
return $old_value->value;
|
||||
}
|
||||
|
||||
if ($old_value->type === "boolean") {
|
||||
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
||||
}
|
||||
|
||||
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue