Use more standardized phpcs
This commit is contained in:
parent
a043071e3c
commit
c449ca5155
493 changed files with 1116 additions and 3903 deletions
|
@ -21,9 +21,6 @@ class AllocationRepository extends EloquentRepository implements AllocationRepos
|
|||
/**
|
||||
* Return all of the allocations that exist for a node that are not currently
|
||||
* allocated.
|
||||
*
|
||||
* @param int $node
|
||||
* @return array
|
||||
*/
|
||||
public function getUnassignedAllocationIds(int $node): array
|
||||
{
|
||||
|
@ -42,15 +39,12 @@ class AllocationRepository extends EloquentRepository implements AllocationRepos
|
|||
*
|
||||
* If an array of nodes is passed the results will be limited to allocations
|
||||
* in those nodes.
|
||||
*
|
||||
* @param array $nodes
|
||||
* @return array
|
||||
*/
|
||||
protected function getDiscardableDedicatedAllocations(array $nodes = []): array
|
||||
{
|
||||
$query = Allocation::query()->selectRaw('CONCAT_WS("-", node_id, ip) as result');
|
||||
|
||||
if (! empty($nodes)) {
|
||||
if (!empty($nodes)) {
|
||||
$query->whereIn('node_id', $nodes);
|
||||
}
|
||||
|
||||
|
@ -64,20 +58,17 @@ class AllocationRepository extends EloquentRepository implements AllocationRepos
|
|||
/**
|
||||
* Return a single allocation from those meeting the requirements.
|
||||
*
|
||||
* @param array $nodes
|
||||
* @param array $ports
|
||||
* @param bool $dedicated
|
||||
* @return \Pterodactyl\Models\Allocation|null
|
||||
*/
|
||||
public function getRandomAllocation(array $nodes, array $ports, bool $dedicated = false)
|
||||
{
|
||||
$query = Allocation::query()->whereNull('server_id');
|
||||
|
||||
if (! empty($nodes)) {
|
||||
if (!empty($nodes)) {
|
||||
$query->whereIn('node_id', $nodes);
|
||||
}
|
||||
|
||||
if (! empty($ports)) {
|
||||
if (!empty($ports)) {
|
||||
$query->where(function (Builder $inner) use ($ports) {
|
||||
$whereIn = [];
|
||||
foreach ($ports as $port) {
|
||||
|
@ -89,7 +80,7 @@ class AllocationRepository extends EloquentRepository implements AllocationRepos
|
|||
$whereIn[] = $port;
|
||||
}
|
||||
|
||||
if (! empty($whereIn)) {
|
||||
if (!empty($whereIn)) {
|
||||
$inner->orWhereIn('port', $whereIn);
|
||||
}
|
||||
});
|
||||
|
@ -100,9 +91,10 @@ class AllocationRepository extends EloquentRepository implements AllocationRepos
|
|||
if ($dedicated) {
|
||||
$discard = $this->getDiscardableDedicatedAllocations($nodes);
|
||||
|
||||
if (! empty($discard)) {
|
||||
if (!empty($discard)) {
|
||||
$query->whereNotIn(
|
||||
$this->getBuilder()->raw('CONCAT_WS("-", node_id, ip)'), $discard
|
||||
$this->getBuilder()->raw('CONCAT_WS("-", node_id, ip)'),
|
||||
$discard
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,6 @@ class ApiKeyRepository extends EloquentRepository implements ApiKeyRepositoryInt
|
|||
|
||||
/**
|
||||
* Get all of the account API keys that exist for a specific user.
|
||||
*
|
||||
* @param \Pterodactyl\Models\User $user
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getAccountKeys(User $user): Collection
|
||||
{
|
||||
|
@ -34,9 +31,6 @@ class ApiKeyRepository extends EloquentRepository implements ApiKeyRepositoryInt
|
|||
|
||||
/**
|
||||
* Get all of the application API keys that exist for a specific user.
|
||||
*
|
||||
* @param \Pterodactyl\Models\User $user
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getApplicationKeys(User $user): Collection
|
||||
{
|
||||
|
@ -47,10 +41,6 @@ class ApiKeyRepository extends EloquentRepository implements ApiKeyRepositoryInt
|
|||
|
||||
/**
|
||||
* Delete an account API key from the panel for a specific user.
|
||||
*
|
||||
* @param \Pterodactyl\Models\User $user
|
||||
* @param string $identifier
|
||||
* @return int
|
||||
*/
|
||||
public function deleteAccountKey(User $user, string $identifier): int
|
||||
{
|
||||
|
@ -62,10 +52,6 @@ class ApiKeyRepository extends EloquentRepository implements ApiKeyRepositoryInt
|
|||
|
||||
/**
|
||||
* Delete an application API key from the panel for a specific user.
|
||||
*
|
||||
* @param \Pterodactyl\Models\User $user
|
||||
* @param string $identifier
|
||||
* @return int
|
||||
*/
|
||||
public function deleteApplicationKey(User $user, string $identifier): int
|
||||
{
|
||||
|
|
|
@ -18,8 +18,6 @@ class BackupRepository extends EloquentRepository
|
|||
/**
|
||||
* Determines if too many backups have been generated by the server.
|
||||
*
|
||||
* @param int $server
|
||||
* @param int $seconds
|
||||
* @return \Pterodactyl\Models\Backup[]|\Illuminate\Support\Collection
|
||||
*/
|
||||
public function getBackupsGeneratedDuringTimespan(int $server, int $seconds = 600)
|
||||
|
|
|
@ -21,8 +21,6 @@ class DatabaseHostRepository extends EloquentRepository implements DatabaseHostR
|
|||
/**
|
||||
* Return database hosts with a count of databases and the node
|
||||
* information for which it is attached.
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getWithViewDetails(): Collection
|
||||
{
|
||||
|
|
|
@ -23,9 +23,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor
|
|||
|
||||
/**
|
||||
* DatabaseRepository constructor.
|
||||
*
|
||||
* @param \Illuminate\Foundation\Application $application
|
||||
* @param \Illuminate\Database\DatabaseManager $database
|
||||
*/
|
||||
public function __construct(Application $application, DatabaseManager $database)
|
||||
{
|
||||
|
@ -47,7 +44,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor
|
|||
/**
|
||||
* Set the connection name to execute statements against.
|
||||
*
|
||||
* @param string $connection
|
||||
* @return $this
|
||||
*/
|
||||
public function setConnection(string $connection)
|
||||
|
@ -59,8 +55,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor
|
|||
|
||||
/**
|
||||
* Return the connection to execute statements against.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getConnection(): string
|
||||
{
|
||||
|
@ -69,9 +63,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor
|
|||
|
||||
/**
|
||||
* Return all of the databases belonging to a server.
|
||||
*
|
||||
* @param int $server
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getDatabasesForServer(int $server): Collection
|
||||
{
|
||||
|
@ -80,10 +71,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor
|
|||
|
||||
/**
|
||||
* Return all of the databases for a given host with the server relationship loaded.
|
||||
*
|
||||
* @param int $host
|
||||
* @param int $count
|
||||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
*/
|
||||
public function getDatabasesForHost(int $host, int $count = 25): LengthAwarePaginator
|
||||
{
|
||||
|
@ -94,9 +81,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor
|
|||
|
||||
/**
|
||||
* Create a new database on a given connection.
|
||||
*
|
||||
* @param string $database
|
||||
* @return bool
|
||||
*/
|
||||
public function createDatabase(string $database): bool
|
||||
{
|
||||
|
@ -106,15 +90,11 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor
|
|||
/**
|
||||
* Create a new database user on a given connection.
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $remote
|
||||
* @param string $password
|
||||
* @param $max_connections
|
||||
* @return bool
|
||||
*/
|
||||
public function createUser(string $username, string $remote, string $password, $max_connections): bool
|
||||
{
|
||||
if (! $max_connections) {
|
||||
if (!$max_connections) {
|
||||
return $this->run(sprintf('CREATE USER `%s`@`%s` IDENTIFIED BY \'%s\'', $username, $remote, $password));
|
||||
} else {
|
||||
return $this->run(sprintf('CREATE USER `%s`@`%s` IDENTIFIED BY \'%s\' WITH MAX_USER_CONNECTIONS %s', $username, $remote, $password, $max_connections));
|
||||
|
@ -123,11 +103,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor
|
|||
|
||||
/**
|
||||
* Give a specific user access to a given database.
|
||||
*
|
||||
* @param string $database
|
||||
* @param string $username
|
||||
* @param string $remote
|
||||
* @return bool
|
||||
*/
|
||||
public function assignUserToDatabase(string $database, string $username, string $remote): bool
|
||||
{
|
||||
|
@ -141,8 +116,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor
|
|||
|
||||
/**
|
||||
* Flush the privileges for a given connection.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function flush(): bool
|
||||
{
|
||||
|
@ -151,9 +124,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor
|
|||
|
||||
/**
|
||||
* Drop a given database on a specific connection.
|
||||
*
|
||||
* @param string $database
|
||||
* @return bool
|
||||
*/
|
||||
public function dropDatabase(string $database): bool
|
||||
{
|
||||
|
@ -163,8 +133,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor
|
|||
/**
|
||||
* Drop a given user on a specific connection.
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $remote
|
||||
* @return mixed
|
||||
*/
|
||||
public function dropUser(string $username, string $remote): bool
|
||||
|
@ -174,9 +142,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor
|
|||
|
||||
/**
|
||||
* Run the provided statement against the database on a given connection.
|
||||
*
|
||||
* @param string $statement
|
||||
* @return bool
|
||||
*/
|
||||
private function run(string $statement): bool
|
||||
{
|
||||
|
|
|
@ -24,9 +24,6 @@ class EggRepository extends EloquentRepository implements EggRepositoryInterface
|
|||
/**
|
||||
* Return an egg with the variables relation attached.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Pterodactyl\Models\Egg
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithVariables(int $id): Egg
|
||||
|
@ -34,14 +31,12 @@ class EggRepository extends EloquentRepository implements EggRepositoryInterface
|
|||
try {
|
||||
return $this->getBuilder()->with('variables')->findOrFail($id, $this->getColumns());
|
||||
} catch (ModelNotFoundException $exception) {
|
||||
throw new RecordNotFoundException;
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all eggs and their relations to be used in the daemon API.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
public function getAllWithCopyAttributes(): Collection
|
||||
{
|
||||
|
@ -52,8 +47,6 @@ class EggRepository extends EloquentRepository implements EggRepositoryInterface
|
|||
* Return an egg with the scriptFrom and configFrom relations loaded onto the model.
|
||||
*
|
||||
* @param int|string $value
|
||||
* @param string $column
|
||||
* @return \Pterodactyl\Models\Egg
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
|
@ -64,16 +57,13 @@ class EggRepository extends EloquentRepository implements EggRepositoryInterface
|
|||
try {
|
||||
return $this->getBuilder()->with('scriptFrom', 'configFrom')->where($column, '=', $value)->firstOrFail($this->getColumns());
|
||||
} catch (ModelNotFoundException $exception) {
|
||||
throw new RecordNotFoundException;
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all of the data needed to export a service.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Pterodactyl\Models\Egg
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithExportAttributes(int $id): Egg
|
||||
|
@ -81,16 +71,12 @@ class EggRepository extends EloquentRepository implements EggRepositoryInterface
|
|||
try {
|
||||
return $this->getBuilder()->with('scriptFrom', 'configFrom', 'variables')->findOrFail($id, $this->getColumns());
|
||||
} catch (ModelNotFoundException $exception) {
|
||||
throw new RecordNotFoundException;
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm a copy script belongs to the same nest as the item trying to use it.
|
||||
*
|
||||
* @param int $copyFromId
|
||||
* @param int $service
|
||||
* @return bool
|
||||
*/
|
||||
public function isCopyableScript(int $copyFromId, int $service): bool
|
||||
{
|
||||
|
|
|
@ -21,9 +21,6 @@ class EggVariableRepository extends EloquentRepository implements EggVariableRep
|
|||
/**
|
||||
* Return editable variables for a given egg. Editable variables must be set to
|
||||
* user viewable in order to be picked up by this function.
|
||||
*
|
||||
* @param int $egg
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getEditableVariables(int $egg): Collection
|
||||
{
|
||||
|
|
|
@ -27,6 +27,7 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
* context's such that we can pass through ?filter[name]=Dane&sort=desc for example.
|
||||
*
|
||||
* @param bool $usingFilters
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function usingRequestFilters($usingFilters = true)
|
||||
|
@ -49,14 +50,11 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
/**
|
||||
* Paginate the response data based on the page para.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $instance
|
||||
* @param int $default
|
||||
*
|
||||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
*/
|
||||
protected function paginate(Builder $instance, int $default = 50)
|
||||
{
|
||||
if (! $this->useRequestFilters) {
|
||||
if (!$this->useRequestFilters) {
|
||||
return $instance->paginate($default);
|
||||
}
|
||||
|
||||
|
@ -87,9 +85,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
/**
|
||||
* Create a new record in the database and return the associated model.
|
||||
*
|
||||
* @param array $fields
|
||||
* @param bool $validate
|
||||
* @param bool $force
|
||||
* @return \Illuminate\Database\Eloquent\Model|bool
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
|
@ -99,10 +94,10 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
$instance = $this->getBuilder()->newModelInstance();
|
||||
($force) ? $instance->forceFill($fields) : $instance->fill($fields);
|
||||
|
||||
if (! $validate) {
|
||||
if (!$validate) {
|
||||
$saved = $instance->skipValidation()->save();
|
||||
} else {
|
||||
if (! $saved = $instance->save()) {
|
||||
if (!$saved = $instance->save()) {
|
||||
throw new DataValidationException($instance->getValidator());
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +108,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
/**
|
||||
* Find a model that has the specific ID passed.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
|
@ -123,15 +117,12 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
try {
|
||||
return $this->getBuilder()->findOrFail($id, $this->getColumns());
|
||||
} catch (ModelNotFoundException $exception) {
|
||||
throw new RecordNotFoundException;
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a model matching an array of where clauses.
|
||||
*
|
||||
* @param array $fields
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function findWhere(array $fields): Collection
|
||||
{
|
||||
|
@ -141,7 +132,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
/**
|
||||
* Find and return the first matching instance for the given fields.
|
||||
*
|
||||
* @param array $fields
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
|
@ -151,15 +141,12 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
try {
|
||||
return $this->getBuilder()->where($fields)->firstOrFail($this->getColumns());
|
||||
} catch (ModelNotFoundException $exception) {
|
||||
throw new RecordNotFoundException;
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a count of records matching the passed arguments.
|
||||
*
|
||||
* @param array $fields
|
||||
* @return int
|
||||
*/
|
||||
public function findCountWhere(array $fields): int
|
||||
{
|
||||
|
@ -168,10 +155,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
|
||||
/**
|
||||
* Delete a given record from the database.
|
||||
*
|
||||
* @param int $id
|
||||
* @param bool $destroy
|
||||
* @return int
|
||||
*/
|
||||
public function delete(int $id, bool $destroy = false): int
|
||||
{
|
||||
|
@ -180,10 +163,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
|
||||
/**
|
||||
* Delete records matching the given attributes.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @param bool $force
|
||||
* @return int
|
||||
*/
|
||||
public function deleteWhere(array $attributes, bool $force = false): int
|
||||
{
|
||||
|
@ -196,9 +175,7 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
* Update a given ID with the passed array of fields.
|
||||
*
|
||||
* @param int $id
|
||||
* @param array $fields
|
||||
* @param bool $validate
|
||||
* @param bool $force
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Model|bool
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
|
@ -209,15 +186,15 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
try {
|
||||
$instance = $this->getBuilder()->where('id', $id)->firstOrFail();
|
||||
} catch (ModelNotFoundException $exception) {
|
||||
throw new RecordNotFoundException;
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
|
||||
($force) ? $instance->forceFill($fields) : $instance->fill($fields);
|
||||
|
||||
if (! $validate) {
|
||||
if (!$validate) {
|
||||
$saved = $instance->skipValidation()->save();
|
||||
} else {
|
||||
if (! $saved = $instance->save()) {
|
||||
if (!$saved = $instance->save()) {
|
||||
throw new DataValidationException($instance->getValidator());
|
||||
}
|
||||
}
|
||||
|
@ -229,7 +206,7 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
* Update a model using the attributes passed.
|
||||
*
|
||||
* @param array|\Closure $attributes
|
||||
* @param array $values
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function updateWhere($attributes, array $values)
|
||||
|
@ -240,11 +217,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
/**
|
||||
* Perform a mass update where matching records are updated using whereIn.
|
||||
* This does not perform any model data validation.
|
||||
*
|
||||
* @param string $column
|
||||
* @param array $values
|
||||
* @param array $fields
|
||||
* @return int
|
||||
*/
|
||||
public function updateWhereIn(string $column, array $values, array $fields): int
|
||||
{
|
||||
|
@ -256,10 +228,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
/**
|
||||
* Update a record if it exists in the database, otherwise create it.
|
||||
*
|
||||
* @param array $where
|
||||
* @param array $fields
|
||||
* @param bool $validate
|
||||
* @param bool $force
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
|
@ -283,7 +251,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
/**
|
||||
* Return all records associated with the given model.
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
* @deprecated Just use the model
|
||||
*/
|
||||
public function all(): Collection
|
||||
|
@ -293,9 +260,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
|
||||
/**
|
||||
* Return a paginated result set using a search term if set on the repository.
|
||||
*
|
||||
* @param int $perPage
|
||||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
*/
|
||||
public function paginated(int $perPage): LengthAwarePaginator
|
||||
{
|
||||
|
@ -305,9 +269,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
/**
|
||||
* Insert a single or multiple records into the database at once skipping
|
||||
* validation and mass assignment checking.
|
||||
*
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function insert(array $data): bool
|
||||
{
|
||||
|
@ -316,9 +277,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
|
||||
/**
|
||||
* Insert multiple records into the database and ignore duplicates.
|
||||
*
|
||||
* @param array $values
|
||||
* @return bool
|
||||
*/
|
||||
public function insertIgnore(array $values): bool
|
||||
{
|
||||
|
@ -332,7 +290,7 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
}
|
||||
|
||||
$bindings = array_values(array_filter(array_flatten($values, 1), function ($binding) {
|
||||
return ! $binding instanceof Expression;
|
||||
return !$binding instanceof Expression;
|
||||
}));
|
||||
|
||||
$grammar = $this->getBuilder()->toBase()->getGrammar();
|
||||
|
@ -351,7 +309,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
/**
|
||||
* Get the amount of entries in the database.
|
||||
*
|
||||
* @return int
|
||||
* @deprecated just use the count method off a model
|
||||
*/
|
||||
public function count(): int
|
||||
|
|
|
@ -22,8 +22,6 @@ class LocationRepository extends EloquentRepository implements LocationRepositor
|
|||
|
||||
/**
|
||||
* Return locations with a count of nodes and servers attached to it.
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getAllWithDetails(): Collection
|
||||
{
|
||||
|
@ -32,8 +30,6 @@ class LocationRepository extends EloquentRepository implements LocationRepositor
|
|||
|
||||
/**
|
||||
* Return all of the available locations with the nodes as a relationship.
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getAllWithNodes(): Collection
|
||||
{
|
||||
|
@ -43,7 +39,6 @@ class LocationRepository extends EloquentRepository implements LocationRepositor
|
|||
/**
|
||||
* Return all of the nodes and their respective count of servers for a location.
|
||||
*
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
|
@ -53,14 +48,13 @@ class LocationRepository extends EloquentRepository implements LocationRepositor
|
|||
try {
|
||||
return $this->getBuilder()->with('nodes.servers')->findOrFail($id, $this->getColumns());
|
||||
} catch (ModelNotFoundException $exception) {
|
||||
throw new RecordNotFoundException;
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a location and the count of nodes in that location.
|
||||
*
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
|
@ -70,7 +64,7 @@ class LocationRepository extends EloquentRepository implements LocationRepositor
|
|||
try {
|
||||
return $this->getBuilder()->withCount('nodes')->findOrFail($id, $this->getColumns());
|
||||
} catch (ModelNotFoundException $exception) {
|
||||
throw new RecordNotFoundException;
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,6 @@ class MountRepository extends EloquentRepository
|
|||
|
||||
/**
|
||||
* Return mounts with a count of eggs, nodes, and servers attached to it.
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getAllWithDetails(): Collection
|
||||
{
|
||||
|
@ -33,7 +31,6 @@ class MountRepository extends EloquentRepository
|
|||
/**
|
||||
* Return all of the mounts and their respective relations.
|
||||
*
|
||||
* @param string $id
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
|
@ -43,15 +40,12 @@ class MountRepository extends EloquentRepository
|
|||
try {
|
||||
return $this->getBuilder()->with('eggs', 'nodes')->findOrFail($id, $this->getColumns());
|
||||
} catch (ModelNotFoundException $exception) {
|
||||
throw new RecordNotFoundException;
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return mounts available to a server (ignoring if they are or are not mounted).
|
||||
*
|
||||
* @param Server $server
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getMountListForServer(Server $server): Collection
|
||||
{
|
||||
|
|
|
@ -29,6 +29,7 @@ class NestRepository extends EloquentRepository implements NestRepositoryInterfa
|
|||
* Return a nest or all nests with their associated eggs and variables.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Nest
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
|
@ -37,10 +38,10 @@ class NestRepository extends EloquentRepository implements NestRepositoryInterfa
|
|||
{
|
||||
$instance = $this->getBuilder()->with('eggs', 'eggs.variables');
|
||||
|
||||
if (! is_null($id)) {
|
||||
if (!is_null($id)) {
|
||||
$instance = $instance->find($id, $this->getColumns());
|
||||
if (! $instance) {
|
||||
throw new RecordNotFoundException;
|
||||
if (!$instance) {
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
|
||||
return $instance;
|
||||
|
@ -52,7 +53,6 @@ class NestRepository extends EloquentRepository implements NestRepositoryInterfa
|
|||
/**
|
||||
* Return a nest or all nests and the count of eggs and servers for that nest.
|
||||
*
|
||||
* @param int|null $id
|
||||
* @return \Pterodactyl\Models\Nest|\Illuminate\Database\Eloquent\Collection
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
|
@ -61,10 +61,10 @@ class NestRepository extends EloquentRepository implements NestRepositoryInterfa
|
|||
{
|
||||
$instance = $this->getBuilder()->withCount(['eggs', 'servers']);
|
||||
|
||||
if (! is_null($id)) {
|
||||
if (!is_null($id)) {
|
||||
$instance = $instance->find($id, $this->getColumns());
|
||||
if (! $instance) {
|
||||
throw new RecordNotFoundException;
|
||||
if (!$instance) {
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
|
||||
return $instance;
|
||||
|
@ -76,16 +76,13 @@ class NestRepository extends EloquentRepository implements NestRepositoryInterfa
|
|||
/**
|
||||
* Return a nest along with its associated eggs and the servers relation on those eggs.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Pterodactyl\Models\Nest
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithEggServers(int $id): Nest
|
||||
{
|
||||
$instance = $this->getBuilder()->with('eggs.servers')->find($id, $this->getColumns());
|
||||
if (! $instance) {
|
||||
throw new RecordNotFoundException;
|
||||
if (!$instance) {
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
|
||||
/* @var Nest $instance */
|
||||
|
|
|
@ -20,9 +20,6 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa
|
|||
|
||||
/**
|
||||
* Return the usage stats for a single node.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @return array
|
||||
*/
|
||||
public function getUsageStats(Node $node): array
|
||||
{
|
||||
|
@ -55,9 +52,6 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa
|
|||
|
||||
/**
|
||||
* Return the usage stats for a single node.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @return array
|
||||
*/
|
||||
public function getUsageStatsRaw(Node $node): array
|
||||
{
|
||||
|
@ -82,14 +76,10 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa
|
|||
|
||||
/**
|
||||
* Return a single node with location and server information.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @param bool $refresh
|
||||
* @return \Pterodactyl\Models\Node
|
||||
*/
|
||||
public function loadLocationAndServerCount(Node $node, bool $refresh = false): Node
|
||||
{
|
||||
if (! $node->relationLoaded('location') || $refresh) {
|
||||
if (!$node->relationLoaded('location') || $refresh) {
|
||||
$node->load('location');
|
||||
}
|
||||
|
||||
|
@ -107,14 +97,11 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa
|
|||
/**
|
||||
* Attach a paginated set of allocations to a node mode including
|
||||
* any servers that are also attached to those allocations.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @param bool $refresh
|
||||
* @return \Pterodactyl\Models\Node
|
||||
*/
|
||||
public function loadNodeAllocations(Node $node, bool $refresh = false): Node
|
||||
{
|
||||
$node->setRelation('allocations',
|
||||
$node->setRelation(
|
||||
'allocations',
|
||||
$node->allocations()
|
||||
->orderByRaw('server_id IS NOT NULL DESC, server_id IS NULL')
|
||||
->orderByRaw('INET_ATON(ip) ASC')
|
||||
|
@ -128,8 +115,6 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa
|
|||
|
||||
/**
|
||||
* Return a collection of nodes for all locations to use in server creation UI.
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getNodesForServerCreation(): Collection
|
||||
{
|
||||
|
@ -155,9 +140,6 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa
|
|||
|
||||
/**
|
||||
* Returns a node with the given id with the Node's resource usage.
|
||||
*
|
||||
* @param int $node_id
|
||||
* @return Node
|
||||
*/
|
||||
public function getNodeWithResourceUsage(int $node_id): Node
|
||||
{
|
||||
|
|
|
@ -11,6 +11,7 @@ class PermissionRepository extends EloquentRepository implements PermissionRepos
|
|||
* Return the model backing this repository.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function model()
|
||||
|
|
|
@ -22,9 +22,6 @@ class ScheduleRepository extends EloquentRepository implements ScheduleRepositor
|
|||
|
||||
/**
|
||||
* Return all of the schedules for a given server.
|
||||
*
|
||||
* @param int $server
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function findServerSchedules(int $server): Collection
|
||||
{
|
||||
|
@ -34,9 +31,6 @@ class ScheduleRepository extends EloquentRepository implements ScheduleRepositor
|
|||
/**
|
||||
* Return a schedule model with all of the associated tasks as a relationship.
|
||||
*
|
||||
* @param int $schedule
|
||||
* @return \Pterodactyl\Models\Schedule
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getScheduleWithTasks(int $schedule): Schedule
|
||||
|
@ -44,7 +38,7 @@ class ScheduleRepository extends EloquentRepository implements ScheduleRepositor
|
|||
try {
|
||||
return $this->getBuilder()->with('tasks')->findOrFail($schedule, $this->getColumns());
|
||||
} catch (ModelNotFoundException $exception) {
|
||||
throw new RecordNotFoundException;
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,14 +24,10 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
|||
|
||||
/**
|
||||
* Load the egg relations onto the server model.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @param bool $refresh
|
||||
* @return \Pterodactyl\Models\Server
|
||||
*/
|
||||
public function loadEggRelations(Server $server, bool $refresh = false): Server
|
||||
{
|
||||
if (! $server->relationLoaded('egg') || $refresh) {
|
||||
if (!$server->relationLoaded('egg') || $refresh) {
|
||||
$server->load('egg.scriptFrom');
|
||||
}
|
||||
|
||||
|
@ -40,18 +36,14 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
|||
|
||||
/**
|
||||
* Return a collection of servers with their associated data for rebuild operations.
|
||||
*
|
||||
* @param int|null $server
|
||||
* @param int|null $node
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getDataForRebuild(int $server = null, int $node = null): Collection
|
||||
{
|
||||
$instance = $this->getBuilder()->with(['allocation', 'allocations', 'egg', 'node']);
|
||||
|
||||
if (! is_null($server) && is_null($node)) {
|
||||
if (!is_null($server) && is_null($node)) {
|
||||
$instance = $instance->where('id', '=', $server);
|
||||
} elseif (is_null($server) && ! is_null($node)) {
|
||||
} elseif (is_null($server) && !is_null($node)) {
|
||||
$instance = $instance->where('node_id', '=', $node);
|
||||
}
|
||||
|
||||
|
@ -60,18 +52,14 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
|||
|
||||
/**
|
||||
* Return a collection of servers with their associated data for reinstall operations.
|
||||
*
|
||||
* @param int|null $server
|
||||
* @param int|null $node
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getDataForReinstall(int $server = null, int $node = null): Collection
|
||||
{
|
||||
$instance = $this->getBuilder()->with(['allocation', 'allocations', 'egg', 'node']);
|
||||
|
||||
if (! is_null($server) && is_null($node)) {
|
||||
if (!is_null($server) && is_null($node)) {
|
||||
$instance = $instance->where('id', '=', $server);
|
||||
} elseif (is_null($server) && ! is_null($node)) {
|
||||
} elseif (is_null($server) && !is_null($node)) {
|
||||
$instance = $instance->where('node_id', '=', $node);
|
||||
}
|
||||
|
||||
|
@ -81,9 +69,6 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
|||
/**
|
||||
* Return a server model and all variables associated with the server.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Pterodactyl\Models\Server
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function findWithVariables(int $id): Server
|
||||
|
@ -93,7 +78,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
|||
->where($this->getModel()->getKeyName(), '=', $id)
|
||||
->firstOrFail($this->getColumns());
|
||||
} catch (ModelNotFoundException $exception) {
|
||||
throw new RecordNotFoundException;
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,14 +86,10 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
|||
* Get the primary allocation for a given server. If a model is passed into
|
||||
* the function, load the allocation relationship onto it. Otherwise, find and
|
||||
* return the server from the database.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @param bool $refresh
|
||||
* @return \Pterodactyl\Models\Server
|
||||
*/
|
||||
public function getPrimaryAllocation(Server $server, bool $refresh = false): Server
|
||||
{
|
||||
if (! $server->relationLoaded('allocation') || $refresh) {
|
||||
if (!$server->relationLoaded('allocation') || $refresh) {
|
||||
$server->load('allocation');
|
||||
}
|
||||
|
||||
|
@ -117,15 +98,11 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
|||
|
||||
/**
|
||||
* Return enough data to be used for the creation of a server via the daemon.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @param bool $refresh
|
||||
* @return \Pterodactyl\Models\Server
|
||||
*/
|
||||
public function getDataForCreation(Server $server, bool $refresh = false): Server
|
||||
{
|
||||
foreach (['allocation', 'allocations', 'egg'] as $relation) {
|
||||
if (! $server->relationLoaded($relation) || $refresh) {
|
||||
if (!$server->relationLoaded($relation) || $refresh) {
|
||||
$server->load($relation);
|
||||
}
|
||||
}
|
||||
|
@ -135,14 +112,10 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
|||
|
||||
/**
|
||||
* Load associated databases onto the server model.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @param bool $refresh
|
||||
* @return \Pterodactyl\Models\Server
|
||||
*/
|
||||
public function loadDatabaseRelations(Server $server, bool $refresh = false): Server
|
||||
{
|
||||
if (! $server->relationLoaded('databases') || $refresh) {
|
||||
if (!$server->relationLoaded('databases') || $refresh) {
|
||||
$server->load('databases.host');
|
||||
}
|
||||
|
||||
|
@ -153,14 +126,10 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
|||
* Get data for use when updating a server on the Daemon. Returns an array of
|
||||
* the egg which is used for build and rebuild. Only loads relations
|
||||
* if they are missing, or refresh is set to true.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @param bool $refresh
|
||||
* @return array
|
||||
*/
|
||||
public function getDaemonServiceData(Server $server, bool $refresh = false): array
|
||||
{
|
||||
if (! $server->relationLoaded('egg') || $refresh) {
|
||||
if (!$server->relationLoaded('egg') || $refresh) {
|
||||
$server->load('egg');
|
||||
}
|
||||
|
||||
|
@ -172,9 +141,6 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
|||
/**
|
||||
* Return a server by UUID.
|
||||
*
|
||||
* @param string $uuid
|
||||
* @return \Pterodactyl\Models\Server
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getByUuid(string $uuid): Server
|
||||
|
@ -190,26 +156,20 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
|||
|
||||
return $model;
|
||||
} catch (ModelNotFoundException $exception) {
|
||||
throw new RecordNotFoundException;
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given UUID and UUID-Short string are unique to a server.
|
||||
*
|
||||
* @param string $uuid
|
||||
* @param string $short
|
||||
* @return bool
|
||||
*/
|
||||
public function isUniqueUuidCombo(string $uuid, string $short): bool
|
||||
{
|
||||
return ! $this->getBuilder()->where('uuid', '=', $uuid)->orWhere('uuidShort', '=', $short)->exists();
|
||||
return !$this->getBuilder()->where('uuid', '=', $uuid)->orWhere('uuidShort', '=', $short)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of servers that are suspended.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSuspendedServersCount(): int
|
||||
{
|
||||
|
@ -218,11 +178,6 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
|||
|
||||
/**
|
||||
* Returns all of the servers that exist for a given node in a paginated response.
|
||||
*
|
||||
* @param int $node
|
||||
* @param int $limit
|
||||
*
|
||||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
*/
|
||||
public function loadAllServersForNode(int $node, int $limit): LengthAwarePaginator
|
||||
{
|
||||
|
|
|
@ -20,9 +20,6 @@ class SessionRepository extends EloquentRepository implements SessionRepositoryI
|
|||
|
||||
/**
|
||||
* Return all of the active sessions for a user.
|
||||
*
|
||||
* @param int $user
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getUserSessions(int $user): Collection
|
||||
{
|
||||
|
@ -32,8 +29,6 @@ class SessionRepository extends EloquentRepository implements SessionRepositoryI
|
|||
/**
|
||||
* Delete a session for a given user.
|
||||
*
|
||||
* @param int $user
|
||||
* @param string $session
|
||||
* @return int|null
|
||||
*/
|
||||
public function deleteUserSession(int $user, string $session)
|
||||
|
|
|
@ -30,9 +30,6 @@ class SettingsRepository extends EloquentRepository implements SettingsRepositor
|
|||
/**
|
||||
* Store a new persistent setting in the database.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string|null $value
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
|
@ -48,8 +45,8 @@ class SettingsRepository extends EloquentRepository implements SettingsRepositor
|
|||
/**
|
||||
* Retrieve a persistent setting from the database.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get(string $key, $default = null)
|
||||
|
@ -74,8 +71,6 @@ class SettingsRepository extends EloquentRepository implements SettingsRepositor
|
|||
|
||||
/**
|
||||
* Remove a key from the database cache.
|
||||
*
|
||||
* @param string $key
|
||||
*/
|
||||
public function forget(string $key)
|
||||
{
|
||||
|
@ -85,8 +80,6 @@ class SettingsRepository extends EloquentRepository implements SettingsRepositor
|
|||
|
||||
/**
|
||||
* Remove a key from the cache.
|
||||
*
|
||||
* @param string $key
|
||||
*/
|
||||
private function clearCache(string $key)
|
||||
{
|
||||
|
|
|
@ -20,18 +20,14 @@ class SubuserRepository extends EloquentRepository implements SubuserRepositoryI
|
|||
|
||||
/**
|
||||
* Return a subuser with the associated server relationship.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Subuser $subuser
|
||||
* @param bool $refresh
|
||||
* @return \Pterodactyl\Models\Subuser
|
||||
*/
|
||||
public function loadServerAndUserRelations(Subuser $subuser, bool $refresh = false): Subuser
|
||||
{
|
||||
if (! $subuser->relationLoaded('server') || $refresh) {
|
||||
if (!$subuser->relationLoaded('server') || $refresh) {
|
||||
$subuser->load('server');
|
||||
}
|
||||
|
||||
if (! $subuser->relationLoaded('user') || $refresh) {
|
||||
if (!$subuser->relationLoaded('user') || $refresh) {
|
||||
$subuser->load('user');
|
||||
}
|
||||
|
||||
|
@ -40,18 +36,14 @@ class SubuserRepository extends EloquentRepository implements SubuserRepositoryI
|
|||
|
||||
/**
|
||||
* Return a subuser with the associated permissions relationship.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Subuser $subuser
|
||||
* @param bool $refresh
|
||||
* @return \Pterodactyl\Models\Subuser
|
||||
*/
|
||||
public function getWithPermissions(Subuser $subuser, bool $refresh = false): Subuser
|
||||
{
|
||||
if (! $subuser->relationLoaded('permissions') || $refresh) {
|
||||
if (!$subuser->relationLoaded('permissions') || $refresh) {
|
||||
$subuser->load('permissions');
|
||||
}
|
||||
|
||||
if (! $subuser->relationLoaded('user') || $refresh) {
|
||||
if (!$subuser->relationLoaded('user') || $refresh) {
|
||||
$subuser->load('user');
|
||||
}
|
||||
|
||||
|
@ -61,10 +53,6 @@ class SubuserRepository extends EloquentRepository implements SubuserRepositoryI
|
|||
/**
|
||||
* Return a subuser and associated permissions given a user_id and server_id.
|
||||
*
|
||||
* @param int $user
|
||||
* @param int $server
|
||||
* @return \Pterodactyl\Models\Subuser
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithPermissionsUsingUserAndServer(int $user, int $server): Subuser
|
||||
|
@ -75,7 +63,7 @@ class SubuserRepository extends EloquentRepository implements SubuserRepositoryI
|
|||
])->first();
|
||||
|
||||
if (is_null($instance)) {
|
||||
throw new RecordNotFoundException;
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
|
||||
return $instance;
|
||||
|
|
|
@ -22,9 +22,6 @@ class TaskRepository extends EloquentRepository implements TaskRepositoryInterfa
|
|||
/**
|
||||
* Get a task and the server relationship for that task.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Pterodactyl\Models\Task
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getTaskForJobProcess(int $id): Task
|
||||
|
@ -32,15 +29,13 @@ class TaskRepository extends EloquentRepository implements TaskRepositoryInterfa
|
|||
try {
|
||||
return $this->getBuilder()->with('server.user', 'schedule')->findOrFail($id, $this->getColumns());
|
||||
} catch (ModelNotFoundException $exception) {
|
||||
throw new RecordNotFoundException;
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next task in a schedule.
|
||||
*
|
||||
* @param int $schedule
|
||||
* @param int $index
|
||||
* @return \Pterodactyl\Models\Task|null
|
||||
*/
|
||||
public function getNextTask(int $schedule, int $index)
|
||||
|
|
|
@ -30,8 +30,6 @@ abstract class Repository implements RepositoryInterface
|
|||
|
||||
/**
|
||||
* Repository constructor.
|
||||
*
|
||||
* @param \Illuminate\Foundation\Application $application
|
||||
*/
|
||||
public function __construct(Application $application)
|
||||
{
|
||||
|
@ -61,6 +59,7 @@ abstract class Repository implements RepositoryInterface
|
|||
* Setup column selection functionality.
|
||||
*
|
||||
* @param array|string $columns
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setColumns($columns = ['*'])
|
||||
|
@ -106,7 +105,6 @@ abstract class Repository implements RepositoryInterface
|
|||
* Set whether or not the repository should return a fresh model
|
||||
* when changes are committed.
|
||||
*
|
||||
* @param bool $fresh
|
||||
* @return $this
|
||||
*/
|
||||
public function setFreshModel(bool $fresh = true)
|
||||
|
@ -121,6 +119,7 @@ abstract class Repository implements RepositoryInterface
|
|||
* Take the provided model and make it accessible to the rest of the repository.
|
||||
*
|
||||
* @param array $model
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function initializeModel(...$model)
|
||||
|
|
|
@ -19,7 +19,6 @@ class DaemonBackupRepository extends DaemonRepository
|
|||
/**
|
||||
* Sets the backup adapter for this execution instance.
|
||||
*
|
||||
* @param string $adapter
|
||||
* @return $this
|
||||
*/
|
||||
public function setBackupAdapter(string $adapter)
|
||||
|
@ -32,9 +31,6 @@ class DaemonBackupRepository extends DaemonRepository
|
|||
/**
|
||||
* Tells the remote Daemon to begin generating a backup for the server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Backup $backup
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function backup(Backup $backup): ResponseInterface
|
||||
|
@ -60,8 +56,6 @@ class DaemonBackupRepository extends DaemonRepository
|
|||
/**
|
||||
* Deletes a backup from the daemon.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Backup $backup
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function delete(Backup $backup): ResponseInterface
|
||||
|
|
|
@ -14,7 +14,6 @@ class DaemonCommandRepository extends DaemonRepository
|
|||
* Sends a command or multiple commands to a running server instance.
|
||||
*
|
||||
* @param string|string[] $command
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
|
|
|
@ -11,7 +11,6 @@ class DaemonConfigurationRepository extends DaemonRepository
|
|||
/**
|
||||
* Returns system information from the wings instance.
|
||||
*
|
||||
* @return array
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function getSystemInformation(): array
|
||||
|
@ -30,15 +29,16 @@ class DaemonConfigurationRepository extends DaemonRepository
|
|||
* this instance using a passed-in model. This allows us to change plenty of information
|
||||
* in the model, and still use the old, pre-update model to actually make the HTTP request.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function update(Node $node)
|
||||
{
|
||||
try {
|
||||
return $this->getHttpClient()->post(
|
||||
'/api/update', ['json' => $node->getConfiguration()]
|
||||
'/api/update',
|
||||
['json' => $node->getConfiguration()]
|
||||
);
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
|
|
|
@ -14,9 +14,7 @@ class DaemonFileRepository extends DaemonRepository
|
|||
/**
|
||||
* Return the contents of a given file.
|
||||
*
|
||||
* @param string $path
|
||||
* @param int|null $notLargerThan the maximum content length in bytes
|
||||
* @return string
|
||||
*
|
||||
* @throws \GuzzleHttp\Exception\TransferException
|
||||
* @throws \Pterodactyl\Exceptions\Http\Server\FileSizeTooLargeException
|
||||
|
@ -40,7 +38,7 @@ class DaemonFileRepository extends DaemonRepository
|
|||
$length = (int) $response->getHeader('Content-Length')[0] ?? 0;
|
||||
|
||||
if ($notLargerThan && $length > $notLargerThan) {
|
||||
throw new FileSizeTooLargeException;
|
||||
throw new FileSizeTooLargeException();
|
||||
}
|
||||
|
||||
return $response->getBody()->__toString();
|
||||
|
@ -50,10 +48,6 @@ class DaemonFileRepository extends DaemonRepository
|
|||
* Save new contents to a given file. This works for both creating and updating
|
||||
* a file.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $content
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function putContent(string $path, string $content): ResponseInterface
|
||||
|
@ -76,9 +70,6 @@ class DaemonFileRepository extends DaemonRepository
|
|||
/**
|
||||
* Return a directory listing for a given path.
|
||||
*
|
||||
* @param string $path
|
||||
* @return array
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function getDirectory(string $path): array
|
||||
|
@ -102,10 +93,6 @@ class DaemonFileRepository extends DaemonRepository
|
|||
/**
|
||||
* Creates a new directory for the server in the given $path.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $path
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function createDirectory(string $name, string $path): ResponseInterface
|
||||
|
@ -130,10 +117,6 @@ class DaemonFileRepository extends DaemonRepository
|
|||
/**
|
||||
* Renames or moves a file on the remote machine.
|
||||
*
|
||||
* @param string|null $root
|
||||
* @param array $files
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function renameFiles(?string $root, array $files): ResponseInterface
|
||||
|
@ -158,9 +141,6 @@ class DaemonFileRepository extends DaemonRepository
|
|||
/**
|
||||
* Copy a given file and give it a unique name.
|
||||
*
|
||||
* @param string $location
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function copyFile(string $location): ResponseInterface
|
||||
|
@ -184,10 +164,6 @@ class DaemonFileRepository extends DaemonRepository
|
|||
/**
|
||||
* Delete a file or folder for the server.
|
||||
*
|
||||
* @param string|null $root
|
||||
* @param array $files
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function deleteFiles(?string $root, array $files): ResponseInterface
|
||||
|
@ -212,10 +188,6 @@ class DaemonFileRepository extends DaemonRepository
|
|||
/**
|
||||
* Compress the given files or folders in the given root.
|
||||
*
|
||||
* @param string|null $root
|
||||
* @param array $files
|
||||
* @return array
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function compressFiles(?string $root, array $files): array
|
||||
|
@ -245,10 +217,6 @@ class DaemonFileRepository extends DaemonRepository
|
|||
/**
|
||||
* Decompresses a given archive file.
|
||||
*
|
||||
* @param string|null $root
|
||||
* @param string $file
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function decompressFile(?string $root, string $file): ResponseInterface
|
||||
|
@ -273,10 +241,6 @@ class DaemonFileRepository extends DaemonRepository
|
|||
/**
|
||||
* Chmods the given files.
|
||||
*
|
||||
* @param string|null $root
|
||||
* @param array $files
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function chmodFiles(?string $root, array $files): ResponseInterface
|
||||
|
@ -301,10 +265,6 @@ class DaemonFileRepository extends DaemonRepository
|
|||
/**
|
||||
* Pulls a file from the given URL and saves it to the disk.
|
||||
*
|
||||
* @param string $url
|
||||
* @param string|null $directory
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function pull(string $url, ?string $directory): ResponseInterface
|
||||
|
|
|
@ -13,9 +13,6 @@ class DaemonPowerRepository extends DaemonRepository
|
|||
/**
|
||||
* Sends a power action to the server instance.
|
||||
*
|
||||
* @param string $action
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function send(string $action): ResponseInterface
|
||||
|
|
|
@ -27,8 +27,6 @@ abstract class DaemonRepository
|
|||
|
||||
/**
|
||||
* BaseWingsRepository constructor.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Foundation\Application $application
|
||||
*/
|
||||
public function __construct(Application $application)
|
||||
{
|
||||
|
@ -38,7 +36,6 @@ abstract class DaemonRepository
|
|||
/**
|
||||
* Set the server model this request is stemming from.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return $this
|
||||
*/
|
||||
public function setServer(Server $server)
|
||||
|
@ -53,7 +50,6 @@ abstract class DaemonRepository
|
|||
/**
|
||||
* Set the node model this request is stemming from.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @return $this
|
||||
*/
|
||||
public function setNode(Node $node)
|
||||
|
@ -65,9 +61,6 @@ abstract class DaemonRepository
|
|||
|
||||
/**
|
||||
* Return an instance of the Guzzle HTTP Client to be used for requests.
|
||||
*
|
||||
* @param array $headers
|
||||
* @return \GuzzleHttp\Client
|
||||
*/
|
||||
public function getHttpClient(array $headers = []): Client
|
||||
{
|
||||
|
|
|
@ -32,8 +32,6 @@ class DaemonServerRepository extends DaemonRepository
|
|||
/**
|
||||
* Creates a new server on the Wings daemon.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function create(array $data): void
|
||||
|
@ -42,7 +40,8 @@ class DaemonServerRepository extends DaemonRepository
|
|||
|
||||
try {
|
||||
$this->getHttpClient()->post(
|
||||
'/api/servers', [
|
||||
'/api/servers',
|
||||
[
|
||||
'json' => $data,
|
||||
]
|
||||
);
|
||||
|
@ -54,8 +53,6 @@ class DaemonServerRepository extends DaemonRepository
|
|||
/**
|
||||
* Updates details about a server on the Daemon.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function update(array $data): void
|
||||
|
@ -96,7 +93,8 @@ class DaemonServerRepository extends DaemonRepository
|
|||
|
||||
try {
|
||||
$this->getHttpClient()->post(sprintf(
|
||||
'/api/servers/%s/reinstall', $this->server->uuid
|
||||
'/api/servers/%s/reinstall',
|
||||
$this->server->uuid
|
||||
));
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
|
@ -107,8 +105,6 @@ class DaemonServerRepository extends DaemonRepository
|
|||
* By default this function will suspend a server instance on the daemon. However, passing
|
||||
* "true" as the first argument will unsuspend the server.
|
||||
*
|
||||
* @param bool $unsuspend
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function suspend(bool $unsuspend = false): void
|
||||
|
@ -118,7 +114,7 @@ class DaemonServerRepository extends DaemonRepository
|
|||
try {
|
||||
$this->getHttpClient()->patch(
|
||||
'/api/servers/' . $this->server->uuid,
|
||||
['json' => ['suspended' => ! $unsuspend]]
|
||||
['json' => ['suspended' => !$unsuspend]]
|
||||
);
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
|
@ -137,7 +133,8 @@ class DaemonServerRepository extends DaemonRepository
|
|||
|
||||
try {
|
||||
$this->getHttpClient()->post(sprintf(
|
||||
'/api/servers/%s/archive', $this->server->uuid
|
||||
'/api/servers/%s/archive',
|
||||
$this->server->uuid
|
||||
));
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
|
@ -149,7 +146,6 @@ class DaemonServerRepository extends DaemonRepository
|
|||
* make it easier to revoke tokens on the fly. This ensures that the JTI key is formatted
|
||||
* correctly and avoids any costly mistakes in the codebase.
|
||||
*
|
||||
* @param int $id
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function revokeUserJTI(int $id): void
|
||||
|
@ -163,7 +159,6 @@ class DaemonServerRepository extends DaemonRepository
|
|||
* Revokes an array of JWT JTI's by marking any token generated before the current time on
|
||||
* the Wings instance as being invalid.
|
||||
*
|
||||
* @param array $jtis
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
protected function revokeJTIs(array $jtis): void
|
||||
|
|
|
@ -10,11 +10,6 @@ use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
|||
class DaemonTransferRepository extends DaemonRepository
|
||||
{
|
||||
/**
|
||||
* @param Server $server
|
||||
* @param array $data
|
||||
* @param Node $node
|
||||
* @param string $token
|
||||
*
|
||||
* @throws DaemonConnectionException
|
||||
*/
|
||||
public function notify(Server $server, array $data, Node $node, string $token): void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue