mirror of
https://github.com/pterodactyl/panel.git
synced 2026-02-04 01:19:30 -06:00
Update PHP and JS dependencies to latest versions and modernize codebase (#5446)
This commit is contained in:
parent
9b703fb40f
commit
a264791fd4
@ -47,5 +47,6 @@ module.exports = {
|
|||||||
'@typescript-eslint/no-use-before-define': 'warn',
|
'@typescript-eslint/no-use-before-define': 'warn',
|
||||||
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
|
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
|
||||||
'@typescript-eslint/ban-ts-comment': ['error', { 'ts-expect-error': 'allow-with-description' }],
|
'@typescript-eslint/ban-ts-comment': ['error', { 'ts-expect-error': 'allow-with-description' }],
|
||||||
|
'react/no-unknown-property': ['error', { ignore: ['css'] }],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
8
.github/workflows/build.yaml
vendored
8
.github/workflows/build.yaml
vendored
@ -19,7 +19,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [16]
|
node-version: [22]
|
||||||
steps:
|
steps:
|
||||||
- name: Code Checkout
|
- name: Code Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@ -32,6 +32,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install --frozen-lockfile
|
run: yarn install --frozen-lockfile
|
||||||
|
- run: yarn tsc
|
||||||
- name: Build
|
- run: yarn lint
|
||||||
run: yarn build:production
|
- run: yarn build:production
|
||||||
|
|||||||
4
.github/workflows/release.yaml
vendored
4
.github/workflows/release.yaml
vendored
@ -18,12 +18,14 @@ jobs:
|
|||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 16
|
node-version: 22
|
||||||
cache: yarn
|
cache: yarn
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install --frozen-lockfile
|
run: yarn install --frozen-lockfile
|
||||||
|
|
||||||
|
- run: yarn tsc
|
||||||
|
- run: yarn lint
|
||||||
- name: Build
|
- name: Build
|
||||||
run: yarn build:production
|
run: yarn build:production
|
||||||
|
|
||||||
|
|||||||
@ -5,19 +5,22 @@ use PhpCsFixer\Finder;
|
|||||||
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
|
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
|
||||||
|
|
||||||
$finder = (new Finder())
|
$finder = (new Finder())
|
||||||
->in(__DIR__)
|
->name('*.php')
|
||||||
->exclude([
|
->ignoreVCSIgnored(true)
|
||||||
'vendor',
|
->exclude([__DIR__ . '/bootstrap/cache'])
|
||||||
'node_modules',
|
->in([
|
||||||
'storage',
|
__DIR__ . '/app',
|
||||||
'bootstrap/cache',
|
__DIR__ . '/bootstrap',
|
||||||
])
|
__DIR__ . '/config',
|
||||||
->notName(['_ide_helper*']);
|
__DIR__ . '/database',
|
||||||
|
__DIR__ . '/routes',
|
||||||
|
__DIR__ . '/tests',
|
||||||
|
]);
|
||||||
|
|
||||||
return (new Config())
|
return (new Config())
|
||||||
->setParallelConfig(ParallelConfigFactory::detect())
|
|
||||||
->setRiskyAllowed(true)
|
|
||||||
->setFinder($finder)
|
->setFinder($finder)
|
||||||
|
->setUsingCache(true)
|
||||||
|
->setParallelConfig(ParallelConfigFactory::detect())
|
||||||
->setRules([
|
->setRules([
|
||||||
'@Symfony' => true,
|
'@Symfony' => true,
|
||||||
'@PSR1' => true,
|
'@PSR1' => true,
|
||||||
@ -27,8 +30,8 @@ return (new Config())
|
|||||||
'combine_consecutive_unsets' => true,
|
'combine_consecutive_unsets' => true,
|
||||||
'concat_space' => ['spacing' => 'one'],
|
'concat_space' => ['spacing' => 'one'],
|
||||||
'heredoc_to_nowdoc' => true,
|
'heredoc_to_nowdoc' => true,
|
||||||
'no_alias_functions' => true,
|
// 'no_alias_functions' => true,
|
||||||
'no_unreachable_default_argument_value' => true,
|
// 'no_unreachable_default_argument_value' => true,
|
||||||
'no_useless_return' => true,
|
'no_useless_return' => true,
|
||||||
'ordered_imports' => [
|
'ordered_imports' => [
|
||||||
'sort_algorithm' => 'length',
|
'sort_algorithm' => 'length',
|
||||||
@ -44,7 +47,7 @@ return (new Config())
|
|||||||
'var',
|
'var',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'random_api_migration' => true,
|
// 'random_api_migration' => true,
|
||||||
'ternary_to_null_coalescing' => true,
|
'ternary_to_null_coalescing' => true,
|
||||||
'yoda_style' => [
|
'yoda_style' => [
|
||||||
'equal' => false,
|
'equal' => false,
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
# Build the assets that are needed for the frontend. This build stage is then discarded
|
# Build the assets that are needed for the frontend. This build stage is then discarded
|
||||||
# since we won't need NodeJS anymore in the future. This Docker image ships a final production
|
# since we won't need NodeJS anymore in the future. This Docker image ships a final production
|
||||||
# level distribution of Pterodactyl.
|
# level distribution of Pterodactyl.
|
||||||
FROM --platform=$TARGETOS/$TARGETARCH mhart/alpine-node:14
|
FROM --platform=$TARGETOS/$TARGETARCH node:22-alpine
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . ./
|
COPY . ./
|
||||||
RUN yarn install --frozen-lockfile \
|
RUN yarn install --frozen-lockfile \
|
||||||
|
|||||||
@ -21,6 +21,6 @@ class UpCommand extends BaseUpCommand
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::handle() ?? 0;
|
return parent::handle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace Pterodactyl\Console\Commands\Schedule;
|
namespace Pterodactyl\Console\Commands\Schedule;
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Pterodactyl\Models\Schedule;
|
use Pterodactyl\Models\Schedule;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
@ -67,7 +66,7 @@ class ProcessRunnableCommand extends Command
|
|||||||
'schedule' => $schedule->name,
|
'schedule' => $schedule->name,
|
||||||
'hash' => $schedule->hashid,
|
'hash' => $schedule->hashid,
|
||||||
]));
|
]));
|
||||||
} catch (\Throwable|\Exception $exception) {
|
} catch (\Throwable $exception) {
|
||||||
Log::error($exception, ['schedule_id' => $schedule->id]);
|
Log::error($exception, ['schedule_id' => $schedule->id]);
|
||||||
|
|
||||||
$this->error("An error was encountered while processing Schedule #$schedule->id: " . $exception->getMessage());
|
$this->error("An error was encountered while processing Schedule #$schedule->id: " . $exception->getMessage());
|
||||||
|
|||||||
@ -97,7 +97,7 @@ class BulkPowerActionCommand extends Command
|
|||||||
$instance->whereIn('id', $servers)->orWhereIn('node_id', $nodes);
|
$instance->whereIn('id', $servers)->orWhereIn('node_id', $nodes);
|
||||||
} elseif (empty($nodes) && !empty($servers)) {
|
} elseif (empty($nodes) && !empty($servers)) {
|
||||||
$instance->whereIn('id', $servers);
|
$instance->whereIn('id', $servers);
|
||||||
} elseif (!empty($nodes) && empty($servers)) {
|
} elseif (!empty($nodes) && empty($servers)) { // @phpstan-ignore empty.variable
|
||||||
$instance->whereIn('node_id', $nodes);
|
$instance->whereIn('node_id', $nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -39,8 +39,8 @@ class UpgradeCommand extends Command
|
|||||||
$this->line($this->getUrl());
|
$this->line($this->getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version_compare(PHP_VERSION, '7.4.0') < 0) {
|
if (version_compare(PHP_VERSION, '8.2.0', '<')) {
|
||||||
$this->error('Cannot execute self-upgrade process. The minimum required PHP version required is 7.4.0, you have [' . PHP_VERSION . '].');
|
$this->error('Cannot execute self-upgrade process. The minimum required PHP version required is 8.2.0, you have [' . PHP_VERSION . '].');
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = 'www-data';
|
$user = 'www-data';
|
||||||
|
|||||||
@ -235,7 +235,7 @@ class Handler extends ExceptionHandler
|
|||||||
*/
|
*/
|
||||||
public static function isReportable(\Exception $exception): bool
|
public static function isReportable(\Exception $exception): bool
|
||||||
{
|
{
|
||||||
return (new static(Container::getInstance()))->shouldReport($exception);
|
return (new self(Container::getInstance()))->shouldReport($exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -262,7 +262,7 @@ class Handler extends ExceptionHandler
|
|||||||
{
|
{
|
||||||
$previous = [];
|
$previous = [];
|
||||||
while ($value = $e->getPrevious()) {
|
while ($value = $e->getPrevious()) {
|
||||||
if (!$value instanceof \Throwable) {
|
if (!$value instanceof \Throwable) { // @phpstan-ignore instanceof.alwaysTrue
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$previous[] = $value;
|
$previous[] = $value;
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Pterodactyl\Extensions;
|
namespace Pterodactyl\Extensions;
|
||||||
|
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use Hashids\Hashids as VendorHashids;
|
use Hashids\Hashids as VendorHashids;
|
||||||
use Pterodactyl\Contracts\Extensions\HashidsInterface;
|
use Pterodactyl\Contracts\Extensions\HashidsInterface;
|
||||||
|
|
||||||
@ -10,10 +11,7 @@ class Hashids extends VendorHashids implements HashidsInterface
|
|||||||
public function decodeFirst(string $encoded, ?string $default = null): mixed
|
public function decodeFirst(string $encoded, ?string $default = null): mixed
|
||||||
{
|
{
|
||||||
$result = $this->decode($encoded);
|
$result = $this->decode($encoded);
|
||||||
if (!is_array($result)) {
|
|
||||||
return $default;
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_first($result, null, $default);
|
return Arr::first($result, null, $default);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,9 @@ namespace Pterodactyl\Facades;
|
|||||||
use Illuminate\Support\Facades\Facade;
|
use Illuminate\Support\Facades\Facade;
|
||||||
use Pterodactyl\Services\Activity\ActivityLogTargetableService;
|
use Pterodactyl\Services\Activity\ActivityLogTargetableService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mixin \Pterodactyl\Services\Activity\ActivityLogTargetableService
|
||||||
|
*/
|
||||||
class LogTarget extends Facade
|
class LogTarget extends Facade
|
||||||
{
|
{
|
||||||
protected static function getFacadeAccessor(): string
|
protected static function getFacadeAccessor(): string
|
||||||
|
|||||||
@ -9,7 +9,6 @@ use Pterodactyl\Models\ApiKey;
|
|||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Prologue\Alerts\AlertsMessageBag;
|
use Prologue\Alerts\AlertsMessageBag;
|
||||||
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
||||||
use Illuminate\View\Factory as ViewFactory;
|
|
||||||
use Pterodactyl\Http\Controllers\Controller;
|
use Pterodactyl\Http\Controllers\Controller;
|
||||||
use Pterodactyl\Services\Api\KeyCreationService;
|
use Pterodactyl\Services\Api\KeyCreationService;
|
||||||
use Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface;
|
use Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface;
|
||||||
@ -24,7 +23,6 @@ class ApiController extends Controller
|
|||||||
private AlertsMessageBag $alert,
|
private AlertsMessageBag $alert,
|
||||||
private ApiKeyRepositoryInterface $repository,
|
private ApiKeyRepositoryInterface $repository,
|
||||||
private KeyCreationService $keyCreationService,
|
private KeyCreationService $keyCreationService,
|
||||||
private ViewFactory $view,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +31,7 @@ class ApiController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(Request $request): View
|
public function index(Request $request): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.api.index', [
|
return view('admin.api.index', [
|
||||||
'keys' => $this->repository->getApplicationKeys($request->user()),
|
'keys' => $this->repository->getApplicationKeys($request->user()),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -48,7 +46,7 @@ class ApiController extends Controller
|
|||||||
$resources = AdminAcl::getResourceList();
|
$resources = AdminAcl::getResourceList();
|
||||||
sort($resources);
|
sort($resources);
|
||||||
|
|
||||||
return $this->view->make('admin.api.new', [
|
return view('admin.api.new', [
|
||||||
'resources' => $resources,
|
'resources' => $resources,
|
||||||
'permissions' => [
|
'permissions' => [
|
||||||
'r' => AdminAcl::READ,
|
'r' => AdminAcl::READ,
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
namespace Pterodactyl\Http\Controllers\Admin;
|
namespace Pterodactyl\Http\Controllers\Admin;
|
||||||
|
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
use Illuminate\View\Factory as ViewFactory;
|
|
||||||
use Pterodactyl\Http\Controllers\Controller;
|
use Pterodactyl\Http\Controllers\Controller;
|
||||||
use Pterodactyl\Services\Helpers\SoftwareVersionService;
|
use Pterodactyl\Services\Helpers\SoftwareVersionService;
|
||||||
|
|
||||||
@ -12,7 +11,7 @@ class BaseController extends Controller
|
|||||||
/**
|
/**
|
||||||
* BaseController constructor.
|
* BaseController constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct(private SoftwareVersionService $version, private ViewFactory $view)
|
public function __construct(private SoftwareVersionService $version)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,6 +20,6 @@ class BaseController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(): View
|
public function index(): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.index', ['version' => $this->version]);
|
return view('admin.index', ['version' => $this->version]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,12 +2,10 @@
|
|||||||
|
|
||||||
namespace Pterodactyl\Http\Controllers\Admin;
|
namespace Pterodactyl\Http\Controllers\Admin;
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
use Pterodactyl\Models\DatabaseHost;
|
use Pterodactyl\Models\DatabaseHost;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Prologue\Alerts\AlertsMessageBag;
|
use Prologue\Alerts\AlertsMessageBag;
|
||||||
use Illuminate\View\Factory as ViewFactory;
|
|
||||||
use Pterodactyl\Http\Controllers\Controller;
|
use Pterodactyl\Http\Controllers\Controller;
|
||||||
use Pterodactyl\Services\Databases\Hosts\HostUpdateService;
|
use Pterodactyl\Services\Databases\Hosts\HostUpdateService;
|
||||||
use Pterodactyl\Http\Requests\Admin\DatabaseHostFormRequest;
|
use Pterodactyl\Http\Requests\Admin\DatabaseHostFormRequest;
|
||||||
@ -30,7 +28,6 @@ class DatabaseController extends Controller
|
|||||||
private HostDeletionService $deletionService,
|
private HostDeletionService $deletionService,
|
||||||
private HostUpdateService $updateService,
|
private HostUpdateService $updateService,
|
||||||
private LocationRepositoryInterface $locationRepository,
|
private LocationRepositoryInterface $locationRepository,
|
||||||
private ViewFactory $view,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +36,7 @@ class DatabaseController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(): View
|
public function index(): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.databases.index', [
|
return view('admin.databases.index', [
|
||||||
'locations' => $this->locationRepository->getAllWithNodes(),
|
'locations' => $this->locationRepository->getAllWithNodes(),
|
||||||
'hosts' => $this->repository->getWithViewDetails(),
|
'hosts' => $this->repository->getWithViewDetails(),
|
||||||
]);
|
]);
|
||||||
@ -52,7 +49,7 @@ class DatabaseController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function view(int $host): View
|
public function view(int $host): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.databases.view', [
|
return view('admin.databases.view', [
|
||||||
'locations' => $this->locationRepository->getAllWithNodes(),
|
'locations' => $this->locationRepository->getAllWithNodes(),
|
||||||
'host' => $this->repository->find($host),
|
'host' => $this->repository->find($host),
|
||||||
'databases' => $this->databaseRepository->getDatabasesForHost($host),
|
'databases' => $this->databaseRepository->getDatabasesForHost($host),
|
||||||
|
|||||||
@ -35,7 +35,7 @@ class LocationController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(): View
|
public function index(): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.locations.index', [
|
return view('admin.locations.index', [
|
||||||
'locations' => $this->repository->getAllWithDetails(),
|
'locations' => $this->repository->getAllWithDetails(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ class LocationController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function view(int $id): View
|
public function view(int $id): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.locations.view', [
|
return view('admin.locations.view', [
|
||||||
'location' => $this->repository->getWithNodes($id),
|
'location' => $this->repository->getWithNodes($id),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@ class MountController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(): View
|
public function index(): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.mounts.index', [
|
return view('admin.mounts.index', [
|
||||||
'mounts' => $this->repository->getAllWithDetails(),
|
'mounts' => $this->repository->getAllWithDetails(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ class MountController extends Controller
|
|||||||
$nests = Nest::query()->with('eggs')->get();
|
$nests = Nest::query()->with('eggs')->get();
|
||||||
$locations = Location::query()->with('nodes')->get();
|
$locations = Location::query()->with('nodes')->get();
|
||||||
|
|
||||||
return $this->view->make('admin.mounts.view', [
|
return view('admin.mounts.view', [
|
||||||
'mount' => $this->repository->getWithRelations($id),
|
'mount' => $this->repository->getWithRelations($id),
|
||||||
'nests' => $nests,
|
'nests' => $nests,
|
||||||
'locations' => $locations,
|
'locations' => $locations,
|
||||||
|
|||||||
@ -41,7 +41,7 @@ class EggController extends Controller
|
|||||||
$nests = $this->nestRepository->getWithEggs();
|
$nests = $this->nestRepository->getWithEggs();
|
||||||
\JavaScript::put(['nests' => $nests->keyBy('id')]);
|
\JavaScript::put(['nests' => $nests->keyBy('id')]);
|
||||||
|
|
||||||
return $this->view->make('admin.eggs.new', ['nests' => $nests]);
|
return view('admin.eggs.new', ['nests' => $nests]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,7 +66,7 @@ class EggController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function view(Egg $egg): View
|
public function view(Egg $egg): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.eggs.view', [
|
return view('admin.eggs.view', [
|
||||||
'egg' => $egg,
|
'egg' => $egg,
|
||||||
'images' => array_map(
|
'images' => array_map(
|
||||||
fn ($key, $value) => $key === $value ? $value : "$key|$value",
|
fn ($key, $value) => $key === $value ? $value : "$key|$value",
|
||||||
|
|||||||
@ -41,7 +41,7 @@ class EggScriptController extends Controller
|
|||||||
['copy_script_from', '=', $egg->id],
|
['copy_script_from', '=', $egg->id],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->view->make('admin.eggs.scripts', [
|
return view('admin.eggs.scripts', [
|
||||||
'copyFromOptions' => $copy,
|
'copyFromOptions' => $copy,
|
||||||
'relyOnScript' => $rely,
|
'relyOnScript' => $rely,
|
||||||
'egg' => $egg,
|
'egg' => $egg,
|
||||||
|
|||||||
@ -39,7 +39,7 @@ class EggVariableController extends Controller
|
|||||||
{
|
{
|
||||||
$egg = $this->repository->getWithVariables($egg);
|
$egg = $this->repository->getWithVariables($egg);
|
||||||
|
|
||||||
return $this->view->make('admin.eggs.variables', ['egg' => $egg]);
|
return view('admin.eggs.variables', ['egg' => $egg]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -35,7 +35,7 @@ class NestController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(): View
|
public function index(): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.nests.index', [
|
return view('admin.nests.index', [
|
||||||
'nests' => $this->repository->getWithCounts(),
|
'nests' => $this->repository->getWithCounts(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ class NestController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function create(): View
|
public function create(): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.nests.new');
|
return view('admin.nests.new');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,7 +68,7 @@ class NestController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function view(int $nest): View
|
public function view(int $nest): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.nests.view', [
|
return view('admin.nests.view', [
|
||||||
'nest' => $this->repository->getWithEggServers($nest),
|
'nest' => $this->repository->getWithEggServers($nest),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,17 +7,9 @@ use Illuminate\Http\Request;
|
|||||||
use Pterodactyl\Models\Node;
|
use Pterodactyl\Models\Node;
|
||||||
use Spatie\QueryBuilder\QueryBuilder;
|
use Spatie\QueryBuilder\QueryBuilder;
|
||||||
use Pterodactyl\Http\Controllers\Controller;
|
use Pterodactyl\Http\Controllers\Controller;
|
||||||
use Illuminate\Contracts\View\Factory as ViewFactory;
|
|
||||||
|
|
||||||
class NodeController extends Controller
|
class NodeController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* NodeController constructor.
|
|
||||||
*/
|
|
||||||
public function __construct(private ViewFactory $view)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a listing of nodes on the system.
|
* Returns a listing of nodes on the system.
|
||||||
*/
|
*/
|
||||||
@ -30,6 +22,6 @@ class NodeController extends Controller
|
|||||||
->allowedSorts(['id'])
|
->allowedSorts(['id'])
|
||||||
->paginate(25);
|
->paginate(25);
|
||||||
|
|
||||||
return $this->view->make('admin.nodes.index', ['nodes' => $nodes]);
|
return view('admin.nodes.index', ['nodes' => $nodes]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,13 +8,11 @@ use Pterodactyl\Models\Node;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Pterodactyl\Models\Allocation;
|
use Pterodactyl\Models\Allocation;
|
||||||
use Pterodactyl\Http\Controllers\Controller;
|
use Pterodactyl\Http\Controllers\Controller;
|
||||||
use Illuminate\Contracts\View\Factory as ViewFactory;
|
|
||||||
use Pterodactyl\Repositories\Eloquent\NodeRepository;
|
use Pterodactyl\Repositories\Eloquent\NodeRepository;
|
||||||
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
||||||
use Pterodactyl\Traits\Controllers\JavascriptInjection;
|
use Pterodactyl\Traits\Controllers\JavascriptInjection;
|
||||||
use Pterodactyl\Services\Helpers\SoftwareVersionService;
|
use Pterodactyl\Services\Helpers\SoftwareVersionService;
|
||||||
use Pterodactyl\Repositories\Eloquent\LocationRepository;
|
use Pterodactyl\Repositories\Eloquent\LocationRepository;
|
||||||
use Pterodactyl\Repositories\Eloquent\AllocationRepository;
|
|
||||||
|
|
||||||
class NodeViewController extends Controller
|
class NodeViewController extends Controller
|
||||||
{
|
{
|
||||||
@ -24,12 +22,10 @@ class NodeViewController extends Controller
|
|||||||
* NodeViewController constructor.
|
* NodeViewController constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private AllocationRepository $allocationRepository,
|
|
||||||
private LocationRepository $locationRepository,
|
private LocationRepository $locationRepository,
|
||||||
private NodeRepository $repository,
|
private NodeRepository $repository,
|
||||||
private ServerRepository $serverRepository,
|
private ServerRepository $serverRepository,
|
||||||
private SoftwareVersionService $versionService,
|
private SoftwareVersionService $versionService,
|
||||||
private ViewFactory $view,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +36,7 @@ class NodeViewController extends Controller
|
|||||||
{
|
{
|
||||||
$node = $this->repository->loadLocationAndServerCount($node);
|
$node = $this->repository->loadLocationAndServerCount($node);
|
||||||
|
|
||||||
return $this->view->make('admin.nodes.view.index', [
|
return view('admin.nodes.view.index', [
|
||||||
'node' => $node,
|
'node' => $node,
|
||||||
'stats' => $this->repository->getUsageStats($node),
|
'stats' => $this->repository->getUsageStats($node),
|
||||||
'version' => $this->versionService,
|
'version' => $this->versionService,
|
||||||
@ -52,7 +48,7 @@ class NodeViewController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function settings(Request $request, Node $node): View
|
public function settings(Request $request, Node $node): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.nodes.view.settings', [
|
return view('admin.nodes.view.settings', [
|
||||||
'node' => $node,
|
'node' => $node,
|
||||||
'locations' => $this->locationRepository->all(),
|
'locations' => $this->locationRepository->all(),
|
||||||
]);
|
]);
|
||||||
@ -63,7 +59,7 @@ class NodeViewController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function configuration(Request $request, Node $node): View
|
public function configuration(Request $request, Node $node): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.nodes.view.configuration', compact('node'));
|
return view('admin.nodes.view.configuration', compact('node'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,9 +69,9 @@ class NodeViewController extends Controller
|
|||||||
{
|
{
|
||||||
$node = $this->repository->loadNodeAllocations($node);
|
$node = $this->repository->loadNodeAllocations($node);
|
||||||
|
|
||||||
$this->plainInject(['node' => Collection::wrap($node)->only(['id'])]);
|
$this->plainInject(['node' => Collection::make([$node])->only(['id'])]);
|
||||||
|
|
||||||
return $this->view->make('admin.nodes.view.allocation', [
|
return view('admin.nodes.view.allocation', [
|
||||||
'node' => $node,
|
'node' => $node,
|
||||||
'allocations' => Allocation::query()->where('node_id', $node->id)
|
'allocations' => Allocation::query()->where('node_id', $node->id)
|
||||||
->groupBy('ip')
|
->groupBy('ip')
|
||||||
@ -90,11 +86,11 @@ class NodeViewController extends Controller
|
|||||||
public function servers(Request $request, Node $node): View
|
public function servers(Request $request, Node $node): View
|
||||||
{
|
{
|
||||||
$this->plainInject([
|
$this->plainInject([
|
||||||
'node' => Collection::wrap($node->makeVisible(['daemon_token_id', 'daemon_token']))
|
'node' => Collection::make([$node->makeVisible(['daemon_token_id', 'daemon_token'])])
|
||||||
->only(['scheme', 'fqdn', 'daemonListen', 'daemon_token_id', 'daemon_token']),
|
->only(['scheme', 'fqdn', 'daemonListen', 'daemon_token_id', 'daemon_token']),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->view->make('admin.nodes.view.servers', [
|
return view('admin.nodes.view.servers', [
|
||||||
'node' => $node,
|
'node' => $node,
|
||||||
'servers' => $this->serverRepository->loadAllServersForNode($node->id, 25),
|
'servers' => $this->serverRepository->loadAllServersForNode($node->id, 25),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -60,7 +60,7 @@ class NodesController extends Controller
|
|||||||
return redirect()->route('admin.locations');
|
return redirect()->route('admin.locations');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->view->make('admin.nodes.new', ['locations' => $locations]);
|
return view('admin.nodes.new', ['locations' => $locations]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -3,11 +3,11 @@
|
|||||||
namespace Pterodactyl\Http\Controllers\Admin\Servers;
|
namespace Pterodactyl\Http\Controllers\Admin\Servers;
|
||||||
|
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
use Pterodactyl\Models\Nest;
|
||||||
use Pterodactyl\Models\Node;
|
use Pterodactyl\Models\Node;
|
||||||
use Pterodactyl\Models\Location;
|
use Pterodactyl\Models\Location;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Prologue\Alerts\AlertsMessageBag;
|
use Prologue\Alerts\AlertsMessageBag;
|
||||||
use Illuminate\View\Factory as ViewFactory;
|
|
||||||
use Pterodactyl\Http\Controllers\Controller;
|
use Pterodactyl\Http\Controllers\Controller;
|
||||||
use Pterodactyl\Repositories\Eloquent\NestRepository;
|
use Pterodactyl\Repositories\Eloquent\NestRepository;
|
||||||
use Pterodactyl\Repositories\Eloquent\NodeRepository;
|
use Pterodactyl\Repositories\Eloquent\NodeRepository;
|
||||||
@ -24,7 +24,6 @@ class CreateServerController extends Controller
|
|||||||
private NestRepository $nestRepository,
|
private NestRepository $nestRepository,
|
||||||
private NodeRepository $nodeRepository,
|
private NodeRepository $nodeRepository,
|
||||||
private ServerCreationService $creationService,
|
private ServerCreationService $creationService,
|
||||||
private ViewFactory $view,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,14 +45,14 @@ class CreateServerController extends Controller
|
|||||||
|
|
||||||
\JavaScript::put([
|
\JavaScript::put([
|
||||||
'nodeData' => $this->nodeRepository->getNodesForServerCreation(),
|
'nodeData' => $this->nodeRepository->getNodesForServerCreation(),
|
||||||
'nests' => $nests->map(function ($item) {
|
'nests' => $nests->map(function (Nest $item) {
|
||||||
return array_merge($item->toArray(), [
|
return array_merge($item->toArray(), [
|
||||||
'eggs' => $item->eggs->keyBy('id')->toArray(),
|
'eggs' => $item->eggs->keyBy('id')->toArray(),
|
||||||
]);
|
]);
|
||||||
})->keyBy('id'),
|
})->keyBy('id'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->view->make('admin.servers.new', [
|
return view('admin.servers.new', [
|
||||||
'locations' => Location::all(),
|
'locations' => Location::all(),
|
||||||
'nests' => $nests,
|
'nests' => $nests,
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -9,17 +9,9 @@ use Spatie\QueryBuilder\QueryBuilder;
|
|||||||
use Spatie\QueryBuilder\AllowedFilter;
|
use Spatie\QueryBuilder\AllowedFilter;
|
||||||
use Pterodactyl\Http\Controllers\Controller;
|
use Pterodactyl\Http\Controllers\Controller;
|
||||||
use Pterodactyl\Models\Filters\AdminServerFilter;
|
use Pterodactyl\Models\Filters\AdminServerFilter;
|
||||||
use Illuminate\Contracts\View\Factory as ViewFactory;
|
|
||||||
|
|
||||||
class ServerController extends Controller
|
class ServerController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* ServerController constructor.
|
|
||||||
*/
|
|
||||||
public function __construct(private ViewFactory $view)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all the servers that exist on the system using a paginated result set. If
|
* Returns all the servers that exist on the system using a paginated result set. If
|
||||||
* a query is passed along in the request it is also passed to the repository function.
|
* a query is passed along in the request it is also passed to the repository function.
|
||||||
@ -33,6 +25,6 @@ class ServerController extends Controller
|
|||||||
])
|
])
|
||||||
->paginate(config()->get('pterodactyl.paginate.admin.servers'));
|
->paginate(config()->get('pterodactyl.paginate.admin.servers'));
|
||||||
|
|
||||||
return $this->view->make('admin.servers.index', ['servers' => $servers]);
|
return view('admin.servers.index', ['servers' => $servers]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,7 +66,7 @@ class ServerTransferController extends Controller
|
|||||||
$transfer->new_node = $node_id;
|
$transfer->new_node = $node_id;
|
||||||
$transfer->old_allocation = $server->allocation_id;
|
$transfer->old_allocation = $server->allocation_id;
|
||||||
$transfer->new_allocation = $allocation_id;
|
$transfer->new_allocation = $allocation_id;
|
||||||
$transfer->old_additional_allocations = $server->allocations->where('id', '!=', $server->allocation_id)->pluck('id');
|
$transfer->old_additional_allocations = $server->allocations->where('id', '!=', $server->allocation_id)->pluck('id')->values()->toArray();
|
||||||
$transfer->new_additional_allocations = $additional_allocations;
|
$transfer->new_additional_allocations = $additional_allocations;
|
||||||
|
|
||||||
$transfer->save();
|
$transfer->save();
|
||||||
|
|||||||
@ -9,11 +9,9 @@ use Pterodactyl\Models\Server;
|
|||||||
use Pterodactyl\Exceptions\DisplayException;
|
use Pterodactyl\Exceptions\DisplayException;
|
||||||
use Pterodactyl\Http\Controllers\Controller;
|
use Pterodactyl\Http\Controllers\Controller;
|
||||||
use Pterodactyl\Services\Servers\EnvironmentService;
|
use Pterodactyl\Services\Servers\EnvironmentService;
|
||||||
use Illuminate\Contracts\View\Factory as ViewFactory;
|
|
||||||
use Pterodactyl\Repositories\Eloquent\NestRepository;
|
use Pterodactyl\Repositories\Eloquent\NestRepository;
|
||||||
use Pterodactyl\Repositories\Eloquent\NodeRepository;
|
use Pterodactyl\Repositories\Eloquent\NodeRepository;
|
||||||
use Pterodactyl\Repositories\Eloquent\MountRepository;
|
use Pterodactyl\Repositories\Eloquent\MountRepository;
|
||||||
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
|
||||||
use Pterodactyl\Traits\Controllers\JavascriptInjection;
|
use Pterodactyl\Traits\Controllers\JavascriptInjection;
|
||||||
use Pterodactyl\Repositories\Eloquent\LocationRepository;
|
use Pterodactyl\Repositories\Eloquent\LocationRepository;
|
||||||
use Pterodactyl\Repositories\Eloquent\DatabaseHostRepository;
|
use Pterodactyl\Repositories\Eloquent\DatabaseHostRepository;
|
||||||
@ -31,9 +29,7 @@ class ServerViewController extends Controller
|
|||||||
private MountRepository $mountRepository,
|
private MountRepository $mountRepository,
|
||||||
private NestRepository $nestRepository,
|
private NestRepository $nestRepository,
|
||||||
private NodeRepository $nodeRepository,
|
private NodeRepository $nodeRepository,
|
||||||
private ServerRepository $repository,
|
|
||||||
private EnvironmentService $environmentService,
|
private EnvironmentService $environmentService,
|
||||||
private ViewFactory $view,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +38,7 @@ class ServerViewController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(Request $request, Server $server): View
|
public function index(Request $request, Server $server): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.servers.view.index', compact('server'));
|
return view('admin.servers.view.index', compact('server'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,7 +46,7 @@ class ServerViewController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function details(Request $request, Server $server): View
|
public function details(Request $request, Server $server): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.servers.view.details', compact('server'));
|
return view('admin.servers.view.details', compact('server'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,7 +56,7 @@ class ServerViewController extends Controller
|
|||||||
{
|
{
|
||||||
$allocations = $server->node->allocations->toBase();
|
$allocations = $server->node->allocations->toBase();
|
||||||
|
|
||||||
return $this->view->make('admin.servers.view.build', [
|
return view('admin.servers.view.build', [
|
||||||
'server' => $server,
|
'server' => $server,
|
||||||
'assigned' => $allocations->where('server_id', $server->id)->sortBy('port')->sortBy('ip'),
|
'assigned' => $allocations->where('server_id', $server->id)->sortBy('port')->sortBy('ip'),
|
||||||
'unassigned' => $allocations->where('server_id', null)->sortBy('port')->sortBy('ip'),
|
'unassigned' => $allocations->where('server_id', null)->sortBy('port')->sortBy('ip'),
|
||||||
@ -87,7 +83,7 @@ class ServerViewController extends Controller
|
|||||||
})->keyBy('id'),
|
})->keyBy('id'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->view->make('admin.servers.view.startup', compact('server', 'nests'));
|
return view('admin.servers.view.startup', compact('server', 'nests'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,7 +91,7 @@ class ServerViewController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function database(Request $request, Server $server): View
|
public function database(Request $request, Server $server): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.servers.view.database', [
|
return view('admin.servers.view.database', [
|
||||||
'hosts' => $this->databaseHostRepository->all(),
|
'hosts' => $this->databaseHostRepository->all(),
|
||||||
'server' => $server,
|
'server' => $server,
|
||||||
]);
|
]);
|
||||||
@ -108,7 +104,7 @@ class ServerViewController extends Controller
|
|||||||
{
|
{
|
||||||
$server->load('mounts');
|
$server->load('mounts');
|
||||||
|
|
||||||
return $this->view->make('admin.servers.view.mounts', [
|
return view('admin.servers.view.mounts', [
|
||||||
'mounts' => $this->mountRepository->getMountListForServer($server),
|
'mounts' => $this->mountRepository->getMountListForServer($server),
|
||||||
'server' => $server,
|
'server' => $server,
|
||||||
]);
|
]);
|
||||||
@ -137,7 +133,7 @@ class ServerViewController extends Controller
|
|||||||
'nodeData' => $this->nodeRepository->getNodesForServerCreation(),
|
'nodeData' => $this->nodeRepository->getNodesForServerCreation(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->view->make('admin.servers.view.manage', [
|
return view('admin.servers.view.manage', [
|
||||||
'server' => $server,
|
'server' => $server,
|
||||||
'locations' => $this->locationRepository->all(),
|
'locations' => $this->locationRepository->all(),
|
||||||
'canTransfer' => $canTransfer,
|
'canTransfer' => $canTransfer,
|
||||||
@ -149,6 +145,6 @@ class ServerViewController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function delete(Request $request, Server $server): View
|
public function delete(Request $request, Server $server): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.servers.view.delete', compact('server'));
|
return view('admin.servers.view.delete', compact('server'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,6 @@ use Illuminate\View\View;
|
|||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Prologue\Alerts\AlertsMessageBag;
|
use Prologue\Alerts\AlertsMessageBag;
|
||||||
use Illuminate\Contracts\Console\Kernel;
|
use Illuminate\Contracts\Console\Kernel;
|
||||||
use Illuminate\View\Factory as ViewFactory;
|
|
||||||
use Pterodactyl\Http\Controllers\Controller;
|
use Pterodactyl\Http\Controllers\Controller;
|
||||||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
||||||
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
|
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
|
||||||
@ -22,7 +21,6 @@ class AdvancedController extends Controller
|
|||||||
private ConfigRepository $config,
|
private ConfigRepository $config,
|
||||||
private Kernel $kernel,
|
private Kernel $kernel,
|
||||||
private SettingsRepositoryInterface $settings,
|
private SettingsRepositoryInterface $settings,
|
||||||
private ViewFactory $view,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +37,7 @@ class AdvancedController extends Controller
|
|||||||
$showRecaptchaWarning = true;
|
$showRecaptchaWarning = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->view->make('admin.settings.advanced', [
|
return view('admin.settings.advanced', [
|
||||||
'showRecaptchaWarning' => $showRecaptchaWarning,
|
'showRecaptchaWarning' => $showRecaptchaWarning,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,6 @@ use Illuminate\View\View;
|
|||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Prologue\Alerts\AlertsMessageBag;
|
use Prologue\Alerts\AlertsMessageBag;
|
||||||
use Illuminate\Contracts\Console\Kernel;
|
use Illuminate\Contracts\Console\Kernel;
|
||||||
use Illuminate\View\Factory as ViewFactory;
|
|
||||||
use Pterodactyl\Http\Controllers\Controller;
|
use Pterodactyl\Http\Controllers\Controller;
|
||||||
use Pterodactyl\Traits\Helpers\AvailableLanguages;
|
use Pterodactyl\Traits\Helpers\AvailableLanguages;
|
||||||
use Pterodactyl\Services\Helpers\SoftwareVersionService;
|
use Pterodactyl\Services\Helpers\SoftwareVersionService;
|
||||||
@ -25,7 +24,6 @@ class IndexController extends Controller
|
|||||||
private Kernel $kernel,
|
private Kernel $kernel,
|
||||||
private SettingsRepositoryInterface $settings,
|
private SettingsRepositoryInterface $settings,
|
||||||
private SoftwareVersionService $versionService,
|
private SoftwareVersionService $versionService,
|
||||||
private ViewFactory $view,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +32,7 @@ class IndexController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(): View
|
public function index(): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.settings.index', [
|
return view('admin.settings.index', [
|
||||||
'version' => $this->versionService,
|
'version' => $this->versionService,
|
||||||
'languages' => $this->getAvailableLanguages(true),
|
'languages' => $this->getAvailableLanguages(true),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -7,7 +7,6 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Contracts\Console\Kernel;
|
use Illuminate\Contracts\Console\Kernel;
|
||||||
use Pterodactyl\Notifications\MailTested;
|
use Pterodactyl\Notifications\MailTested;
|
||||||
use Illuminate\View\Factory as ViewFactory;
|
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
use Pterodactyl\Exceptions\DisplayException;
|
use Pterodactyl\Exceptions\DisplayException;
|
||||||
use Pterodactyl\Http\Controllers\Controller;
|
use Pterodactyl\Http\Controllers\Controller;
|
||||||
@ -27,7 +26,6 @@ class MailController extends Controller
|
|||||||
private Encrypter $encrypter,
|
private Encrypter $encrypter,
|
||||||
private Kernel $kernel,
|
private Kernel $kernel,
|
||||||
private SettingsRepositoryInterface $settings,
|
private SettingsRepositoryInterface $settings,
|
||||||
private ViewFactory $view,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +35,7 @@ class MailController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(): View
|
public function index(): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.settings.mail', [
|
return view('admin.settings.mail', [
|
||||||
'disabled' => $this->config->get('mail.default') !== 'smtp',
|
'disabled' => $this->config->get('mail.default') !== 'smtp',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,7 +57,7 @@ class UserController extends Controller
|
|||||||
->allowedSorts(['id', 'uuid'])
|
->allowedSorts(['id', 'uuid'])
|
||||||
->paginate(50);
|
->paginate(50);
|
||||||
|
|
||||||
return $this->view->make('admin.users.index', ['users' => $users]);
|
return view('admin.users.index', ['users' => $users]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,7 +65,7 @@ class UserController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function create(): View
|
public function create(): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.users.new', [
|
return view('admin.users.new', [
|
||||||
'languages' => $this->getAvailableLanguages(true),
|
'languages' => $this->getAvailableLanguages(true),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ class UserController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function view(User $user): View
|
public function view(User $user): View
|
||||||
{
|
{
|
||||||
return $this->view->make('admin.users.view', [
|
return view('admin.users.view', [
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'languages' => $this->getAvailableLanguages(true),
|
'languages' => $this->getAvailableLanguages(true),
|
||||||
]);
|
]);
|
||||||
@ -139,12 +139,14 @@ class UserController extends Controller
|
|||||||
// Handle single user requests.
|
// Handle single user requests.
|
||||||
if ($request->query('user_id')) {
|
if ($request->query('user_id')) {
|
||||||
$user = User::query()->findOrFail($request->input('user_id'));
|
$user = User::query()->findOrFail($request->input('user_id'));
|
||||||
|
// @phpstan-ignore-next-line property.notFound
|
||||||
$user->md5 = md5(strtolower($user->email));
|
$user->md5 = md5(strtolower($user->email));
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $users->map(function ($item) {
|
return $users->map(function ($item) {
|
||||||
|
// @phpstan-ignore-next-line property.notFound
|
||||||
$item->md5 = md5(strtolower($item->email));
|
$item->md5 = md5(strtolower($item->email));
|
||||||
|
|
||||||
return $item;
|
return $item;
|
||||||
|
|||||||
@ -59,7 +59,7 @@ abstract class ApplicationApiController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function getTransformer(string $abstract)
|
public function getTransformer(string $abstract)
|
||||||
{
|
{
|
||||||
Assert::subclassOf($abstract, BaseTransformer::class);
|
Assert::subclassOf($abstract, BaseTransformer::class); // @phpstan-ignore staticMethod.alreadyNarrowedType
|
||||||
|
|
||||||
return $abstract::fromRequest($this->request);
|
return $abstract::fromRequest($this->request);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,7 +64,7 @@ class AccountController extends ClientApiController
|
|||||||
$guard->setUser($user);
|
$guard->setUser($user);
|
||||||
|
|
||||||
// This method doesn't exist in the stateless Sanctum world.
|
// This method doesn't exist in the stateless Sanctum world.
|
||||||
if (method_exists($guard, 'logoutOtherDevices')) {
|
if (method_exists($guard, 'logoutOtherDevices')) { // @phpstan-ignore function.alreadyNarrowedType
|
||||||
$guard->logoutOtherDevices($request->input('password'));
|
$guard->logoutOtherDevices($request->input('password'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -49,7 +49,7 @@ abstract class ClientApiController extends ApplicationApiController
|
|||||||
*/
|
*/
|
||||||
public function getTransformer(string $abstract)
|
public function getTransformer(string $abstract)
|
||||||
{
|
{
|
||||||
Assert::subclassOf($abstract, BaseClientTransformer::class);
|
Assert::subclassOf($abstract, BaseClientTransformer::class); // @phpstan-ignore staticMethod.alreadyNarrowedType
|
||||||
|
|
||||||
return $abstract::fromRequest($this->request);
|
return $abstract::fromRequest($this->request);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,6 @@ namespace Pterodactyl\Http\Controllers\Api\Client\Servers;
|
|||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Pterodactyl\Models\Server;
|
use Pterodactyl\Models\Server;
|
||||||
use Pterodactyl\Facades\Activity;
|
use Pterodactyl\Facades\Activity;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
|
||||||
use GuzzleHttp\Exception\BadResponseException;
|
use GuzzleHttp\Exception\BadResponseException;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
use Pterodactyl\Repositories\Wings\DaemonCommandRepository;
|
use Pterodactyl\Repositories\Wings\DaemonCommandRepository;
|
||||||
@ -36,10 +35,7 @@ class CommandController extends ClientApiController
|
|||||||
$previous = $exception->getPrevious();
|
$previous = $exception->getPrevious();
|
||||||
|
|
||||||
if ($previous instanceof BadResponseException) {
|
if ($previous instanceof BadResponseException) {
|
||||||
if (
|
if ($previous->getResponse()->getStatusCode() === Response::HTTP_BAD_GATEWAY) {
|
||||||
$previous->getResponse() instanceof ResponseInterface
|
|
||||||
&& $previous->getResponse()->getStatusCode() === Response::HTTP_BAD_GATEWAY
|
|
||||||
) {
|
|
||||||
throw new HttpException(Response::HTTP_BAD_GATEWAY, 'Server must be online in order to send commands.', $exception);
|
throw new HttpException(Response::HTTP_BAD_GATEWAY, 'Server must be online in order to send commands.', $exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,9 +52,7 @@ class StartupController extends ClientApiController
|
|||||||
*/
|
*/
|
||||||
public function update(UpdateStartupVariableRequest $request, Server $server): array
|
public function update(UpdateStartupVariableRequest $request, Server $server): array
|
||||||
{
|
{
|
||||||
/** @var \Pterodactyl\Models\EggVariable $variable */
|
|
||||||
$variable = $server->variables()->where('env_variable', $request->input('key'))->first();
|
$variable = $server->variables()->where('env_variable', $request->input('key'))->first();
|
||||||
$original = $variable->server_value;
|
|
||||||
|
|
||||||
if (is_null($variable) || !$variable->user_viewable) {
|
if (is_null($variable) || !$variable->user_viewable) {
|
||||||
throw new BadRequestHttpException('The environment variable you are trying to edit does not exist.');
|
throw new BadRequestHttpException('The environment variable you are trying to edit does not exist.');
|
||||||
@ -62,6 +60,8 @@ class StartupController extends ClientApiController
|
|||||||
throw new BadRequestHttpException('The environment variable you are trying to edit is read-only.');
|
throw new BadRequestHttpException('The environment variable you are trying to edit is read-only.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$original = $variable->server_value;
|
||||||
|
|
||||||
// Revalidate the variable value using the egg variable specific validation rules for it.
|
// Revalidate the variable value using the egg variable specific validation rules for it.
|
||||||
$this->validate($request, ['value' => $variable->rules]);
|
$this->validate($request, ['value' => $variable->rules]);
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ use Illuminate\Http\JsonResponse;
|
|||||||
use Pterodactyl\Http\Controllers\Controller;
|
use Pterodactyl\Http\Controllers\Controller;
|
||||||
use Pterodactyl\Extensions\Backups\BackupManager;
|
use Pterodactyl\Extensions\Backups\BackupManager;
|
||||||
use Pterodactyl\Extensions\Filesystem\S3Filesystem;
|
use Pterodactyl\Extensions\Filesystem\S3Filesystem;
|
||||||
|
use Pterodactyl\Exceptions\Http\HttpForbiddenException;
|
||||||
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
|
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
|
||||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
|
|
||||||
@ -42,14 +43,10 @@ class BackupRemoteUploadController extends Controller
|
|||||||
throw new BadRequestHttpException('A non-empty "size" query parameter must be provided.');
|
throw new BadRequestHttpException('A non-empty "size" query parameter must be provided.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var Backup $model */
|
$model = Backup::query()->where('uuid', $backup)->firstOrFail();
|
||||||
$model = Backup::query()
|
|
||||||
->where('uuid', $backup)
|
|
||||||
->firstOrFail();
|
|
||||||
|
|
||||||
// Check that the backup is "owned" by the node making the request. This avoids other nodes
|
// Check that the backup is "owned" by the node making the request. This avoids other nodes
|
||||||
// from messing with backups that they don't own.
|
// from messing with backups that they don't own.
|
||||||
/** @var \Pterodactyl\Models\Server $server */
|
|
||||||
$server = $model->server;
|
$server = $model->server;
|
||||||
if ($server->node_id !== $node->id) {
|
if ($server->node_id !== $node->id) {
|
||||||
throw new HttpForbiddenException('You do not have permission to access that backup.');
|
throw new HttpForbiddenException('You do not have permission to access that backup.');
|
||||||
|
|||||||
@ -100,7 +100,7 @@ class ServerDetailsController extends Controller
|
|||||||
// so that power actions, file management, and backups can resume as normal.
|
// so that power actions, file management, and backups can resume as normal.
|
||||||
Activity::event('server:backup.restore-failed')
|
Activity::event('server:backup.restore-failed')
|
||||||
->subject($server, $subject->subject)
|
->subject($server, $subject->subject)
|
||||||
->property('name', $subject->subject->name)
|
->property('name', $subject->subject->name) // @phpstan-ignore property.notFound
|
||||||
->log();
|
->log();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -160,6 +160,6 @@ class SftpAuthenticationController extends Controller
|
|||||||
{
|
{
|
||||||
$username = explode('.', strrev($request->input('username', '')));
|
$username = explode('.', strrev($request->input('username', '')));
|
||||||
|
|
||||||
return strtolower(strrev($username[0] ?? '') . '|' . $request->ip());
|
return strtolower(strrev($username[0] ?? '') . '|' . $request->ip()); // @phpstan-ignore nullCoalesce.offset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,6 +49,8 @@ abstract class AbstractLoginController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Get the failed login response instance.
|
* Get the failed login response instance.
|
||||||
*
|
*
|
||||||
|
* @return never-return
|
||||||
|
*
|
||||||
* @throws DisplayException
|
* @throws DisplayException
|
||||||
*/
|
*/
|
||||||
protected function sendFailedLoginResponse(Request $request, ?Authenticatable $user = null, ?string $message = null)
|
protected function sendFailedLoginResponse(Request $request, ?Authenticatable $user = null, ?string $message = null)
|
||||||
|
|||||||
@ -56,7 +56,6 @@ class LoginCheckpointController extends AbstractLoginController
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/** @var User $user */
|
|
||||||
$user = User::query()->findOrFail($details['user_id']);
|
$user = User::query()->findOrFail($details['user_id']);
|
||||||
} catch (ModelNotFoundException) {
|
} catch (ModelNotFoundException) {
|
||||||
$this->sendFailedLoginResponse($request, null, self::TOKEN_EXPIRED_MESSAGE);
|
$this->sendFailedLoginResponse($request, null, self::TOKEN_EXPIRED_MESSAGE);
|
||||||
@ -72,7 +71,7 @@ class LoginCheckpointController extends AbstractLoginController
|
|||||||
} else {
|
} else {
|
||||||
$decrypted = $this->encrypter->decrypt($user->totp_secret);
|
$decrypted = $this->encrypter->decrypt($user->totp_secret);
|
||||||
|
|
||||||
if ($this->google2FA->verifyKey($decrypted, (string) $request->input('authentication_code') ?? '', config('pterodactyl.auth.2fa.window'))) {
|
if ($this->google2FA->verifyKey($decrypted, (string) ($request->input('authentication_code') ?? ''), config('pterodactyl.auth.2fa.window'))) {
|
||||||
Event::dispatch(new ProvidedAuthenticationToken($user));
|
Event::dispatch(new ProvidedAuthenticationToken($user));
|
||||||
|
|
||||||
return $this->sendLoginResponse($user, $request);
|
return $this->sendLoginResponse($user, $request);
|
||||||
|
|||||||
@ -9,19 +9,10 @@ use Pterodactyl\Models\User;
|
|||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Pterodactyl\Facades\Activity;
|
use Pterodactyl\Facades\Activity;
|
||||||
use Illuminate\Contracts\View\View;
|
use Illuminate\Contracts\View\View;
|
||||||
use Illuminate\Contracts\View\Factory as ViewFactory;
|
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
|
|
||||||
class LoginController extends AbstractLoginController
|
class LoginController extends AbstractLoginController
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* LoginController constructor.
|
|
||||||
*/
|
|
||||||
public function __construct(private ViewFactory $view)
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle all incoming requests for the authentication routes and render the
|
* Handle all incoming requests for the authentication routes and render the
|
||||||
* base authentication view component. React will take over at this point and
|
* base authentication view component. React will take over at this point and
|
||||||
@ -29,7 +20,7 @@ class LoginController extends AbstractLoginController
|
|||||||
*/
|
*/
|
||||||
public function index(): View
|
public function index(): View
|
||||||
{
|
{
|
||||||
return $this->view->make('templates/auth.core');
|
return view('templates/auth.core');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -67,7 +67,7 @@ class ResetPasswordController extends Controller
|
|||||||
* account do not automatically log them in. In those cases, send the user back to the login
|
* account do not automatically log them in. In those cases, send the user back to the login
|
||||||
* form with a note telling them their password was changed and to log back in.
|
* form with a note telling them their password was changed and to log back in.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Contracts\Auth\CanResetPassword|\Pterodactyl\Models\User $user
|
* @param \Illuminate\Contracts\Auth\CanResetPassword&\Pterodactyl\Models\User $user
|
||||||
* @param string $password
|
* @param string $password
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
|
|||||||
@ -23,6 +23,6 @@ class IndexController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(): View
|
public function index(): View
|
||||||
{
|
{
|
||||||
return $this->view->make('templates/base.core');
|
return view('templates/base.core');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ class TrackAPIKey
|
|||||||
if ($request->user()) {
|
if ($request->user()) {
|
||||||
$token = $request->user()->currentAccessToken();
|
$token = $request->user()->currentAccessToken();
|
||||||
|
|
||||||
LogTarget::setApiKeyId($token instanceof ApiKey ? $token->id : null);
|
LogTarget::setApiKeyId($token instanceof ApiKey ? $token->id : null); // @phpstan-ignore instanceof.alwaysTrue
|
||||||
}
|
}
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
|
|||||||
@ -16,7 +16,7 @@ class RequireClientApiKey
|
|||||||
{
|
{
|
||||||
$token = $request->user()->currentAccessToken();
|
$token = $request->user()->currentAccessToken();
|
||||||
|
|
||||||
if ($token instanceof ApiKey && $token->key_type === ApiKey::TYPE_APPLICATION) {
|
if ($token instanceof ApiKey && $token->key_type === ApiKey::TYPE_APPLICATION) { // @phpstan-ignore instanceof.alwaysTrue
|
||||||
throw new AccessDeniedHttpException('You are attempting to use an application API key on an endpoint that requires a client API key.');
|
throw new AccessDeniedHttpException('You are attempting to use an application API key on an endpoint that requires a client API key.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ class ResourceBelongsToServer
|
|||||||
public function handle(Request $request, \Closure $next): mixed
|
public function handle(Request $request, \Closure $next): mixed
|
||||||
{
|
{
|
||||||
$params = $request->route()->parameters();
|
$params = $request->route()->parameters();
|
||||||
if (is_null($params) || !$params['server'] instanceof Server) {
|
if (! isset($params['server']) || !$params['server'] instanceof Server) {
|
||||||
throw new \InvalidArgumentException('This middleware cannot be used in a context that is missing a server in the parameters.');
|
throw new \InvalidArgumentException('This middleware cannot be used in a context that is missing a server in the parameters.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ class ResourceBelongsToServer
|
|||||||
// that requires something in addition to the server in order to be accessed.
|
// that requires something in addition to the server in order to be accessed.
|
||||||
case Task::class:
|
case Task::class:
|
||||||
$schedule = $request->route()->parameter('schedule');
|
$schedule = $request->route()->parameter('schedule');
|
||||||
if ($model->schedule_id !== $schedule->id || $schedule->server_id !== $server->id) {
|
if (!$schedule instanceof Schedule || $model->schedule_id !== $schedule->id || $schedule->server_id !== $server->id) {
|
||||||
throw $exception;
|
throw $exception;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -35,7 +35,6 @@ class RequireTwoFactorAuthentication
|
|||||||
*/
|
*/
|
||||||
public function handle(Request $request, \Closure $next): mixed
|
public function handle(Request $request, \Closure $next): mixed
|
||||||
{
|
{
|
||||||
/** @var \Pterodactyl\Models\User $user */
|
|
||||||
$user = $request->user();
|
$user = $request->user();
|
||||||
$uri = rtrim($request->getRequestUri(), '/') . '/';
|
$uri = rtrim($request->getRequestUri(), '/') . '/';
|
||||||
$current = $request->route()->getName();
|
$current = $request->route()->getName();
|
||||||
|
|||||||
@ -12,7 +12,7 @@ class LocationFormRequest extends AdminFormRequest
|
|||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
if ($this->method() === 'PATCH') {
|
if ($this->method() === 'PATCH') {
|
||||||
return Location::getRulesForUpdate($this->route()->parameter('location')->id);
|
return Location::getRulesForUpdate($this->route()->parameter('location')->id); // @phpstan-ignore property.nonObject
|
||||||
}
|
}
|
||||||
|
|
||||||
return Location::getRules();
|
return Location::getRules();
|
||||||
|
|||||||
@ -12,7 +12,7 @@ class MountFormRequest extends AdminFormRequest
|
|||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
if ($this->method() === 'PATCH') {
|
if ($this->method() === 'PATCH') {
|
||||||
return Mount::getRulesForUpdate($this->route()->parameter('mount')->id);
|
return Mount::getRulesForUpdate($this->route()->parameter('mount')->id); // @phpstan-ignore property.nonObject
|
||||||
}
|
}
|
||||||
|
|
||||||
return Mount::getRules();
|
return Mount::getRules();
|
||||||
|
|||||||
@ -38,7 +38,7 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||||||
}
|
}
|
||||||
|
|
||||||
$token = $this->user()->currentAccessToken();
|
$token = $this->user()->currentAccessToken();
|
||||||
if ($token instanceof TransientToken) {
|
if ($token instanceof TransientToken) { // @phpstan-ignore instanceof.alwaysFalse
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||||||
$value = $this->route()->parameter($key);
|
$value = $this->route()->parameter($key);
|
||||||
|
|
||||||
Assert::isInstanceOf($value, $expect);
|
Assert::isInstanceOf($value, $expect);
|
||||||
Assert::isInstanceOf($value, Model::class);
|
Assert::isInstanceOf($value, Model::class); // @phpstan-ignore staticMethod.alreadyNarrowedType
|
||||||
Assert::true($value->exists);
|
Assert::true($value->exists);
|
||||||
|
|
||||||
/* @var T $value */
|
/* @var T $value */
|
||||||
|
|||||||
@ -11,7 +11,7 @@ class UpdateLocationRequest extends StoreLocationRequest
|
|||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
$locationId = $this->route()->parameter('location')->id;
|
$locationId = $this->route()->parameter('location')->id; // @phpstan-ignore property.nonObject
|
||||||
|
|
||||||
return collect(Location::getRulesForUpdate($locationId))->only([
|
return collect(Location::getRulesForUpdate($locationId))->only([
|
||||||
'short',
|
'short',
|
||||||
|
|||||||
@ -12,7 +12,7 @@ class UpdateNodeRequest extends StoreNodeRequest
|
|||||||
*/
|
*/
|
||||||
public function rules(?array $rules = null): array
|
public function rules(?array $rules = null): array
|
||||||
{
|
{
|
||||||
$node = $this->route()->parameter('node')->id;
|
$node = $this->parameter('node', Node::class);
|
||||||
|
|
||||||
return parent::rules(Node::getRulesForUpdate($node));
|
return parent::rules(Node::getRulesForUpdate($node));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ class StoreServerDatabaseRequest extends ApplicationApiRequest
|
|||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
$server = $this->route()->parameter('server');
|
$server = $this->parameter('server', Server::class);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'database' => [
|
'database' => [
|
||||||
|
|||||||
@ -18,7 +18,6 @@ class SetDockerImageRequest extends ClientApiRequest implements ClientPermission
|
|||||||
|
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
/** @var Server $server */
|
|
||||||
$server = $this->route()->parameter('server');
|
$server = $this->route()->parameter('server');
|
||||||
|
|
||||||
Assert::isInstanceOf($server, Server::class);
|
Assert::isInstanceOf($server, Server::class);
|
||||||
|
|||||||
@ -63,8 +63,6 @@ abstract class SubuserRequest extends ClientApiRequest
|
|||||||
// Otherwise, get the current subuser's permission set, and ensure that the
|
// Otherwise, get the current subuser's permission set, and ensure that the
|
||||||
// permissions they are trying to assign are not _more_ than the ones they
|
// permissions they are trying to assign are not _more_ than the ones they
|
||||||
// already have.
|
// already have.
|
||||||
/** @var Subuser|null $subuser */
|
|
||||||
/** @var GetUserPermissionsService $service */
|
|
||||||
$service = $this->container->make(GetUserPermissionsService::class);
|
$service = $this->container->make(GetUserPermissionsService::class);
|
||||||
|
|
||||||
if (count(array_diff($permissions, $service->handle($server, $user))) > 0) {
|
if (count(array_diff($permissions, $service->handle($server, $user))) > 0) {
|
||||||
|
|||||||
@ -26,7 +26,7 @@ use Illuminate\Database\Eloquent\Model as IlluminateModel;
|
|||||||
* @property \Illuminate\Support\Collection|null $properties
|
* @property \Illuminate\Support\Collection|null $properties
|
||||||
* @property Carbon $timestamp
|
* @property Carbon $timestamp
|
||||||
* @property IlluminateModel|\Eloquent $actor
|
* @property IlluminateModel|\Eloquent $actor
|
||||||
* @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\ActivityLogSubject[] $subjects
|
* @property \Illuminate\Database\Eloquent\Collection<int, \Pterodactyl\Models\ActivityLogSubject> $subjects
|
||||||
* @property int|null $subjects_count
|
* @property int|null $subjects_count
|
||||||
* @property ApiKey|null $apiKey
|
* @property ApiKey|null $apiKey
|
||||||
*
|
*
|
||||||
@ -82,21 +82,30 @@ class ActivityLog extends Model
|
|||||||
'properties' => ['array'],
|
'properties' => ['array'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\MorphTo<\Illuminate\Database\Eloquent\Model, $this>
|
||||||
|
*/
|
||||||
public function actor(): MorphTo
|
public function actor(): MorphTo
|
||||||
{
|
{
|
||||||
$morph = $this->morphTo();
|
$morph = $this->morphTo();
|
||||||
if (method_exists($morph, 'withTrashed')) {
|
if (method_exists($morph, 'withTrashed')) { // @phpstan-ignore function.alreadyNarrowedType
|
||||||
return $morph->withTrashed();
|
return $morph->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $morph;
|
return $morph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\ActivityLogSubject, $this>
|
||||||
|
*/
|
||||||
public function subjects(): HasMany
|
public function subjects(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(ActivityLogSubject::class);
|
return $this->hasMany(ActivityLogSubject::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasOne<\Pterodactyl\Models\ApiKey, $this>
|
||||||
|
*/
|
||||||
public function apiKey(): HasOne
|
public function apiKey(): HasOne
|
||||||
{
|
{
|
||||||
return $this->hasOne(ApiKey::class, 'id', 'api_key_id');
|
return $this->hasOne(ApiKey::class, 'id', 'api_key_id');
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
namespace Pterodactyl\Models;
|
namespace Pterodactyl\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \Pterodactyl\Models\ActivityLogSubject.
|
* \Pterodactyl\Models\ActivityLogSubject.
|
||||||
@ -12,13 +14,13 @@ use Illuminate\Database\Eloquent\Relations\Pivot;
|
|||||||
* @property int $subject_id
|
* @property int $subject_id
|
||||||
* @property string $subject_type
|
* @property string $subject_type
|
||||||
* @property ActivityLog|null $activityLog
|
* @property ActivityLog|null $activityLog
|
||||||
* @property \Illuminate\Database\Eloquent\Model|\Eloquent $subject
|
* @property \Illuminate\Database\Eloquent\Model $subject
|
||||||
*
|
*
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ActivityLogSubject newModelQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|ActivityLogSubject newModelQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ActivityLogSubject newQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|ActivityLogSubject newQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ActivityLogSubject query()
|
* @method static \Illuminate\Database\Eloquent\Builder|ActivityLogSubject query()
|
||||||
*
|
*
|
||||||
* @mixin \Eloquent
|
* @mixin \Illuminate\Database\Eloquent\Model
|
||||||
*/
|
*/
|
||||||
class ActivityLogSubject extends Pivot
|
class ActivityLogSubject extends Pivot
|
||||||
{
|
{
|
||||||
@ -29,15 +31,21 @@ class ActivityLogSubject extends Pivot
|
|||||||
|
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
|
|
||||||
public function activityLog()
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\ActivityLog, $this>
|
||||||
|
*/
|
||||||
|
public function activityLog(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(ActivityLog::class);
|
return $this->belongsTo(ActivityLog::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function subject()
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\MorphTo<\Illuminate\Database\Eloquent\Model, $this>
|
||||||
|
*/
|
||||||
|
public function subject(): MorphTo
|
||||||
{
|
{
|
||||||
$morph = $this->morphTo();
|
$morph = $this->morphTo();
|
||||||
if (method_exists($morph, 'withTrashed')) {
|
if (method_exists($morph, 'withTrashed')) { // @phpstan-ignore function.alreadyNarrowedType
|
||||||
return $morph->withTrashed();
|
return $morph->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -114,6 +114,8 @@ class Allocation extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets information for the server associated with this allocation.
|
* Gets information for the server associated with this allocation.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Server, $this>
|
||||||
*/
|
*/
|
||||||
public function server(): BelongsTo
|
public function server(): BelongsTo
|
||||||
{
|
{
|
||||||
@ -122,6 +124,8 @@ class Allocation extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Node model associated with this allocation.
|
* Return the Node model associated with this allocation.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Node, $this>
|
||||||
*/
|
*/
|
||||||
public function node(): BelongsTo
|
public function node(): BelongsTo
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,6 +5,7 @@ namespace Pterodactyl\Models;
|
|||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
||||||
|
use Laravel\Sanctum\Contracts\HasAbilities;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||||||
*
|
*
|
||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class ApiKey extends Model
|
class ApiKey extends Model implements HasAbilities
|
||||||
{
|
{
|
||||||
/** @use HasFactory<\Database\Factories\ApiKeyFactory> */
|
/** @use HasFactory<\Database\Factories\ApiKeyFactory> */
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
@ -159,8 +160,22 @@ class ApiKey extends Model
|
|||||||
'r_' . AdminAcl::RESOURCE_SERVERS => 'integer|min:0|max:3',
|
'r_' . AdminAcl::RESOURCE_SERVERS => 'integer|min:0|max:3',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function can($ability)
|
||||||
|
{
|
||||||
|
// todo: this was never initially implemented and only became obvious once
|
||||||
|
// internal tooling was updated and started catching this mistake.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cant($ability)
|
||||||
|
{
|
||||||
|
return ! $this->can($ability);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the user this token is assigned to.
|
* Returns the user this token is assigned to.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\User, $this>
|
||||||
*/
|
*/
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
@ -170,6 +185,8 @@ class ApiKey extends Model
|
|||||||
/**
|
/**
|
||||||
* Required for support with Laravel Sanctum.
|
* Required for support with Laravel Sanctum.
|
||||||
*
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\User, $this>
|
||||||
|
*
|
||||||
* @see \Laravel\Sanctum\Guard::supportsTokens()
|
* @see \Laravel\Sanctum\Guard::supportsTokens()
|
||||||
*/
|
*/
|
||||||
public function tokenable(): BelongsTo
|
public function tokenable(): BelongsTo
|
||||||
|
|||||||
@ -39,11 +39,17 @@ class AuditLog extends Model
|
|||||||
'created_at',
|
'created_at',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\User, $this>
|
||||||
|
*/
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Server, $this>
|
||||||
|
*/
|
||||||
public function server(): BelongsTo
|
public function server(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Server::class);
|
return $this->belongsTo(Server::class);
|
||||||
@ -58,9 +64,8 @@ class AuditLog extends Model
|
|||||||
*/
|
*/
|
||||||
public static function instance(string $action, array $metadata, bool $isSystem = false): self
|
public static function instance(string $action, array $metadata, bool $isSystem = false): self
|
||||||
{
|
{
|
||||||
/** @var Request $request */
|
|
||||||
$request = Container::getInstance()->make('request');
|
$request = Container::getInstance()->make('request');
|
||||||
if ($isSystem || !$request instanceof Request) {
|
if ($isSystem || !$request instanceof Request) { // @phpstan-ignore instanceof.alwaysTrue
|
||||||
$request = null;
|
$request = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -72,6 +72,9 @@ class Backup extends Model
|
|||||||
'upload_id' => 'nullable|string',
|
'upload_id' => 'nullable|string',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Server, $this>
|
||||||
|
*/
|
||||||
public function server(): BelongsTo
|
public function server(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Server::class);
|
return $this->belongsTo(Server::class);
|
||||||
|
|||||||
@ -94,6 +94,8 @@ class Database extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the host database server associated with a database.
|
* Gets the host database server associated with a database.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\DatabaseHost, $this>
|
||||||
*/
|
*/
|
||||||
public function host(): BelongsTo
|
public function host(): BelongsTo
|
||||||
{
|
{
|
||||||
@ -102,6 +104,8 @@ class Database extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the server associated with a database.
|
* Gets the server associated with a database.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Server, $this>
|
||||||
*/
|
*/
|
||||||
public function server(): BelongsTo
|
public function server(): BelongsTo
|
||||||
{
|
{
|
||||||
|
|||||||
@ -71,6 +71,8 @@ class DatabaseHost extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the node associated with a database host.
|
* Gets the node associated with a database host.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Node, $this>
|
||||||
*/
|
*/
|
||||||
public function node(): BelongsTo
|
public function node(): BelongsTo
|
||||||
{
|
{
|
||||||
@ -79,6 +81,8 @@ class DatabaseHost extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the databases associated with this host.
|
* Gets the databases associated with this host.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Database, $this>
|
||||||
*/
|
*/
|
||||||
public function databases(): HasMany
|
public function databases(): HasMany
|
||||||
{
|
{
|
||||||
|
|||||||
@ -167,7 +167,7 @@ class Egg extends Model
|
|||||||
*/
|
*/
|
||||||
public function getCopyScriptEntryAttribute(): string
|
public function getCopyScriptEntryAttribute(): string
|
||||||
{
|
{
|
||||||
if (!is_null($this->script_entry) || is_null($this->copy_script_from)) {
|
if (is_null($this->copy_script_from)) {
|
||||||
return $this->script_entry;
|
return $this->script_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ class Egg extends Model
|
|||||||
*/
|
*/
|
||||||
public function getCopyScriptContainerAttribute(): string
|
public function getCopyScriptContainerAttribute(): string
|
||||||
{
|
{
|
||||||
if (!is_null($this->script_container) || is_null($this->copy_script_from)) {
|
if (is_null($this->copy_script_from)) {
|
||||||
return $this->script_container;
|
return $this->script_container;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,6 +263,8 @@ class Egg extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets nest associated with an egg.
|
* Gets nest associated with an egg.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Nest, $this>
|
||||||
*/
|
*/
|
||||||
public function nest(): BelongsTo
|
public function nest(): BelongsTo
|
||||||
{
|
{
|
||||||
@ -271,6 +273,8 @@ class Egg extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all servers associated with this egg.
|
* Gets all servers associated with this egg.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Server, $this>
|
||||||
*/
|
*/
|
||||||
public function servers(): HasMany
|
public function servers(): HasMany
|
||||||
{
|
{
|
||||||
@ -279,6 +283,8 @@ class Egg extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all variables associated with this egg.
|
* Gets all variables associated with this egg.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\EggVariable, $this>
|
||||||
*/
|
*/
|
||||||
public function variables(): HasMany
|
public function variables(): HasMany
|
||||||
{
|
{
|
||||||
@ -287,6 +293,8 @@ class Egg extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the parent egg from which to copy scripts.
|
* Get the parent egg from which to copy scripts.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<self, $this>
|
||||||
*/
|
*/
|
||||||
public function scriptFrom(): BelongsTo
|
public function scriptFrom(): BelongsTo
|
||||||
{
|
{
|
||||||
@ -295,6 +303,8 @@ class Egg extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the parent egg from which to copy configuration settings.
|
* Get the parent egg from which to copy configuration settings.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<self, $this>
|
||||||
*/
|
*/
|
||||||
public function configFrom(): BelongsTo
|
public function configFrom(): BelongsTo
|
||||||
{
|
{
|
||||||
|
|||||||
@ -84,6 +84,9 @@ class EggVariable extends Model
|
|||||||
return in_array('required', explode('|', $this->rules));
|
return in_array('required', explode('|', $this->rules));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasOne<\Pterodactyl\Models\Egg, $this>
|
||||||
|
*/
|
||||||
public function egg(): HasOne
|
public function egg(): HasOne
|
||||||
{
|
{
|
||||||
return $this->hasOne(Egg::class);
|
return $this->hasOne(Egg::class);
|
||||||
@ -91,6 +94,8 @@ class EggVariable extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return server variables associated with this variable.
|
* Return server variables associated with this variable.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\ServerVariable, $this>
|
||||||
*/
|
*/
|
||||||
public function serverVariable(): HasMany
|
public function serverVariable(): HasMany
|
||||||
{
|
{
|
||||||
|
|||||||
@ -51,6 +51,8 @@ class Location extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the nodes in a specified location.
|
* Gets the nodes in a specified location.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Node, $this>
|
||||||
*/
|
*/
|
||||||
public function nodes(): HasMany
|
public function nodes(): HasMany
|
||||||
{
|
{
|
||||||
@ -59,6 +61,8 @@ class Location extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the servers within a given location.
|
* Gets the servers within a given location.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough<\Pterodactyl\Models\Server, \Pterodactyl\Models\Node, $this>
|
||||||
*/
|
*/
|
||||||
public function servers(): HasManyThrough
|
public function servers(): HasManyThrough
|
||||||
{
|
{
|
||||||
|
|||||||
@ -81,11 +81,12 @@ abstract class Model extends IlluminateModel
|
|||||||
/**
|
/**
|
||||||
* Returns the validator instance used by this model.
|
* Returns the validator instance used by this model.
|
||||||
*/
|
*/
|
||||||
public function getValidator(): Validator
|
public function getValidator(): \Illuminate\Validation\Validator
|
||||||
{
|
{
|
||||||
$rules = $this->exists ? static::getRulesForUpdate($this) : static::getRules();
|
$rules = $this->exists ? static::getRulesForUpdate($this) : static::getRules();
|
||||||
|
|
||||||
return static::$validatorFactory->make([], $rules, [], []);
|
// @phpstan-ignore-next-line return.type
|
||||||
|
return static::$validatorFactory->make([], $rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -94,6 +94,8 @@ class Mount extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all eggs that have this mount assigned.
|
* Returns all eggs that have this mount assigned.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<\Pterodactyl\Models\Egg, $this>
|
||||||
*/
|
*/
|
||||||
public function eggs(): BelongsToMany
|
public function eggs(): BelongsToMany
|
||||||
{
|
{
|
||||||
@ -102,6 +104,8 @@ class Mount extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all nodes that have this mount assigned.
|
* Returns all nodes that have this mount assigned.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<\Pterodactyl\Models\Node, $this>
|
||||||
*/
|
*/
|
||||||
public function nodes(): BelongsToMany
|
public function nodes(): BelongsToMany
|
||||||
{
|
{
|
||||||
@ -110,6 +114,8 @@ class Mount extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all servers that have this mount assigned.
|
* Returns all servers that have this mount assigned.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<\Pterodactyl\Models\Server, $this>
|
||||||
*/
|
*/
|
||||||
public function servers(): BelongsToMany
|
public function servers(): BelongsToMany
|
||||||
{
|
{
|
||||||
|
|||||||
@ -48,6 +48,8 @@ class Nest extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all eggs associated with this service.
|
* Gets all eggs associated with this service.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Egg, $this>
|
||||||
*/
|
*/
|
||||||
public function eggs(): HasMany
|
public function eggs(): HasMany
|
||||||
{
|
{
|
||||||
@ -56,6 +58,8 @@ class Nest extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all servers associated with this nest.
|
* Gets all servers associated with this nest.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Server, $this>
|
||||||
*/
|
*/
|
||||||
public function servers(): HasMany
|
public function servers(): HasMany
|
||||||
{
|
{
|
||||||
|
|||||||
@ -194,6 +194,9 @@ class Node extends Model
|
|||||||
return $this->maintenance_mode;
|
return $this->maintenance_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough<\Pterodactyl\Models\Mount, \Pterodactyl\Models\MountNode, $this>
|
||||||
|
*/
|
||||||
public function mounts(): HasManyThrough
|
public function mounts(): HasManyThrough
|
||||||
{
|
{
|
||||||
return $this->hasManyThrough(Mount::class, MountNode::class, 'node_id', 'id', 'id', 'mount_id');
|
return $this->hasManyThrough(Mount::class, MountNode::class, 'node_id', 'id', 'id', 'mount_id');
|
||||||
@ -201,6 +204,8 @@ class Node extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the location associated with a node.
|
* Gets the location associated with a node.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Location, $this>
|
||||||
*/
|
*/
|
||||||
public function location(): BelongsTo
|
public function location(): BelongsTo
|
||||||
{
|
{
|
||||||
@ -209,6 +214,8 @@ class Node extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the servers associated with a node.
|
* Gets the servers associated with a node.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Server, $this>
|
||||||
*/
|
*/
|
||||||
public function servers(): HasMany
|
public function servers(): HasMany
|
||||||
{
|
{
|
||||||
@ -217,6 +224,8 @@ class Node extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the allocations associated with a node.
|
* Gets the allocations associated with a node.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Allocation, $this>
|
||||||
*/
|
*/
|
||||||
public function allocations(): HasMany
|
public function allocations(): HasMany
|
||||||
{
|
{
|
||||||
@ -231,6 +240,7 @@ class Node extends Model
|
|||||||
$memoryLimit = $this->memory * (1 + ($this->memory_overallocate / 100));
|
$memoryLimit = $this->memory * (1 + ($this->memory_overallocate / 100));
|
||||||
$diskLimit = $this->disk * (1 + ($this->disk_overallocate / 100));
|
$diskLimit = $this->disk * (1 + ($this->disk_overallocate / 100));
|
||||||
|
|
||||||
|
// @phpstan-ignore-next-line property.notFound, property.notFound
|
||||||
return ($this->sum_memory + $memory) <= $memoryLimit && ($this->sum_disk + $disk) <= $diskLimit;
|
return ($this->sum_memory + $memory) <= $memoryLimit && ($this->sum_disk + $disk) <= $diskLimit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,6 +26,9 @@ class RecoveryToken extends Model
|
|||||||
'token' => 'required|string',
|
'token' => 'required|string',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\User, $this>
|
||||||
|
*/
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class);
|
||||||
|
|||||||
@ -28,7 +28,7 @@ use Pterodactyl\Contracts\Extensions\HashidsInterface;
|
|||||||
* @property \Carbon\Carbon $updated_at
|
* @property \Carbon\Carbon $updated_at
|
||||||
* @property string $hashid
|
* @property string $hashid
|
||||||
* @property Server $server
|
* @property Server $server
|
||||||
* @property \Pterodactyl\Models\Task[]|\Illuminate\Support\Collection $tasks
|
* @property \Illuminate\Database\Eloquent\Collection<int, \Pterodactyl\Models\Task> $tasks
|
||||||
*/
|
*/
|
||||||
class Schedule extends Model
|
class Schedule extends Model
|
||||||
{
|
{
|
||||||
@ -133,6 +133,8 @@ class Schedule extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return tasks belonging to a schedule.
|
* Return tasks belonging to a schedule.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Task, $this>
|
||||||
*/
|
*/
|
||||||
public function tasks(): HasMany
|
public function tasks(): HasMany
|
||||||
{
|
{
|
||||||
@ -141,6 +143,8 @@ class Schedule extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the server model that a schedule belongs to.
|
* Return the server model that a schedule belongs to.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Server, $this>
|
||||||
*/
|
*/
|
||||||
public function server(): BelongsTo
|
public function server(): BelongsTo
|
||||||
{
|
{
|
||||||
|
|||||||
@ -219,6 +219,8 @@ class Server extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the user who owns the server.
|
* Gets the user who owns the server.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\User, $this>
|
||||||
*/
|
*/
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
@ -227,6 +229,8 @@ class Server extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the subusers associated with a server.
|
* Gets the subusers associated with a server.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Subuser, $this>
|
||||||
*/
|
*/
|
||||||
public function subusers(): HasMany
|
public function subusers(): HasMany
|
||||||
{
|
{
|
||||||
@ -235,6 +239,8 @@ class Server extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the default allocation for a server.
|
* Gets the default allocation for a server.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasOne<\Pterodactyl\Models\Allocation, $this>
|
||||||
*/
|
*/
|
||||||
public function allocation(): HasOne
|
public function allocation(): HasOne
|
||||||
{
|
{
|
||||||
@ -243,6 +249,8 @@ class Server extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all allocations associated with this server.
|
* Gets all allocations associated with this server.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Allocation, $this>
|
||||||
*/
|
*/
|
||||||
public function allocations(): HasMany
|
public function allocations(): HasMany
|
||||||
{
|
{
|
||||||
@ -251,6 +259,8 @@ class Server extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets information for the nest associated with this server.
|
* Gets information for the nest associated with this server.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Nest, $this>
|
||||||
*/
|
*/
|
||||||
public function nest(): BelongsTo
|
public function nest(): BelongsTo
|
||||||
{
|
{
|
||||||
@ -259,6 +269,8 @@ class Server extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets information for the egg associated with this server.
|
* Gets information for the egg associated with this server.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasOne<\Pterodactyl\Models\Egg, $this>
|
||||||
*/
|
*/
|
||||||
public function egg(): HasOne
|
public function egg(): HasOne
|
||||||
{
|
{
|
||||||
@ -267,6 +279,8 @@ class Server extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets information for the service variables associated with this server.
|
* Gets information for the service variables associated with this server.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\EggVariable, $this>
|
||||||
*/
|
*/
|
||||||
public function variables(): HasMany
|
public function variables(): HasMany
|
||||||
{
|
{
|
||||||
@ -285,6 +299,8 @@ class Server extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets information for the node associated with this server.
|
* Gets information for the node associated with this server.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Node, $this>
|
||||||
*/
|
*/
|
||||||
public function node(): BelongsTo
|
public function node(): BelongsTo
|
||||||
{
|
{
|
||||||
@ -293,6 +309,8 @@ class Server extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets information for the tasks associated with this server.
|
* Gets information for the tasks associated with this server.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Schedule, $this>
|
||||||
*/
|
*/
|
||||||
public function schedules(): HasMany
|
public function schedules(): HasMany
|
||||||
{
|
{
|
||||||
@ -301,6 +319,8 @@ class Server extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all databases associated with a server.
|
* Gets all databases associated with a server.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Database, $this>
|
||||||
*/
|
*/
|
||||||
public function databases(): HasMany
|
public function databases(): HasMany
|
||||||
{
|
{
|
||||||
@ -310,21 +330,28 @@ class Server extends Model
|
|||||||
/**
|
/**
|
||||||
* Returns the location that a server belongs to.
|
* Returns the location that a server belongs to.
|
||||||
*
|
*
|
||||||
|
* @return \Znck\Eloquent\Relations\BelongsToThrough<\Pterodactyl\Models\Location, \Pterodactyl\Models\Node>
|
||||||
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function location(): \Znck\Eloquent\Relations\BelongsToThrough
|
public function location(): \Znck\Eloquent\Relations\BelongsToThrough
|
||||||
{
|
{
|
||||||
return $this->belongsToThrough(Location::class, Node::class);
|
return $this->belongsToThrough(Location::class, Node::class); // @phpstan-ignore return.type
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the associated server transfer.
|
* Returns the associated server transfer.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasOne<\Pterodactyl\Models\ServerTransfer, $this>
|
||||||
*/
|
*/
|
||||||
public function transfer(): HasOne
|
public function transfer(): HasOne
|
||||||
{
|
{
|
||||||
return $this->hasOne(ServerTransfer::class)->whereNull('successful')->orderByDesc('id');
|
return $this->hasOne(ServerTransfer::class)->whereNull('successful')->orderByDesc('id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Backup, $this>
|
||||||
|
*/
|
||||||
public function backups(): HasMany
|
public function backups(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(Backup::class);
|
return $this->hasMany(Backup::class);
|
||||||
@ -332,6 +359,8 @@ class Server extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all mounts that have this server has mounted.
|
* Returns all mounts that have this server has mounted.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough<\Pterodactyl\Models\Mount, \Pterodactyl\Models\MountServer, $this>
|
||||||
*/
|
*/
|
||||||
public function mounts(): HasManyThrough
|
public function mounts(): HasManyThrough
|
||||||
{
|
{
|
||||||
@ -340,6 +369,8 @@ class Server extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all of the activity log entries where the server is the subject.
|
* Returns all of the activity log entries where the server is the subject.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany<\Pterodactyl\Models\ActivityLog, $this>
|
||||||
*/
|
*/
|
||||||
public function activity(): MorphToMany
|
public function activity(): MorphToMany
|
||||||
{
|
{
|
||||||
|
|||||||
@ -70,6 +70,8 @@ class ServerTransfer extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the server associated with a server transfer.
|
* Gets the server associated with a server transfer.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Server, $this>
|
||||||
*/
|
*/
|
||||||
public function server(): BelongsTo
|
public function server(): BelongsTo
|
||||||
{
|
{
|
||||||
@ -78,6 +80,8 @@ class ServerTransfer extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the source node associated with a server transfer.
|
* Gets the source node associated with a server transfer.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasOne<\Pterodactyl\Models\Node, $this>
|
||||||
*/
|
*/
|
||||||
public function oldNode(): HasOne
|
public function oldNode(): HasOne
|
||||||
{
|
{
|
||||||
@ -86,6 +90,8 @@ class ServerTransfer extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the target node associated with a server transfer.
|
* Gets the target node associated with a server transfer.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasOne<\Pterodactyl\Models\Node, $this>
|
||||||
*/
|
*/
|
||||||
public function newNode(): HasOne
|
public function newNode(): HasOne
|
||||||
{
|
{
|
||||||
|
|||||||
@ -41,6 +41,8 @@ class ServerVariable extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the server this variable is associated with.
|
* Returns the server this variable is associated with.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Server, $this>
|
||||||
*/
|
*/
|
||||||
public function server(): BelongsTo
|
public function server(): BelongsTo
|
||||||
{
|
{
|
||||||
@ -49,6 +51,8 @@ class ServerVariable extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns information about a given variables parent.
|
* Returns information about a given variables parent.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\EggVariable, $this>
|
||||||
*/
|
*/
|
||||||
public function variable(): BelongsTo
|
public function variable(): BelongsTo
|
||||||
{
|
{
|
||||||
|
|||||||
@ -65,6 +65,8 @@ class Subuser extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the server associated with a subuser.
|
* Gets the server associated with a subuser.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Server, $this>
|
||||||
*/
|
*/
|
||||||
public function server(): BelongsTo
|
public function server(): BelongsTo
|
||||||
{
|
{
|
||||||
@ -73,6 +75,8 @@ class Subuser extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the user associated with a subuser.
|
* Gets the user associated with a subuser.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\User, $this>
|
||||||
*/
|
*/
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
@ -81,6 +85,8 @@ class Subuser extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the permissions associated with a subuser.
|
* Gets the permissions associated with a subuser.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Permission, $this>
|
||||||
*/
|
*/
|
||||||
public function permissions(): HasMany
|
public function permissions(): HasMany
|
||||||
{
|
{
|
||||||
|
|||||||
@ -111,6 +111,8 @@ class Task extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the schedule that a task belongs to.
|
* Return the schedule that a task belongs to.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Schedule, $this>
|
||||||
*/
|
*/
|
||||||
public function schedule(): BelongsTo
|
public function schedule(): BelongsTo
|
||||||
{
|
{
|
||||||
@ -119,9 +121,11 @@ class Task extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the server a task is assigned to, acts as a belongsToThrough.
|
* Return the server a task is assigned to, acts as a belongsToThrough.
|
||||||
|
*
|
||||||
|
* @return \Znck\Eloquent\Relations\BelongsToThrough<\Pterodactyl\Models\Server, \Pterodactyl\Models\Schedule>
|
||||||
*/
|
*/
|
||||||
public function server(): \Znck\Eloquent\Relations\BelongsToThrough
|
public function server(): \Znck\Eloquent\Relations\BelongsToThrough
|
||||||
{
|
{
|
||||||
return $this->belongsToThrough(Server::class, Schedule::class);
|
return $this->belongsToThrough(Server::class, Schedule::class); // @phpstan-ignore return.type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,10 +10,13 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||||||
use Pterodactyl\Extensions\Laravel\Sanctum\NewAccessToken;
|
use Pterodactyl\Extensions\Laravel\Sanctum\NewAccessToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @template TToken of \Laravel\Sanctum\Contracts\HasAbilities
|
||||||
|
*
|
||||||
* @mixin \Pterodactyl\Models\Model
|
* @mixin \Pterodactyl\Models\Model
|
||||||
*/
|
*/
|
||||||
trait HasAccessTokens
|
trait HasAccessTokens
|
||||||
{
|
{
|
||||||
|
/** @use \Laravel\Sanctum\HasApiTokens<TToken> */
|
||||||
use HasApiTokens {
|
use HasApiTokens {
|
||||||
tokens as private _tokens;
|
tokens as private _tokens;
|
||||||
createToken as private _createToken;
|
createToken as private _createToken;
|
||||||
|
|||||||
@ -88,9 +88,10 @@ class User extends Model implements
|
|||||||
use Authorizable;
|
use Authorizable;
|
||||||
use AvailableLanguages;
|
use AvailableLanguages;
|
||||||
use CanResetPassword;
|
use CanResetPassword;
|
||||||
|
/** @use \Pterodactyl\Models\Traits\HasAccessTokens<\Pterodactyl\Models\ApiKey> */
|
||||||
use HasAccessTokens;
|
use HasAccessTokens;
|
||||||
use Notifiable;
|
use Notifiable;
|
||||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
/** @use \Illuminate\Database\Eloquent\Factories\HasFactory<\Database\Factories\UserFactory> */
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
public const USER_LEVEL_USER = 0;
|
public const USER_LEVEL_USER = 0;
|
||||||
@ -228,23 +229,34 @@ class User extends Model implements
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all servers that a user owns.
|
* Returns all servers that a user owns.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Server, $this>
|
||||||
*/
|
*/
|
||||||
public function servers(): HasMany
|
public function servers(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(Server::class, 'owner_id');
|
return $this->hasMany(Server::class, 'owner_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\ApiKey, $this>
|
||||||
|
*/
|
||||||
public function apiKeys(): HasMany
|
public function apiKeys(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(ApiKey::class)
|
return $this->hasMany(ApiKey::class)
|
||||||
->where('key_type', ApiKey::TYPE_ACCOUNT);
|
->where('key_type', ApiKey::TYPE_ACCOUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\RecoveryToken, $this>
|
||||||
|
*/
|
||||||
public function recoveryTokens(): HasMany
|
public function recoveryTokens(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(RecoveryToken::class);
|
return $this->hasMany(RecoveryToken::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\UserSSHKey, $this>
|
||||||
|
*/
|
||||||
public function sshKeys(): HasMany
|
public function sshKeys(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(UserSSHKey::class);
|
return $this->hasMany(UserSSHKey::class);
|
||||||
@ -253,6 +265,8 @@ class User extends Model implements
|
|||||||
/**
|
/**
|
||||||
* Returns all the activity logs where this user is the subject — not to
|
* Returns all the activity logs where this user is the subject — not to
|
||||||
* be confused by activity logs where this user is the _actor_.
|
* be confused by activity logs where this user is the _actor_.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany<\Pterodactyl\Models\ActivityLog, $this>
|
||||||
*/
|
*/
|
||||||
public function activity(): MorphToMany
|
public function activity(): MorphToMany
|
||||||
{
|
{
|
||||||
@ -262,6 +276,8 @@ class User extends Model implements
|
|||||||
/**
|
/**
|
||||||
* Returns all the servers that a user can access by way of being the owner of the
|
* Returns all the servers that a user can access by way of being the owner of the
|
||||||
* server, or because they are assigned as a subuser for that server.
|
* server, or because they are assigned as a subuser for that server.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder<\Pterodactyl\Models\Server>
|
||||||
*/
|
*/
|
||||||
public function accessibleServers(): Builder
|
public function accessibleServers(): Builder
|
||||||
{
|
{
|
||||||
|
|||||||
@ -33,10 +33,9 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSSHKey whereUserId($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|UserSSHKey whereUserId($value)
|
||||||
* @method static \Illuminate\Database\Query\Builder|UserSSHKey withTrashed()
|
* @method static \Illuminate\Database\Query\Builder|UserSSHKey withTrashed()
|
||||||
* @method static \Illuminate\Database\Query\Builder|UserSSHKey withoutTrashed()
|
* @method static \Illuminate\Database\Query\Builder|UserSSHKey withoutTrashed()
|
||||||
|
* @method static \Database\Factories\UserSSHKeyFactory factory(...$parameters)
|
||||||
*
|
*
|
||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*
|
|
||||||
* @method static \Database\Factories\UserSSHKeyFactory factory(...$parameters)
|
|
||||||
*/
|
*/
|
||||||
class UserSSHKey extends Model
|
class UserSSHKey extends Model
|
||||||
{
|
{
|
||||||
@ -60,6 +59,9 @@ class UserSSHKey extends Model
|
|||||||
'public_key' => ['required', 'string'],
|
'public_key' => ['required', 'string'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\User, $this>
|
||||||
|
*/
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class);
|
||||||
|
|||||||
@ -25,6 +25,8 @@ class ServerInstalled extends Notification implements ShouldQueue, ReceivesEvent
|
|||||||
/**
|
/**
|
||||||
* Handle a direct call to this notification from the server installed event. This is configured
|
* Handle a direct call to this notification from the server installed event. This is configured
|
||||||
* in the event service provider.
|
* in the event service provider.
|
||||||
|
*
|
||||||
|
* @phpstan-param Installed $event
|
||||||
*/
|
*/
|
||||||
public function handle(Event|Installed $event): void
|
public function handle(Event|Installed $event): void
|
||||||
{
|
{
|
||||||
|
|||||||
@ -8,6 +8,7 @@ class EggVariableObserver
|
|||||||
{
|
{
|
||||||
public function creating(EggVariable $variable): void
|
public function creating(EggVariable $variable): void
|
||||||
{
|
{
|
||||||
|
// @phpstan-ignore-next-line property.notFound
|
||||||
if ($variable->field_type) {
|
if ($variable->field_type) {
|
||||||
unset($variable->field_type);
|
unset($variable->field_type);
|
||||||
}
|
}
|
||||||
@ -15,6 +16,7 @@ class EggVariableObserver
|
|||||||
|
|
||||||
public function updating(EggVariable $variable): void
|
public function updating(EggVariable $variable): void
|
||||||
{
|
{
|
||||||
|
// @phpstan-ignore-next-line property.notFound
|
||||||
if ($variable->field_type) {
|
if ($variable->field_type) {
|
||||||
unset($variable->field_type);
|
unset($variable->field_type);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,6 +34,8 @@ class BackupRepository extends EloquentRepository
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a query filtering only non-failed backups for a specific server.
|
* Returns a query filtering only non-failed backups for a specific server.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Backup, \Pterodactyl\Models\Server>
|
||||||
*/
|
*/
|
||||||
public function getNonFailedBackups(Server $server): HasMany
|
public function getNonFailedBackups(Server $server): HasMany
|
||||||
{
|
{
|
||||||
|
|||||||
@ -20,6 +20,8 @@ class NestRepository extends EloquentRepository implements NestRepositoryInterfa
|
|||||||
/**
|
/**
|
||||||
* Return a nest or all nests with their associated eggs and variables.
|
* Return a nest or all nests with their associated eggs and variables.
|
||||||
*
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Collection<int, \Pterodactyl\Models\Nest>|\Pterodactyl\Models\Nest
|
||||||
|
*
|
||||||
* @throws RecordNotFoundException
|
* @throws RecordNotFoundException
|
||||||
*/
|
*/
|
||||||
public function getWithEggs(?int $id = null): Collection|Nest
|
public function getWithEggs(?int $id = null): Collection|Nest
|
||||||
@ -41,6 +43,8 @@ class NestRepository extends EloquentRepository implements NestRepositoryInterfa
|
|||||||
/**
|
/**
|
||||||
* Return a nest or all nests and the count of eggs and servers for that nest.
|
* Return a nest or all nests and the count of eggs and servers for that nest.
|
||||||
*
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Collection<int, \Pterodactyl\Models\Nest>|\Pterodactyl\Models\Nest
|
||||||
|
*
|
||||||
* @throws RecordNotFoundException
|
* @throws RecordNotFoundException
|
||||||
*/
|
*/
|
||||||
public function getWithCounts(?int $id = null): Collection|Nest
|
public function getWithCounts(?int $id = null): Collection|Nest
|
||||||
@ -71,7 +75,6 @@ class NestRepository extends EloquentRepository implements NestRepositoryInterfa
|
|||||||
throw new RecordNotFoundException();
|
throw new RecordNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @var Nest $instance */
|
return $instance; // @phpstan-ignore return.type
|
||||||
return $instance;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,7 +72,7 @@ class Fqdn implements Rule, DataAwareRule
|
|||||||
*/
|
*/
|
||||||
public static function make(?string $schemeField = null): self
|
public static function make(?string $schemeField = null): self
|
||||||
{
|
{
|
||||||
return tap(new static(), function ($fqdn) use ($schemeField) {
|
return tap(new self(), function ($fqdn) use ($schemeField) {
|
||||||
$fqdn->schemeField = $schemeField;
|
$fqdn->schemeField = $schemeField;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -140,7 +140,7 @@ class ActivityLogService
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return $this->save();
|
return $this->save();
|
||||||
} catch (\Throwable|\Exception $exception) {
|
} catch (\Throwable $exception) {
|
||||||
if (config('app.env') !== 'production') {
|
if (config('app.env') !== 'production') {
|
||||||
/* @noinspection PhpUnhandledExceptionInspection */
|
/* @noinspection PhpUnhandledExceptionInspection */
|
||||||
throw $exception;
|
throw $exception;
|
||||||
@ -210,10 +210,8 @@ class ActivityLogService
|
|||||||
|
|
||||||
if ($actor = $this->targetable->actor()) {
|
if ($actor = $this->targetable->actor()) {
|
||||||
$this->actor($actor);
|
$this->actor($actor);
|
||||||
} elseif ($user = $this->manager->guard()->user()) {
|
} elseif (! is_null($user = $this->manager->guard()->user())) {
|
||||||
if ($user instanceof Model) {
|
$this->actor($user);
|
||||||
$this->actor($user);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->activity;
|
return $this->activity;
|
||||||
|
|||||||
@ -54,7 +54,7 @@ class AssignmentService
|
|||||||
$underlying = gethostbyname($data['allocation_ip']);
|
$underlying = gethostbyname($data['allocation_ip']);
|
||||||
$parsed = Network::parse($underlying);
|
$parsed = Network::parse($underlying);
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
/* @noinspection PhpUndefinedVariableInspection */
|
// @phpstan-ignore-next-line variable.undefined
|
||||||
throw new DisplayException("Could not parse provided allocation IP address ({$underlying}): {$exception->getMessage()}", $exception);
|
throw new DisplayException("Could not parse provided allocation IP address ({$underlying}): {$exception->getMessage()}", $exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -73,6 +73,7 @@ class DeleteBackupService
|
|||||||
/** @var \Pterodactyl\Extensions\Filesystem\S3Filesystem $adapter */
|
/** @var \Pterodactyl\Extensions\Filesystem\S3Filesystem $adapter */
|
||||||
$adapter = $this->manager->adapter(Backup::ADAPTER_AWS_S3);
|
$adapter = $this->manager->adapter(Backup::ADAPTER_AWS_S3);
|
||||||
|
|
||||||
|
// @phpstan-ignore-next-line method.notFound
|
||||||
$adapter->getClient()->deleteObject([
|
$adapter->getClient()->deleteObject([
|
||||||
'Bucket' => $adapter->getBucket(),
|
'Bucket' => $adapter->getBucket(),
|
||||||
'Key' => sprintf('%s/%s.tar.gz', $backup->server->uuid, $backup->uuid),
|
'Key' => sprintf('%s/%s.tar.gz', $backup->server->uuid, $backup->uuid),
|
||||||
|
|||||||
@ -16,7 +16,7 @@ use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;
|
|||||||
|
|
||||||
class InitiateBackupService
|
class InitiateBackupService
|
||||||
{
|
{
|
||||||
private ?array $ignoredFiles;
|
private array $ignoredFiles = [];
|
||||||
|
|
||||||
private bool $isLocked = false;
|
private bool $isLocked = false;
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ class InitiateBackupService
|
|||||||
{
|
{
|
||||||
if (is_array($ignored)) {
|
if (is_array($ignored)) {
|
||||||
foreach ($ignored as $value) {
|
foreach ($ignored as $value) {
|
||||||
Assert::string($value);
|
Assert::string($value); // @phpstan-ignore staticMethod.alreadyNarrowedType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,6 @@ class InitiateBackupService
|
|||||||
// Get the oldest backup the server has that is not "locked" (indicating a backup that should
|
// Get the oldest backup the server has that is not "locked" (indicating a backup that should
|
||||||
// never be automatically purged). If we find a backup we will delete it and then continue with
|
// never be automatically purged). If we find a backup we will delete it and then continue with
|
||||||
// this process. If no backup is found that can be used an exception is thrown.
|
// this process. If no backup is found that can be used an exception is thrown.
|
||||||
/** @var Backup $oldest */
|
|
||||||
$oldest = $successful->where('is_locked', false)->orderBy('created_at')->first();
|
$oldest = $successful->where('is_locked', false)->orderBy('created_at')->first();
|
||||||
if (!$oldest) {
|
if (!$oldest) {
|
||||||
throw new TooManyBackupsException($server->backup_limit);
|
throw new TooManyBackupsException($server->backup_limit);
|
||||||
@ -113,7 +112,7 @@ class InitiateBackupService
|
|||||||
'server_id' => $server->id,
|
'server_id' => $server->id,
|
||||||
'uuid' => Uuid::uuid4()->toString(),
|
'uuid' => Uuid::uuid4()->toString(),
|
||||||
'name' => trim($name) ?: sprintf('Backup at %s', CarbonImmutable::now()->toDateTimeString()),
|
'name' => trim($name) ?: sprintf('Backup at %s', CarbonImmutable::now()->toDateTimeString()),
|
||||||
'ignored_files' => array_values($this->ignoredFiles ?? []),
|
'ignored_files' => array_values($this->ignoredFiles),
|
||||||
'disk' => $this->backupManager->getDefaultAdapter(),
|
'disk' => $this->backupManager->getDefaultAdapter(),
|
||||||
'is_locked' => $this->isLocked,
|
'is_locked' => $this->isLocked,
|
||||||
], true, true);
|
], true, true);
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace Pterodactyl\Services\Databases;
|
namespace Pterodactyl\Services\Databases;
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use Pterodactyl\Models\Server;
|
use Pterodactyl\Models\Server;
|
||||||
use Pterodactyl\Models\Database;
|
use Pterodactyl\Models\Database;
|
||||||
use Pterodactyl\Helpers\Utilities;
|
use Pterodactyl\Helpers\Utilities;
|
||||||
@ -118,12 +117,16 @@ class DatabaseManagementService
|
|||||||
});
|
});
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
try {
|
try {
|
||||||
|
// This is actually incorrect, it can be null in the case that the $database model
|
||||||
|
// itself isn't able to be created in Pterodactyl's database.
|
||||||
|
//
|
||||||
|
// @phpstan-ignore-next-line instanceof.alwaysFalse
|
||||||
if ($database instanceof Database) {
|
if ($database instanceof Database) {
|
||||||
$this->repository->dropDatabase($database->database);
|
$this->repository->dropDatabase($database->database);
|
||||||
$this->repository->dropUser($database->username, $database->remote);
|
$this->repository->dropUser($database->username, $database->remote);
|
||||||
$this->repository->flush();
|
$this->repository->flush();
|
||||||
}
|
}
|
||||||
} catch (\Exception $deletionException) {
|
} catch (\Throwable $deletionException) { // @phpstan-ignore catch.neverThrown
|
||||||
// Do nothing here. We've already encountered an issue before this point so no
|
// Do nothing here. We've already encountered an issue before this point so no
|
||||||
// reason to prioritize this error over the initial one.
|
// reason to prioritize this error over the initial one.
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace Pterodactyl\Services\Locations;
|
namespace Pterodactyl\Services\Locations;
|
||||||
|
|
||||||
use Webmozart\Assert\Assert;
|
|
||||||
use Pterodactyl\Models\Location;
|
use Pterodactyl\Models\Location;
|
||||||
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
||||||
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
|
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
|
||||||
@ -26,9 +25,7 @@ class LocationDeletionService
|
|||||||
*/
|
*/
|
||||||
public function handle(Location|int $location): ?int
|
public function handle(Location|int $location): ?int
|
||||||
{
|
{
|
||||||
$location = ($location instanceof Location) ? $location->id : $location;
|
$location = $location instanceof Location ? $location->id : $location;
|
||||||
|
|
||||||
Assert::integerish($location, 'First argument passed to handle must be numeric or an instance of ' . Location::class . ', received %s.');
|
|
||||||
|
|
||||||
$count = $this->nodeRepository->findCountWhere([['location_id', '=', $location]]);
|
$count = $this->nodeRepository->findCountWhere([['location_id', '=', $location]]);
|
||||||
if ($count > 0) {
|
if ($count > 0) {
|
||||||
|
|||||||
@ -6,8 +6,8 @@ use Carbon\CarbonImmutable;
|
|||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Pterodactyl\Models\Node;
|
use Pterodactyl\Models\Node;
|
||||||
use Pterodactyl\Models\User;
|
use Pterodactyl\Models\User;
|
||||||
use Lcobucci\JWT\Token\Plain;
|
|
||||||
use Lcobucci\JWT\Configuration;
|
use Lcobucci\JWT\Configuration;
|
||||||
|
use Lcobucci\JWT\UnencryptedToken;
|
||||||
use Lcobucci\JWT\Signer\Hmac\Sha256;
|
use Lcobucci\JWT\Signer\Hmac\Sha256;
|
||||||
use Lcobucci\JWT\Signer\Key\InMemory;
|
use Lcobucci\JWT\Signer\Key\InMemory;
|
||||||
use Pterodactyl\Extensions\Lcobucci\JWT\Encoding\TimestampDates;
|
use Pterodactyl\Extensions\Lcobucci\JWT\Encoding\TimestampDates;
|
||||||
@ -18,7 +18,7 @@ class NodeJWTService
|
|||||||
|
|
||||||
private ?User $user = null;
|
private ?User $user = null;
|
||||||
|
|
||||||
private ?\DateTimeImmutable $expiresAt;
|
private \DateTimeImmutable $expiresAt;
|
||||||
|
|
||||||
private ?string $subject = null;
|
private ?string $subject = null;
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ class NodeJWTService
|
|||||||
/**
|
/**
|
||||||
* Generate a new JWT for a given node.
|
* Generate a new JWT for a given node.
|
||||||
*/
|
*/
|
||||||
public function handle(Node $node, ?string $identifiedBy, string $algo = 'md5'): Plain
|
public function handle(Node $node, ?string $identifiedBy, string $algo = 'md5'): UnencryptedToken
|
||||||
{
|
{
|
||||||
$identifier = hash($algo, $identifiedBy);
|
$identifier = hash($algo, $identifiedBy);
|
||||||
$config = Configuration::forSymmetricSigner(new Sha256(), InMemory::plainText($node->getDecryptedKey()));
|
$config = Configuration::forSymmetricSigner(new Sha256(), InMemory::plainText($node->getDecryptedKey()));
|
||||||
@ -73,7 +73,7 @@ class NodeJWTService
|
|||||||
->issuedAt(CarbonImmutable::now())
|
->issuedAt(CarbonImmutable::now())
|
||||||
->canOnlyBeUsedAfter(CarbonImmutable::now()->subMinutes(5));
|
->canOnlyBeUsedAfter(CarbonImmutable::now()->subMinutes(5));
|
||||||
|
|
||||||
if ($this->expiresAt) {
|
if (isset($this->expiresAt)) {
|
||||||
$builder = $builder->expiresAt($this->expiresAt);
|
$builder = $builder->expiresAt($this->expiresAt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,9 +27,7 @@ class ProcessScheduleService
|
|||||||
*/
|
*/
|
||||||
public function handle(Schedule $schedule, bool $now = false): void
|
public function handle(Schedule $schedule, bool $now = false): void
|
||||||
{
|
{
|
||||||
/** @var \Pterodactyl\Models\Task $task */
|
|
||||||
$task = $schedule->tasks()->orderBy('sequence_id')->first();
|
$task = $schedule->tasks()->orderBy('sequence_id')->first();
|
||||||
|
|
||||||
if (is_null($task)) {
|
if (is_null($task)) {
|
||||||
throw new DisplayException('Cannot process schedule for task execution: no tasks are registered.');
|
throw new DisplayException('Cannot process schedule for task execution: no tasks are registered.');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,7 +95,7 @@ class BuildModificationService
|
|||||||
|
|
||||||
// Keep track of all the allocations we're just now adding so that we can use the first
|
// Keep track of all the allocations we're just now adding so that we can use the first
|
||||||
// one to reset the default allocation to.
|
// one to reset the default allocation to.
|
||||||
$freshlyAllocated = $query->pluck('id')->first();
|
$freshlyAllocated = $query->pluck('id')->first(); // @phpstan-ignore larastan.noUnnecessaryCollectionCall
|
||||||
|
|
||||||
$query->update(['server_id' => $server->id, 'notes' => null]);
|
$query->update(['server_id' => $server->id, 'notes' => null]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,6 +36,6 @@ class UserDeletionService
|
|||||||
throw new DisplayException($this->translator->get('admin/user.exceptions.user_has_servers'));
|
throw new DisplayException($this->translator->get('admin/user.exceptions.user_has_servers'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->repository->delete($user);
|
return $this->repository->delete($user); // @phpstan-ignore return.type (this has been like this, unsure at the moment what is truly correct)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Pterodactyl\Traits\Controllers;
|
|
||||||
|
|
||||||
use JavaScript;
|
|
||||||
|
|
||||||
trait PlainJavascriptInjection
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Injects statistics into javascript.
|
|
||||||
*/
|
|
||||||
public function injectJavascript($data)
|
|
||||||
{
|
|
||||||
\JavaScript::put($data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -50,7 +50,7 @@ abstract class BaseTransformer extends TransformerAbstract
|
|||||||
/**
|
/**
|
||||||
* Returns a new transformer instance with the request set on the instance.
|
* Returns a new transformer instance with the request set on the instance.
|
||||||
*/
|
*/
|
||||||
public static function fromRequest(Request $request): BaseTransformer
|
public static function fromRequest(Request $request): static
|
||||||
{
|
{
|
||||||
return app(static::class)->setRequest($request);
|
return app(static::class)->setRequest($request);
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ abstract class BaseTransformer extends TransformerAbstract
|
|||||||
{
|
{
|
||||||
$allowed = [ApiKey::TYPE_ACCOUNT, ApiKey::TYPE_APPLICATION];
|
$allowed = [ApiKey::TYPE_ACCOUNT, ApiKey::TYPE_APPLICATION];
|
||||||
|
|
||||||
$token = $this->request->user()->currentAccessToken();
|
$token = $this->request->user()?->currentAccessToken();
|
||||||
if (!$token instanceof ApiKey || !in_array($token->key_type, $allowed)) {
|
if (!$token instanceof ApiKey || !in_array($token->key_type, $allowed)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ abstract class BaseTransformer extends TransformerAbstract
|
|||||||
*/
|
*/
|
||||||
protected function makeTransformer(string $abstract)
|
protected function makeTransformer(string $abstract)
|
||||||
{
|
{
|
||||||
Assert::subclassOf($abstract, self::class);
|
Assert::subclassOf($abstract, self::class); // @phpstan-ignore staticMethod.alreadyNarrowedType
|
||||||
|
|
||||||
return $abstract::fromRequest($this->request);
|
return $abstract::fromRequest($this->request);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ namespace Pterodactyl\Transformers\Api\Application;
|
|||||||
|
|
||||||
use League\Fractal\Resource\Item;
|
use League\Fractal\Resource\Item;
|
||||||
use Pterodactyl\Models\EggVariable;
|
use Pterodactyl\Models\EggVariable;
|
||||||
|
use Pterodactyl\Models\ServerVariable;
|
||||||
use League\Fractal\Resource\NullResource;
|
use League\Fractal\Resource\NullResource;
|
||||||
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user