This breaks literally the entire panel.
This commit is contained in:
parent
344c1a9885
commit
df87ea0867
88 changed files with 1205 additions and 992 deletions
|
@ -9,33 +9,33 @@
|
|||
|
||||
namespace Pterodactyl\Repositories\Eloquent;
|
||||
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Webmozart\Assert\Assert;
|
||||
use Pterodactyl\Models\ServiceOption;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
|
||||
use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface;
|
||||
|
||||
class ServiceOptionRepository extends EloquentRepository implements ServiceOptionRepositoryInterface
|
||||
class EggRepository extends EloquentRepository implements EggRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function model()
|
||||
{
|
||||
return ServiceOption::class;
|
||||
return Egg::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a service option with the variables relation attached.
|
||||
* Return an egg with the variables relation attached.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Pterodactyl\Models\ServiceOption
|
||||
* @return \Pterodactyl\Models\Egg
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithVariables(int $id): ServiceOption
|
||||
public function getWithVariables(int $id): Egg
|
||||
{
|
||||
/** @var \Pterodactyl\Models\ServiceOption $instance */
|
||||
/** @var \Pterodactyl\Models\Egg $instance */
|
||||
$instance = $this->getBuilder()->with('variables')->find($id, $this->getColumns());
|
||||
if (! $instance) {
|
||||
throw new RecordNotFoundException;
|
||||
|
@ -45,7 +45,7 @@ class ServiceOptionRepository extends EloquentRepository implements ServiceOptio
|
|||
}
|
||||
|
||||
/**
|
||||
* Return all of the service options and their relations to be used in the daemon API.
|
||||
* Return all eggs and their relations to be used in the daemon API.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
|
@ -55,19 +55,19 @@ class ServiceOptionRepository extends EloquentRepository implements ServiceOptio
|
|||
}
|
||||
|
||||
/**
|
||||
* Return a service option with the scriptFrom and configFrom relations loaded onto the model.
|
||||
* Return an egg with the scriptFrom and configFrom relations loaded onto the model.
|
||||
*
|
||||
* @param int|string $value
|
||||
* @param string $column
|
||||
* @return \Pterodactyl\Models\ServiceOption
|
||||
* @return \Pterodactyl\Models\Egg
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithCopyAttributes($value, string $column = 'id'): ServiceOption
|
||||
public function getWithCopyAttributes($value, string $column = 'id'): Egg
|
||||
{
|
||||
Assert::true((is_digit($value) || is_string($value)), 'First argument passed to getWithCopyAttributes must be an integer or string, received %s.');
|
||||
|
||||
/** @var \Pterodactyl\Models\ServiceOption $instance */
|
||||
/** @var \Pterodactyl\Models\Egg $instance */
|
||||
$instance = $this->getBuilder()->with('scriptFrom', 'configFrom')->where($column, '=', $value)->first($this->getColumns());
|
||||
if (! $instance) {
|
||||
throw new RecordNotFoundException;
|
||||
|
@ -80,13 +80,13 @@ class ServiceOptionRepository extends EloquentRepository implements ServiceOptio
|
|||
* Return all of the data needed to export a service.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Pterodactyl\Models\ServiceOption
|
||||
* @return \Pterodactyl\Models\Egg
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithExportAttributes(int $id): ServiceOption
|
||||
public function getWithExportAttributes(int $id): Egg
|
||||
{
|
||||
/** @var \Pterodactyl\Models\ServiceOption $instance */
|
||||
/** @var \Pterodactyl\Models\Egg $instance */
|
||||
$instance = $this->getBuilder()->with('scriptFrom', 'configFrom', 'variables')->find($id, $this->getColumns());
|
||||
if (! $instance) {
|
||||
throw new RecordNotFoundException;
|
||||
|
@ -96,7 +96,7 @@ class ServiceOptionRepository extends EloquentRepository implements ServiceOptio
|
|||
}
|
||||
|
||||
/**
|
||||
* Confirm a copy script belongs to the same service as the item trying to use it.
|
||||
* Confirm a copy script belongs to the same nest as the item trying to use it.
|
||||
*
|
||||
* @param int $copyFromId
|
||||
* @param int $service
|
||||
|
@ -106,7 +106,7 @@ class ServiceOptionRepository extends EloquentRepository implements ServiceOptio
|
|||
{
|
||||
return $this->getBuilder()->whereNull('copy_script_from')
|
||||
->where('id', '=', $copyFromId)
|
||||
->where('service_id', '=', $service)
|
||||
->where('nest_id', '=', $service)
|
||||
->exists();
|
||||
}
|
||||
}
|
|
@ -9,16 +9,16 @@
|
|||
|
||||
namespace Pterodactyl\Repositories\Eloquent;
|
||||
|
||||
use Pterodactyl\Models\ServiceVariable;
|
||||
use Pterodactyl\Contracts\Repository\OptionVariableRepositoryInterface;
|
||||
use Pterodactyl\Models\EggVariable;
|
||||
use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface;
|
||||
|
||||
class OptionVariableRepository extends EloquentRepository implements OptionVariableRepositoryInterface
|
||||
class EggVariableRepository extends EloquentRepository implements EggVariableRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function model()
|
||||
{
|
||||
return ServiceVariable::class;
|
||||
return EggVariable::class;
|
||||
}
|
||||
}
|
|
@ -9,31 +9,31 @@
|
|||
|
||||
namespace Pterodactyl\Repositories\Eloquent;
|
||||
|
||||
use Pterodactyl\Models\Service;
|
||||
use Pterodactyl\Models\Nest;
|
||||
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
|
||||
use Pterodactyl\Contracts\Repository\ServiceRepositoryInterface;
|
||||
|
||||
class ServiceRepository extends EloquentRepository implements ServiceRepositoryInterface
|
||||
class NestRepository extends EloquentRepository implements NestRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function model()
|
||||
{
|
||||
return Service::class;
|
||||
return Nest::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a service or all services with their associated options, variables, and packs.
|
||||
* Return a nest or all nests with their associated eggs, variables, and packs.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Service
|
||||
* @return \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Nest
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithOptions(int $id = null)
|
||||
public function getWithEggs(int $id = null)
|
||||
{
|
||||
$instance = $this->getBuilder()->with('options.packs', 'options.variables');
|
||||
$instance = $this->getBuilder()->with('eggs.packs', 'eggs.variables');
|
||||
|
||||
if (! is_null($id)) {
|
||||
$instance = $instance->find($id, $this->getColumns());
|
||||
|
@ -48,16 +48,16 @@ class ServiceRepository extends EloquentRepository implements ServiceRepositoryI
|
|||
}
|
||||
|
||||
/**
|
||||
* Return a service or all services and the count of options, packs, and servers for that service.
|
||||
* Return a nest or all nests and the count of eggs, packs, and servers for that nest.
|
||||
*
|
||||
* @param int|null $id
|
||||
* @return \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Service
|
||||
* @return \Pterodactyl\Models\Nest|\Illuminate\Database\Eloquent\Collection
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithCounts(int $id = null)
|
||||
{
|
||||
$instance = $this->getBuilder()->withCount(['options', 'packs', 'servers']);
|
||||
$instance = $this->getBuilder()->withCount(['eggs', 'packs', 'servers']);
|
||||
|
||||
if (! is_null($id)) {
|
||||
$instance = $instance->find($id, $this->getColumns());
|
||||
|
@ -72,21 +72,21 @@ class ServiceRepository extends EloquentRepository implements ServiceRepositoryI
|
|||
}
|
||||
|
||||
/**
|
||||
* Return a service along with its associated options and the servers relation on those options.
|
||||
* Return a nest along with its associated eggs and the servers relation on those eggs.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Pterodactyl\Models\Service
|
||||
* @return \Pterodactyl\Models\Nest
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithOptionServers(int $id): Service
|
||||
public function getWithEggServers(int $id): Nest
|
||||
{
|
||||
$instance = $this->getBuilder()->with('options.servers')->find($id, $this->getColumns());
|
||||
$instance = $this->getBuilder()->with('eggs.servers')->find($id, $this->getColumns());
|
||||
if (! $instance) {
|
||||
throw new RecordNotFoundException;
|
||||
}
|
||||
|
||||
/* @var Service $instance */
|
||||
/* @var Nest $instance */
|
||||
return $instance;
|
||||
}
|
||||
}
|
|
@ -116,7 +116,7 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa
|
|||
*/
|
||||
public function getNodeServers($id)
|
||||
{
|
||||
$instance = $this->getBuilder()->with('servers.user', 'servers.service', 'servers.option')
|
||||
$instance = $this->getBuilder()->with('servers.user', 'servers.nest', 'servers.egg')
|
||||
->find($id, $this->getColumns());
|
||||
|
||||
if (! $instance) {
|
||||
|
|
|
@ -75,11 +75,11 @@ class PackRepository extends EloquentRepository implements PackRepositoryInterfa
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function paginateWithOptionAndServerCount($paginate = 50)
|
||||
public function paginateWithEggAndServerCount($paginate = 50)
|
||||
{
|
||||
Assert::integer($paginate, 'First argument passed to paginateWithOptionAndServerCount must be integer, received %s.');
|
||||
|
||||
return $this->getBuilder()->with('option')->withCount('servers')
|
||||
return $this->getBuilder()->with('egg')->withCount('servers')
|
||||
->search($this->searchTerm)
|
||||
->paginate($paginate, $this->getColumns());
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
|||
Assert::nullOrIntegerish($server, 'First argument passed to getDataForRebuild must be null or integer, received %s.');
|
||||
Assert::nullOrIntegerish($node, 'Second argument passed to getDataForRebuild must be null or integer, received %s.');
|
||||
|
||||
$instance = $this->getBuilder()->with('allocation', 'allocations', 'pack', 'option', 'node');
|
||||
$instance = $this->getBuilder()->with('allocation', 'allocations', 'pack', 'egg', 'node');
|
||||
|
||||
if (! is_null($server) && is_null($node)) {
|
||||
$instance = $instance->where('id', '=', $server);
|
||||
|
@ -66,7 +66,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
|||
{
|
||||
Assert::integerish($id, 'First argument passed to findWithVariables must be integer, received %s.');
|
||||
|
||||
$instance = $this->getBuilder()->with('option.variables', 'variables')
|
||||
$instance = $this->getBuilder()->with('egg.variables', 'variables')
|
||||
->where($this->getModel()->getKeyName(), '=', $id)
|
||||
->first($this->getColumns());
|
||||
|
||||
|
@ -82,7 +82,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
|||
*/
|
||||
public function getVariablesWithValues($id, $returnWithObject = false)
|
||||
{
|
||||
$instance = $this->getBuilder()->with('variables', 'option.variables')
|
||||
$instance = $this->getBuilder()->with('variables', 'egg.variables')
|
||||
->find($id, $this->getColumns());
|
||||
|
||||
if (! $instance) {
|
||||
|
@ -90,7 +90,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
|||
}
|
||||
|
||||
$data = [];
|
||||
$instance->option->variables->each(function ($item) use (&$data, $instance) {
|
||||
$instance->egg->variables->each(function ($item) use (&$data, $instance) {
|
||||
$display = $instance->variables->where('variable_id', $item->id)->pluck('variable_value')->first();
|
||||
|
||||
$data[$item->env_variable] = $display ?? $item->default_value;
|
||||
|
@ -111,7 +111,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
|||
*/
|
||||
public function getDataForCreation($id)
|
||||
{
|
||||
$instance = $this->getBuilder()->with(['allocation', 'allocations', 'pack', 'option'])->find($id, $this->getColumns());
|
||||
$instance = $this->getBuilder()->with(['allocation', 'allocations', 'pack', 'egg'])->find($id, $this->getColumns());
|
||||
if (! $instance) {
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
|
@ -140,15 +140,15 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
|||
*/
|
||||
public function getDaemonServiceData($id)
|
||||
{
|
||||
$instance = $this->getBuilder()->with('option.service', 'pack')->find($id, $this->getColumns());
|
||||
$instance = $this->getBuilder()->with('egg.nest', 'pack')->find($id, $this->getColumns());
|
||||
|
||||
if (! $instance) {
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
|
||||
return [
|
||||
'type' => $instance->option->service->folder,
|
||||
'option' => $instance->option->tag,
|
||||
'type' => $instance->egg->nest->folder,
|
||||
'option' => $instance->egg->tag,
|
||||
'pack' => (! is_null($instance->pack_id)) ? $instance->pack->uuid : null,
|
||||
];
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
|||
{
|
||||
Assert::stringNotEmpty($uuid, 'First argument passed to getByUuid must be a non-empty string, received %s.');
|
||||
|
||||
$instance = $this->getBuilder()->with('service', 'node')->where(function ($query) use ($uuid) {
|
||||
$instance = $this->getBuilder()->with('nest', 'node')->where(function ($query) use ($uuid) {
|
||||
$query->where('uuidShort', $uuid)->orWhere('uuid', $uuid);
|
||||
})->first($this->getColumns());
|
||||
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Repositories\Eloquent;
|
||||
|
||||
use Pterodactyl\Models\ServiceVariable;
|
||||
use Pterodactyl\Contracts\Repository\ServiceVariableRepositoryInterface;
|
||||
|
||||
class ServiceVariableRepository extends EloquentRepository implements ServiceVariableRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function model()
|
||||
{
|
||||
return ServiceVariable::class;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue