Update repository base code to be cleaner and make use of PHP 7 features
This commit is contained in:
parent
0ec5a4e08c
commit
60eb60013c
96 changed files with 1048 additions and 1785 deletions
|
@ -1,14 +1,9 @@
|
|||
<?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\Contracts\Repository;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
interface AllocationRepositoryInterface extends RepositoryInterface
|
||||
{
|
||||
/**
|
||||
|
@ -18,13 +13,13 @@ interface AllocationRepositoryInterface extends RepositoryInterface
|
|||
* @param array $ids
|
||||
* @return int
|
||||
*/
|
||||
public function assignAllocationsToServer($server, array $ids);
|
||||
public function assignAllocationsToServer(int $server = null, array $ids): int;
|
||||
|
||||
/**
|
||||
* Return all of the allocations for a specific node.
|
||||
*
|
||||
* @param int $node
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getAllocationsForNode($node);
|
||||
public function getAllocationsForNode(int $node): Collection;
|
||||
}
|
||||
|
|
|
@ -1,21 +1,38 @@
|
|||
<?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\Contracts\Repository\Attributes;
|
||||
|
||||
interface SearchableInterface
|
||||
{
|
||||
/**
|
||||
* Filter results by search term.
|
||||
* Set the search term.
|
||||
*
|
||||
* @param string $term
|
||||
* @param string|null $term
|
||||
* @return $this
|
||||
* @deprecated
|
||||
*/
|
||||
public function search($term);
|
||||
|
||||
/**
|
||||
* Set the search term to use when requesting all records from
|
||||
* the model.
|
||||
*
|
||||
* @param string|null $term
|
||||
* @return $this
|
||||
*/
|
||||
public function setSearchTerm(string $term = null);
|
||||
|
||||
/**
|
||||
* Determine if a valid search term is set on this repository.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasSearchTerm(): bool;
|
||||
|
||||
/**
|
||||
* Return the search term.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSearchTerm();
|
||||
}
|
||||
|
|
|
@ -1,26 +1,4 @@
|
|||
<?php
|
||||
/*
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Contracts\Repository;
|
||||
|
||||
|
@ -44,14 +22,6 @@ interface DaemonKeyRepositoryInterface extends RepositoryInterface
|
|||
*/
|
||||
public function loadServerAndUserRelations(DaemonKey $key, bool $refresh = false): DaemonKey;
|
||||
|
||||
/**
|
||||
* Gets the daemon keys associated with a specific server.
|
||||
*
|
||||
* @param int $server
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getServerKeys($server);
|
||||
|
||||
/**
|
||||
* Return a daemon key with the associated server relation attached.
|
||||
*
|
||||
|
@ -60,7 +30,7 @@ interface DaemonKeyRepositoryInterface extends RepositoryInterface
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getKeyWithServer($key);
|
||||
public function getKeyWithServer(string $key): DaemonKey;
|
||||
|
||||
/**
|
||||
* Get all of the keys for a specific user including the information needed
|
||||
|
|
|
@ -1,30 +1,28 @@
|
|||
<?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\Contracts\Repository;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Pterodactyl\Models\DatabaseHost;
|
||||
|
||||
interface DatabaseHostRepositoryInterface extends RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Return database hosts with a count of databases and the node information for which it is attached.
|
||||
* Return database hosts with a count of databases and the node
|
||||
* information for which it is attached.
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getWithViewDetails();
|
||||
public function getWithViewDetails(): Collection;
|
||||
|
||||
/**
|
||||
* Return a database host with the databases and associated servers that are attached to said databases.
|
||||
* Return a database host with the databases and associated servers
|
||||
* that are attached to said databases.
|
||||
*
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
* @return \Pterodactyl\Models\DatabaseHost
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithServers($id);
|
||||
public function getWithServers(int $id): DatabaseHost;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
namespace Pterodactyl\Contracts\Repository;
|
||||
|
||||
use Pterodactyl\Models\Database;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
interface DatabaseRepositoryInterface extends RepositoryInterface
|
||||
|
@ -43,12 +44,12 @@ interface DatabaseRepositoryInterface extends RepositoryInterface
|
|||
* the provided details.
|
||||
*
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
* @return \Pterodactyl\Models\Database
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\DuplicateDatabaseNameException
|
||||
*/
|
||||
public function createIfNotExists(array $data);
|
||||
public function createIfNotExists(array $data): Database;
|
||||
|
||||
/**
|
||||
* Create a new database on a given connection.
|
||||
|
@ -56,7 +57,7 @@ interface DatabaseRepositoryInterface extends RepositoryInterface
|
|||
* @param string $database
|
||||
* @return bool
|
||||
*/
|
||||
public function createDatabase($database);
|
||||
public function createDatabase(string $database): bool;
|
||||
|
||||
/**
|
||||
* Create a new database user on a given connection.
|
||||
|
@ -66,7 +67,7 @@ interface DatabaseRepositoryInterface extends RepositoryInterface
|
|||
* @param string $password
|
||||
* @return bool
|
||||
*/
|
||||
public function createUser($username, $remote, $password);
|
||||
public function createUser(string $username, string $remote, string $password): bool;
|
||||
|
||||
/**
|
||||
* Give a specific user access to a given database.
|
||||
|
@ -76,14 +77,14 @@ interface DatabaseRepositoryInterface extends RepositoryInterface
|
|||
* @param string $remote
|
||||
* @return bool
|
||||
*/
|
||||
public function assignUserToDatabase($database, $username, $remote);
|
||||
public function assignUserToDatabase(string $database, string $username, string $remote): bool;
|
||||
|
||||
/**
|
||||
* Flush the privileges for a given connection.
|
||||
*
|
||||
* @return mixed
|
||||
* @return bool
|
||||
*/
|
||||
public function flush();
|
||||
public function flush(): bool;
|
||||
|
||||
/**
|
||||
* Drop a given database on a specific connection.
|
||||
|
@ -91,7 +92,7 @@ interface DatabaseRepositoryInterface extends RepositoryInterface
|
|||
* @param string $database
|
||||
* @return bool
|
||||
*/
|
||||
public function dropDatabase($database);
|
||||
public function dropDatabase(string $database): bool;
|
||||
|
||||
/**
|
||||
* Drop a given user on a specific connection.
|
||||
|
@ -100,5 +101,5 @@ interface DatabaseRepositoryInterface extends RepositoryInterface
|
|||
* @param string $remote
|
||||
* @return mixed
|
||||
*/
|
||||
public function dropUser($username, $remote);
|
||||
public function dropUser(string $username, string $remote): bool;
|
||||
}
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
<?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\Contracts\Repository;
|
||||
|
||||
use Pterodactyl\Models\Location;
|
||||
use Illuminate\Support\Collection;
|
||||
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
|
||||
|
||||
interface LocationRepositoryInterface extends RepositoryInterface, SearchableInterface
|
||||
|
@ -16,16 +11,16 @@ interface LocationRepositoryInterface extends RepositoryInterface, SearchableInt
|
|||
/**
|
||||
* Return locations with a count of nodes and servers attached to it.
|
||||
*
|
||||
* @return mixed
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getAllWithDetails();
|
||||
public function getAllWithDetails(): Collection;
|
||||
|
||||
/**
|
||||
* Return all of the available locations with the nodes as a relationship.
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getAllWithNodes();
|
||||
public function getAllWithNodes(): Collection;
|
||||
|
||||
/**
|
||||
* Return all of the nodes and their respective count of servers for a location.
|
||||
|
@ -35,7 +30,7 @@ interface LocationRepositoryInterface extends RepositoryInterface, SearchableInt
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithNodes($id);
|
||||
public function getWithNodes(int $id): Location;
|
||||
|
||||
/**
|
||||
* Return a location and the count of nodes in that location.
|
||||
|
@ -45,5 +40,5 @@ interface LocationRepositoryInterface extends RepositoryInterface, SearchableInt
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithNodeCount($id);
|
||||
public function getWithNodeCount(int $id): Location;
|
||||
}
|
||||
|
|
|
@ -1,68 +1,65 @@
|
|||
<?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\Contracts\Repository;
|
||||
|
||||
use Pterodactyl\Models\Node;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
|
||||
|
||||
interface NodeRepositoryInterface extends RepositoryInterface, SearchableInterface
|
||||
{
|
||||
const THRESHOLD_PERCENTAGE_LOW = 75;
|
||||
const THRESHOLD_PERCENTAGE_MEDIUM = 90;
|
||||
|
||||
/**
|
||||
* Return the usage stats for a single node.
|
||||
*
|
||||
* @param int $id
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @return array
|
||||
*/
|
||||
public function getUsageStats($id);
|
||||
public function getUsageStats(Node $node): array;
|
||||
|
||||
/**
|
||||
* Return all available nodes with a searchable interface.
|
||||
*
|
||||
* @param int $count
|
||||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
*/
|
||||
public function getNodeListingData($count = 25);
|
||||
public function getNodeListingData(): LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* Return a single node with location and server information.
|
||||
*
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @param bool $refresh
|
||||
* @return \Pterodactyl\Models\Node
|
||||
*/
|
||||
public function getSingleNode($id);
|
||||
public function loadLocationAndServerCount(Node $node, bool $refresh = false): Node;
|
||||
|
||||
/**
|
||||
* Return a node with all of the associated allocations and servers that are attached to said allocations.
|
||||
* Attach a paginated set of allocations to a node mode including
|
||||
* any servers that are also attached to those allocations.
|
||||
*
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @param bool $refresh
|
||||
* @return \Pterodactyl\Models\Node
|
||||
*/
|
||||
public function getNodeAllocations($id);
|
||||
public function loadNodeAllocations(Node $node, bool $refresh = false): Node;
|
||||
|
||||
/**
|
||||
* Return a node with all of the servers attached to that node.
|
||||
*
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
* @return \Pterodactyl\Models\Node
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getNodeServers($id);
|
||||
public function getNodeServers(int $id): Node;
|
||||
|
||||
/**
|
||||
* Return a collection of nodes for all locations to use in server creation UI.
|
||||
*
|
||||
* @return mixed
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getNodesForServerCreation();
|
||||
public function getNodesForServerCreation(): Collection;
|
||||
}
|
||||
|
|
|
@ -1,44 +1,26 @@
|
|||
<?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\Contracts\Repository;
|
||||
|
||||
use Pterodactyl\Models\Pack;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
|
||||
|
||||
interface PackRepositoryInterface extends RepositoryInterface, SearchableInterface
|
||||
{
|
||||
/**
|
||||
* Return a paginated listing of packs with their associated egg and server count.
|
||||
*
|
||||
* @param int $paginate
|
||||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
*/
|
||||
public function paginateWithEggAndServerCount($paginate = 50);
|
||||
|
||||
/**
|
||||
* Return a pack with the associated server models attached to it.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*
|
||||
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
|
||||
* @param \Pterodactyl\Models\Pack $pack
|
||||
* @param bool $refresh
|
||||
* @return \Pterodactyl\Models\Pack
|
||||
*/
|
||||
public function getWithServers($id);
|
||||
public function loadServerData(Pack $pack, bool $refresh = false): Pack;
|
||||
|
||||
/**
|
||||
* Return all of the file archives for a given pack.
|
||||
* Return a paginated listing of packs with their associated egg and server count.
|
||||
*
|
||||
* @param int $id
|
||||
* @param bool $collection
|
||||
* @return object|\Illuminate\Support\Collection
|
||||
*
|
||||
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
|
||||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
*/
|
||||
public function getFileArchives($id, $collection = false);
|
||||
public function paginateWithEggAndServerCount(): LengthAwarePaginator;
|
||||
}
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
<?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\Contracts\Repository;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
interface RepositoryInterface
|
||||
{
|
||||
/**
|
||||
|
@ -42,17 +37,34 @@ interface RepositoryInterface
|
|||
/**
|
||||
* An array of columns to filter the response by.
|
||||
*
|
||||
* @param array $columns
|
||||
* @param array|string $columns
|
||||
* @return $this
|
||||
*/
|
||||
public function withColumns($columns = ['*']);
|
||||
public function setColumns($columns = ['*']);
|
||||
|
||||
/**
|
||||
* Disable returning a fresh model when data is inserted or updated.
|
||||
* Stop repository update functions from returning a fresh
|
||||
* model when changes are committed.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function withoutFresh();
|
||||
public function withoutFreshModel();
|
||||
|
||||
/**
|
||||
* Return a fresh model with a repository updates a model.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function withFreshModel();
|
||||
|
||||
/**
|
||||
* Set wether or not the repository should return a fresh model
|
||||
* when changes are committed.
|
||||
*
|
||||
* @param bool $fresh
|
||||
* @return $this
|
||||
*/
|
||||
public function setFreshModel(bool $fresh = true);
|
||||
|
||||
/**
|
||||
* Create a new model instance and persist it to the database.
|
||||
|
@ -64,23 +76,7 @@ interface RepositoryInterface
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
public function create(array $fields, $validate = true, $force = false);
|
||||
|
||||
/**
|
||||
* Delete a given record from the database.
|
||||
*
|
||||
* @param int $id
|
||||
* @return int
|
||||
*/
|
||||
public function delete($id);
|
||||
|
||||
/**
|
||||
* Delete records matching the given attributes.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @return int
|
||||
*/
|
||||
public function deleteWhere(array $attributes);
|
||||
public function create(array $fields, bool $validate = true, bool $force = false);
|
||||
|
||||
/**
|
||||
* Find a model that has the specific ID passed.
|
||||
|
@ -90,15 +86,15 @@ interface RepositoryInterface
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function find($id);
|
||||
public function find(int $id);
|
||||
|
||||
/**
|
||||
* Find a model matching an array of where clauses.
|
||||
*
|
||||
* @param array $fields
|
||||
* @return mixed
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function findWhere(array $fields);
|
||||
public function findWhere(array $fields): Collection;
|
||||
|
||||
/**
|
||||
* Find and return the first matching instance for the given fields.
|
||||
|
@ -116,7 +112,23 @@ interface RepositoryInterface
|
|||
* @param array $fields
|
||||
* @return int
|
||||
*/
|
||||
public function findCountWhere(array $fields);
|
||||
public function findCountWhere(array $fields): int;
|
||||
|
||||
/**
|
||||
* Delete a given record from the database.
|
||||
*
|
||||
* @param int $id
|
||||
* @return int
|
||||
*/
|
||||
public function delete(int $id): int;
|
||||
|
||||
/**
|
||||
* Delete records matching the given attributes.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @return int
|
||||
*/
|
||||
public function deleteWhere(array $attributes): int;
|
||||
|
||||
/**
|
||||
* Update a given ID with the passed array of fields.
|
||||
|
@ -130,7 +142,7 @@ interface RepositoryInterface
|
|||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function update($id, array $fields, $validate = true, $force = false);
|
||||
public function update($id, array $fields, bool $validate = true, bool $force = false);
|
||||
|
||||
/**
|
||||
* Perform a mass update where matching records are updated using whereIn.
|
||||
|
@ -141,7 +153,7 @@ interface RepositoryInterface
|
|||
* @param array $fields
|
||||
* @return int
|
||||
*/
|
||||
public function updateWhereIn($column, array $values, array $fields);
|
||||
public function updateWhereIn(string $column, array $values, array $fields): int;
|
||||
|
||||
/**
|
||||
* Update a record if it exists in the database, otherwise create it.
|
||||
|
@ -154,23 +166,14 @@ interface RepositoryInterface
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
public function updateOrCreate(array $where, array $fields, $validate = true, $force = false);
|
||||
public function updateOrCreate(array $where, array $fields, bool $validate = true, bool $force = false);
|
||||
|
||||
/**
|
||||
* Update multiple records matching the passed clauses.
|
||||
* Return all records associated with the given model.
|
||||
*
|
||||
* @param array $where
|
||||
* @param array $fields
|
||||
* @return mixed
|
||||
* @return Collection
|
||||
*/
|
||||
public function massUpdate(array $where, array $fields);
|
||||
|
||||
/**
|
||||
* Return all records from the model.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function all();
|
||||
public function all(): Collection;
|
||||
|
||||
/**
|
||||
* Insert a single or multiple records into the database at once skipping
|
||||
|
@ -179,7 +182,7 @@ interface RepositoryInterface
|
|||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function insert(array $data);
|
||||
public function insert(array $data): bool;
|
||||
|
||||
/**
|
||||
* Insert multiple records into the database and ignore duplicates.
|
||||
|
@ -187,5 +190,5 @@ interface RepositoryInterface
|
|||
* @param array $values
|
||||
* @return bool
|
||||
*/
|
||||
public function insertIgnore(array $values);
|
||||
public function insertIgnore(array $values): bool;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?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\Contracts\Repository;
|
||||
|
||||
|
@ -38,5 +31,5 @@ interface ScheduleRepositoryInterface extends RepositoryInterface
|
|||
* @param string $timestamp
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getSchedulesToProcess($timestamp);
|
||||
public function getSchedulesToProcess(string $timestamp): Collection;
|
||||
}
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
<?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\Contracts\Repository;
|
||||
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
|
||||
|
||||
interface ServerRepositoryInterface extends RepositoryInterface, SearchableInterface
|
||||
|
@ -17,19 +13,10 @@ interface ServerRepositoryInterface extends RepositoryInterface, SearchableInter
|
|||
/**
|
||||
* Returns a listing of all servers that exist including relationships.
|
||||
*
|
||||
* @param int|null $paginate
|
||||
* @return mixed
|
||||
* @param int $paginate
|
||||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
*/
|
||||
public function getAllServers($paginate);
|
||||
|
||||
/**
|
||||
* Return a collection of servers with their associated data for rebuild operations.
|
||||
*
|
||||
* @param int|null $server
|
||||
* @param int|null $node
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
public function getDataForRebuild($server = null, $node = null);
|
||||
public function getAllServers(int $paginate): LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* Load the egg relations onto the server model.
|
||||
|
@ -40,15 +27,35 @@ interface ServerRepositoryInterface extends RepositoryInterface, SearchableInter
|
|||
*/
|
||||
public function loadEggRelations(Server $server, bool $refresh = false): Server;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Return a server model and all variables associated with the server.
|
||||
*
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
* @return \Pterodactyl\Models\Server
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function findWithVariables($id);
|
||||
public function findWithVariables(int $id): Server;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Return all of the server variables possible and default to the variable
|
||||
|
@ -60,20 +67,7 @@ interface ServerRepositoryInterface extends RepositoryInterface, SearchableInter
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getVariablesWithValues($id, $returnAsObject = false);
|
||||
|
||||
/**
|
||||
* 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 int|\Pterodactyl\Models\Server $server
|
||||
* @param bool $refresh
|
||||
* @return \Pterodactyl\Models\Server
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getPrimaryAllocation($server, bool $refresh = false): Server;
|
||||
public function getVariablesWithValues(int $id, bool $returnAsObject = false);
|
||||
|
||||
/**
|
||||
* Return enough data to be used for the creation of a server via the daemon.
|
||||
|
@ -85,14 +79,13 @@ interface ServerRepositoryInterface extends RepositoryInterface, SearchableInter
|
|||
public function getDataForCreation(Server $server, bool $refresh = false): Server;
|
||||
|
||||
/**
|
||||
* Return a server as well as associated databases and their hosts.
|
||||
* Load associated databases onto the server model.
|
||||
*
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @param bool $refresh
|
||||
* @return \Pterodactyl\Models\Server
|
||||
*/
|
||||
public function getWithDatabases($id);
|
||||
public function loadDatabaseRelations(Server $server, bool $refresh = false): Server;
|
||||
|
||||
/**
|
||||
* Get data for use when updating a server on the Daemon. Returns an array of
|
||||
|
@ -105,24 +98,14 @@ interface ServerRepositoryInterface extends RepositoryInterface, SearchableInter
|
|||
*/
|
||||
public function getDaemonServiceData(Server $server, bool $refresh = false): array;
|
||||
|
||||
/**
|
||||
* Return an array of server IDs that a given user can access based on owner and subuser permissions.
|
||||
*
|
||||
* @param int $user
|
||||
* @return array
|
||||
*/
|
||||
public function getUserAccessServers($user);
|
||||
|
||||
/**
|
||||
* Return a paginated list of servers that a user can access at a given level.
|
||||
*
|
||||
* @param int $user
|
||||
* @param string $level
|
||||
* @param bool $admin
|
||||
* @param array $relations
|
||||
* @param \Pterodactyl\Models\User $user
|
||||
* @param int $level
|
||||
* @return \Illuminate\Pagination\LengthAwarePaginator
|
||||
*/
|
||||
public function filterUserAccessServers($user, $admin = false, $level = 'all', array $relations = []);
|
||||
public function filterUserAccessServers(User $user, int $level): LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* Return a server by UUID.
|
||||
|
@ -132,5 +115,5 @@ interface ServerRepositoryInterface extends RepositoryInterface, SearchableInter
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getByUuid($uuid);
|
||||
public function getByUuid(string $uuid): Server;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?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\Contracts\Repository;
|
||||
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
<?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\Contracts\Repository;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
interface SessionRepositoryInterface extends RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Return all of the active sessions for a user.
|
||||
*
|
||||
* @param int $user
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getUserSessions(int $user): Collection;
|
||||
|
||||
/**
|
||||
* Delete a session for a given user.
|
||||
*
|
||||
|
@ -18,13 +21,5 @@ interface SessionRepositoryInterface extends RepositoryInterface
|
|||
* @param int $session
|
||||
* @return null|int
|
||||
*/
|
||||
public function deleteUserSession($user, $session);
|
||||
|
||||
/**
|
||||
* Return all of the active sessions for a user.
|
||||
*
|
||||
* @param int $user
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getUserSessions($user);
|
||||
public function deleteUserSession(int $user, int $session);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,9 @@ interface SettingsRepositoryInterface extends RepositoryInterface
|
|||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function set(string $key, string $value);
|
||||
|
||||
|
@ -26,7 +28,6 @@ interface SettingsRepositoryInterface extends RepositoryInterface
|
|||
* Remove a key from the database cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function forget(string $key);
|
||||
}
|
||||
|
|
|
@ -34,25 +34,4 @@ interface SubuserRepositoryInterface extends RepositoryInterface
|
|||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithPermissionsUsingUserAndServer(int $user, int $server): Subuser;
|
||||
|
||||
/**
|
||||
* Find a subuser and return with server and permissions relationships.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithServerAndPermissions($id);
|
||||
|
||||
/**
|
||||
* Return a subuser and their associated connection key for a server.
|
||||
*
|
||||
* @param int $user
|
||||
* @param int $server
|
||||
* @return \Pterodactyl\Models\Subuser
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithKey($user, $server);
|
||||
}
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
<?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\Contracts\Repository;
|
||||
|
||||
use Pterodactyl\Models\Task;
|
||||
|
||||
interface TaskRepositoryInterface extends RepositoryInterface
|
||||
{
|
||||
/**
|
||||
|
@ -19,14 +14,14 @@ interface TaskRepositoryInterface extends RepositoryInterface
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getTaskWithServer($id);
|
||||
public function getTaskWithServer(int $id): Task;
|
||||
|
||||
/**
|
||||
* Returns the next task in a schedule.
|
||||
*
|
||||
* @param int $schedule the ID of the schedule to select the next task from
|
||||
* @param int $index the index of the current task
|
||||
* @param int $schedule
|
||||
* @param int $index
|
||||
* @return null|\Pterodactyl\Models\Task
|
||||
*/
|
||||
public function getNextTask($schedule, $index);
|
||||
public function getNextTask(int $schedule, int $index);
|
||||
}
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
<?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\Contracts\Repository;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
|
||||
|
||||
interface UserRepositoryInterface extends RepositoryInterface, SearchableInterface
|
||||
|
@ -18,13 +13,13 @@ interface UserRepositoryInterface extends RepositoryInterface, SearchableInterfa
|
|||
*
|
||||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
*/
|
||||
public function getAllUsersWithCounts();
|
||||
public function getAllUsersWithCounts(): LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* Return all matching models for a user in a format that can be used for dropdowns.
|
||||
*
|
||||
* @param string $query
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function filterUsersByQuery($query);
|
||||
public function filterUsersByQuery(string $query): Collection;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue