Cleanup code, add basic functionality for Nests
This commit is contained in:
parent
6c85be72fa
commit
88ac1ce1fd
37 changed files with 331 additions and 159 deletions
|
@ -113,6 +113,6 @@ class ApiController extends Controller
|
|||
{
|
||||
$this->repository->deleteApplicationKey($request->user(), $identifier);
|
||||
|
||||
return response('', 204);
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ class MountController extends Controller
|
|||
{
|
||||
$mount->eggs()->detach($egg_id);
|
||||
|
||||
return response('', 204);
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -219,6 +219,6 @@ class MountController extends Controller
|
|||
{
|
||||
$mount->nodes()->detach($node_id);
|
||||
|
||||
return response('', 204);
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ class NodesController extends Controller
|
|||
{
|
||||
$this->allocationDeletionService->handle($allocation);
|
||||
|
||||
return response('', 204);
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -222,7 +222,7 @@ class NodesController extends Controller
|
|||
$this->allocationRemoveSingle($node, $allocation);
|
||||
}
|
||||
|
||||
return response('', 204);
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -261,7 +261,7 @@ class NodesController extends Controller
|
|||
'ip_alias' => (empty($request->input('alias'))) ? null : $request->input('alias'),
|
||||
]);
|
||||
|
||||
return response('', 204);
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -395,7 +395,7 @@ class ServersController extends Controller
|
|||
|
||||
$this->databasePasswordService->handle($database);
|
||||
|
||||
return response('', 204);
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -417,7 +417,7 @@ class ServersController extends Controller
|
|||
|
||||
$this->databaseManagementService->delete($database);
|
||||
|
||||
return response('', 204);
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -112,7 +112,7 @@ class MailController extends Controller
|
|||
|
||||
$this->kernel->call('queue:restart');
|
||||
|
||||
return response('', 204);
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -130,6 +130,6 @@ class MailController extends Controller
|
|||
return response($exception->getMessage(), 500);
|
||||
}
|
||||
|
||||
return response('', 204);
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,9 @@ abstract class ApplicationApiController extends Controller
|
|||
* Return an instance of an application transformer.
|
||||
*
|
||||
* @param string $abstract
|
||||
*
|
||||
* @return \Pterodactyl\Transformers\Api\Application\BaseTransformer
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function getTransformer(string $abstract)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Http\Controllers\Api\Application\Locations;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use Pterodactyl\Models\Location;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
|
@ -66,7 +65,9 @@ class LocationController extends ApplicationApiController
|
|||
* Return all of the locations currently registered on the Panel.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\GetLocationsRequest $request
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetLocationsRequest $request): array
|
||||
{
|
||||
|
@ -84,11 +85,14 @@ class LocationController extends ApplicationApiController
|
|||
* Return a single location.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\GetLocationRequest $request
|
||||
* @param \Pterodactyl\Models\Location $location
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function view(GetLocationRequest $request): array
|
||||
public function view(GetLocationRequest $request, Location $location): array
|
||||
{
|
||||
return $this->fractal->item($request->getModel(Location::class))
|
||||
return $this->fractal->item($location)
|
||||
->transformWith($this->getTransformer(LocationTransformer::class))
|
||||
->toArray();
|
||||
}
|
||||
|
@ -98,9 +102,11 @@ class LocationController extends ApplicationApiController
|
|||
* new location attached.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\StoreLocationRequest $request
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function store(StoreLocationRequest $request): JsonResponse
|
||||
{
|
||||
|
@ -120,14 +126,17 @@ class LocationController extends ApplicationApiController
|
|||
* Update a location on the Panel and return the updated record to the user.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\UpdateLocationRequest $request
|
||||
* @param \Pterodactyl\Models\Location $location
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function update(UpdateLocationRequest $request): array
|
||||
public function update(UpdateLocationRequest $request, Location $location): array
|
||||
{
|
||||
$location = $this->updateService->handle($request->getModel(Location::class), $request->validated());
|
||||
$location = $this->updateService->handle($location, $request->validated());
|
||||
|
||||
return $this->fractal->item($location)
|
||||
->transformWith($this->getTransformer(LocationTransformer::class))
|
||||
|
@ -138,14 +147,16 @@ class LocationController extends ApplicationApiController
|
|||
* Delete a location from the Panel.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\DeleteLocationRequest $request
|
||||
* @return \Illuminate\Http\Response
|
||||
* @param \Pterodactyl\Models\Location $location
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Service\Location\HasActiveNodesException
|
||||
*/
|
||||
public function delete(DeleteLocationRequest $request): Response
|
||||
public function delete(DeleteLocationRequest $request, Location $location): JsonResponse
|
||||
{
|
||||
$this->deletionService->handle($request->getModel(Location::class));
|
||||
$this->deletionService->handle($location);
|
||||
|
||||
return response('', 204);
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,12 +33,15 @@ class EggController extends ApplicationApiController
|
|||
* Return all eggs that exist for a given nest.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\Eggs\GetEggsRequest $request
|
||||
* @param \Pterodactyl\Models\Nest $nest
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetEggsRequest $request): array
|
||||
public function index(GetEggsRequest $request, Nest $nest): array
|
||||
{
|
||||
$eggs = $this->repository->findWhere([
|
||||
['nest_id', '=', $request->getModel(Nest::class)->id],
|
||||
['nest_id', '=', $nest->id],
|
||||
]);
|
||||
|
||||
return $this->fractal->collection($eggs)
|
||||
|
@ -50,11 +53,14 @@ class EggController extends ApplicationApiController
|
|||
* Return a single egg that exists on the specified nest.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\Eggs\GetEggRequest $request
|
||||
* @param \Pterodactyl\Models\Egg $egg
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function view(GetEggRequest $request): array
|
||||
public function view(GetEggRequest $request, Egg $egg): array
|
||||
{
|
||||
return $this->fractal->item($request->getModel(Egg::class))
|
||||
return $this->fractal->item($egg)
|
||||
->transformWith($this->getTransformer(EggTransformer::class))
|
||||
->toArray();
|
||||
}
|
||||
|
|
|
@ -31,7 +31,9 @@ class NestController extends ApplicationApiController
|
|||
* Return all Nests that exist on the Panel.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\GetNestsRequest $request
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetNestsRequest $request): array
|
||||
{
|
||||
|
@ -46,11 +48,14 @@ class NestController extends ApplicationApiController
|
|||
* Return information about a single Nest model.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\GetNestsRequest $request
|
||||
* @param \Pterodactyl\Models\Nest $nest
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function view(GetNestsRequest $request): array
|
||||
public function view(GetNestsRequest $request, Nest $nest): array
|
||||
{
|
||||
return $this->fractal->item($request->getModel(Nest::class))
|
||||
return $this->fractal->item($nest)
|
||||
->transformWith($this->getTransformer(NestTransformer::class))
|
||||
->toArray();
|
||||
}
|
||||
|
|
|
@ -46,7 +46,9 @@ class AllocationController extends ApplicationApiController
|
|||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Allocations\GetAllocationsRequest $request
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetAllocationsRequest $request, Node $node): array
|
||||
{
|
||||
|
|
|
@ -20,6 +20,6 @@ class NodeConfigurationController extends ApplicationApiController
|
|||
*/
|
||||
public function __invoke(GetNodeRequest $request, Node $node)
|
||||
{
|
||||
return JsonResponse::create($node->getConfiguration());
|
||||
return new JsonResponse($node->getConfiguration());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,9 @@ class NodeController extends ApplicationApiController
|
|||
* Return all of the nodes currently available on the Panel.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodesRequest $request
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetNodesRequest $request): array
|
||||
{
|
||||
|
@ -84,7 +86,9 @@ class NodeController extends ApplicationApiController
|
|||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodeRequest $request
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function view(GetNodeRequest $request, Node $node): array
|
||||
{
|
||||
|
@ -98,9 +102,10 @@ class NodeController extends ApplicationApiController
|
|||
* status response on success.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\StoreNodeRequest $request
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException*@throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function store(StoreNodeRequest $request): JsonResponse
|
||||
{
|
||||
|
@ -121,6 +126,7 @@ class NodeController extends ApplicationApiController
|
|||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\UpdateNodeRequest $request
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Throwable
|
||||
|
@ -142,6 +148,7 @@ class NodeController extends ApplicationApiController
|
|||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\DeleteNodeRequest $request
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
|
||||
|
|
|
@ -37,8 +37,9 @@ class RoleController extends ApplicationApiController
|
|||
* @param \Pterodactyl\Http\Requests\Api\Application\Roles\GetRolesRequest $request
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetRolesRequest $request)
|
||||
public function index(GetRolesRequest $request): array
|
||||
{
|
||||
return $this->fractal->collection(AdminRole::all())
|
||||
->transformWith($this->getTransformer(AdminRoleTransformer::class))
|
||||
|
@ -52,6 +53,7 @@ class RoleController extends ApplicationApiController
|
|||
* @param \Pterodactyl\Models\AdminRole $role
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function view(GetRolesRequest $request, AdminRole $role): array
|
||||
{
|
||||
|
@ -66,8 +68,9 @@ class RoleController extends ApplicationApiController
|
|||
* @param \Pterodactyl\Http\Requests\Api\Application\Roles\StoreRoleRequest $request
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function store(StoreRoleRequest $request)
|
||||
public function store(StoreRoleRequest $request): JsonResponse
|
||||
{
|
||||
$role = AdminRole::query()->create($request->validated());
|
||||
|
||||
|
@ -83,8 +86,9 @@ class RoleController extends ApplicationApiController
|
|||
* @param \Pterodactyl\Models\AdminRole $role
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function update(UpdateRoleRequest $request, AdminRole $role)
|
||||
public function update(UpdateRoleRequest $request, AdminRole $role): array
|
||||
{
|
||||
$role->update($request->validated());
|
||||
|
||||
|
@ -101,7 +105,7 @@ class RoleController extends ApplicationApiController
|
|||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function delete(DeleteRoleRequest $request, AdminRole $role)
|
||||
public function delete(DeleteRoleRequest $request, AdminRole $role): JsonResponse
|
||||
{
|
||||
$this->repository->delete($role->id);
|
||||
|
||||
|
|
|
@ -44,7 +44,8 @@ class DatabaseController extends ApplicationApiController
|
|||
DatabaseManagementService $databaseManagementService,
|
||||
DatabasePasswordService $databasePasswordService,
|
||||
DatabaseRepositoryInterface $repository
|
||||
) {
|
||||
)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->databaseManagementService = $databaseManagementService;
|
||||
|
@ -58,7 +59,9 @@ class DatabaseController extends ApplicationApiController
|
|||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\GetServerDatabasesRequest $request
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetServerDatabasesRequest $request, Server $server): array
|
||||
{
|
||||
|
@ -73,7 +76,9 @@ class DatabaseController extends ApplicationApiController
|
|||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\GetServerDatabaseRequest $request
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @param \Pterodactyl\Models\Database $database
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function view(GetServerDatabaseRequest $request, Server $server, Database $database): array
|
||||
{
|
||||
|
@ -88,6 +93,7 @@ class DatabaseController extends ApplicationApiController
|
|||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\ServerDatabaseWriteRequest $request
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @param \Pterodactyl\Models\Database $database
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
|
@ -96,7 +102,7 @@ class DatabaseController extends ApplicationApiController
|
|||
{
|
||||
$this->databasePasswordService->handle($database);
|
||||
|
||||
return JsonResponse::create([], JsonResponse::HTTP_NO_CONTENT);
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,6 +110,7 @@ class DatabaseController extends ApplicationApiController
|
|||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\StoreServerDatabaseRequest $request
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
|
@ -129,14 +136,16 @@ class DatabaseController extends ApplicationApiController
|
|||
* Handle a request to delete a specific server database from the Panel.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\ServerDatabaseWriteRequest $request
|
||||
* @return \Illuminate\Http\Response
|
||||
* @param \Pterodactyl\Models\Database $database
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete(ServerDatabaseWriteRequest $request): Response
|
||||
public function delete(ServerDatabaseWriteRequest $request, Database $database): JsonResponse
|
||||
{
|
||||
$this->databaseManagementService->delete($request->getModel(Database::class));
|
||||
$this->databaseManagementService->delete($database);
|
||||
|
||||
return response('', 204);
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,9 @@ class ExternalServerController extends ApplicationApiController
|
|||
* Retrieve a specific server from the database using its external ID.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\GetExternalServerRequest $request
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetExternalServerRequest $request): array
|
||||
{
|
||||
|
|
|
@ -22,12 +22,10 @@ class ServerController extends ApplicationApiController
|
|||
* @var \Pterodactyl\Services\Servers\ServerCreationService
|
||||
*/
|
||||
private $creationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\ServerDeletionService
|
||||
*/
|
||||
private $deletionService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
|
||||
*/
|
||||
|
@ -44,7 +42,8 @@ class ServerController extends ApplicationApiController
|
|||
ServerCreationService $creationService,
|
||||
ServerDeletionService $deletionService,
|
||||
ServerRepositoryInterface $repository
|
||||
) {
|
||||
)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->creationService = $creationService;
|
||||
|
@ -56,7 +55,9 @@ class ServerController extends ApplicationApiController
|
|||
* Return all of the servers that currently exist on the Panel.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\GetServersRequest $request
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetServersRequest $request): array
|
||||
{
|
||||
|
@ -74,12 +75,12 @@ class ServerController extends ApplicationApiController
|
|||
* Create a new server on the system.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\StoreServerRequest $request
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableAllocationException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException
|
||||
|
@ -97,22 +98,28 @@ class ServerController extends ApplicationApiController
|
|||
* Show a single server transformed for the application API.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\GetServerRequest $request
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function view(GetServerRequest $request): array
|
||||
public function view(GetServerRequest $request, Server $server): array
|
||||
{
|
||||
return $this->fractal->item($request->getModel(Server::class))
|
||||
return $this->fractal->item($server)
|
||||
->transformWith($this->getTransformer(ServerTransformer::class))
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a server.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @param string $force
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function delete(ServerWriteRequest $request, Server $server, string $force = ''): Response
|
||||
{
|
||||
|
|
|
@ -42,16 +42,17 @@ class ServerDetailsController extends ApplicationApiController
|
|||
* Update the details for a specific server.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerDetailsRequest $request
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function details(UpdateServerDetailsRequest $request): array
|
||||
public function details(UpdateServerDetailsRequest $request, Server $server): array
|
||||
{
|
||||
$server = $this->detailsModificationService->returnUpdatedModel()->handle(
|
||||
$request->getModel(Server::class), $request->validated()
|
||||
$server, $request->validated()
|
||||
);
|
||||
|
||||
return $this->fractal->item($server)
|
||||
|
@ -64,11 +65,11 @@ class ServerDetailsController extends ApplicationApiController
|
|||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerBuildConfigurationRequest $request
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Throwable
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function build(UpdateServerBuildConfigurationRequest $request, Server $server): array
|
||||
{
|
||||
|
|
|
@ -42,6 +42,7 @@ class ServerManagementController extends ApplicationApiController
|
|||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @throws \Throwable
|
||||
|
@ -58,6 +59,7 @@ class ServerManagementController extends ApplicationApiController
|
|||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @throws \Throwable
|
||||
|
@ -74,11 +76,10 @@ class ServerManagementController extends ApplicationApiController
|
|||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function reinstall(ServerWriteRequest $request, Server $server): Response
|
||||
{
|
||||
|
|
|
@ -32,18 +32,16 @@ class StartupController extends ApplicationApiController
|
|||
* Update the startup and environment settings for a specific server.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerStartupRequest $request
|
||||
* @return array
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @return array
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function index(UpdateServerStartupRequest $request): array
|
||||
public function index(UpdateServerStartupRequest $request, Server $server): array
|
||||
{
|
||||
$server = $this->modificationService
|
||||
->setUserLevel(User::USER_LEVEL_ADMIN)
|
||||
->handle($request->getModel(Server::class), $request->validated());
|
||||
->handle($server, $request->validated());
|
||||
|
||||
return $this->fractal->item($server)
|
||||
->transformWith($this->getTransformer(ServerTransformer::class))
|
||||
|
|
|
@ -12,7 +12,9 @@ class ExternalUserController extends ApplicationApiController
|
|||
* Retrieve a specific user from the database using their external ID.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Users\GetExternalUserRequest $request
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetExternalUserRequest $request): array
|
||||
{
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace Pterodactyl\Http\Controllers\Api\Application\Users;
|
||||
|
||||
use Pterodactyl\Models\User;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
use Pterodactyl\Services\Users\UserUpdateService;
|
||||
|
@ -52,7 +51,8 @@ class UserController extends ApplicationApiController
|
|||
UserCreationService $creationService,
|
||||
UserDeletionService $deletionService,
|
||||
UserUpdateService $updateService
|
||||
) {
|
||||
)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->creationService = $creationService;
|
||||
|
@ -67,7 +67,9 @@ class UserController extends ApplicationApiController
|
|||
* the request.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Users\GetUsersRequest $request
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetUsersRequest $request): array
|
||||
{
|
||||
|
@ -87,7 +89,9 @@ class UserController extends ApplicationApiController
|
|||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Users\GetUsersRequest $request
|
||||
* @param \Pterodactyl\Models\User $user
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function view(GetUsersRequest $request, User $user): array
|
||||
{
|
||||
|
@ -106,10 +110,12 @@ class UserController extends ApplicationApiController
|
|||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Users\UpdateUserRequest $request
|
||||
* @param \Pterodactyl\Models\User $user
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function update(UpdateUserRequest $request, User $user): array
|
||||
{
|
||||
|
@ -127,6 +133,7 @@ class UserController extends ApplicationApiController
|
|||
* header on successful creation.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Users\StoreUserRequest $request
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Exception
|
||||
|
@ -152,6 +159,7 @@ class UserController extends ApplicationApiController
|
|||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Users\DeleteUserRequest $request
|
||||
* @param \Pterodactyl\Models\User $user
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
|
|
|
@ -29,6 +29,7 @@ class GetExternalUserRequest extends ApplicationApiRequest
|
|||
* Determine if the requested external user exists.
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
|
|
@ -19,15 +19,15 @@ class AdminRoleTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return a transformed User model that can be consumed by external services.
|
||||
*
|
||||
* @param \Pterodactyl\Models\AdminRole $role
|
||||
* @param \Pterodactyl\Models\AdminRole $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(AdminRole $role): array
|
||||
public function transform(AdminRole $model): array
|
||||
{
|
||||
return [
|
||||
'id' => $role->id,
|
||||
'name' => $role->name,
|
||||
'description' => $role->description,
|
||||
'id' => $model->id,
|
||||
'name' => $model->name,
|
||||
'description' => $model->description,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,18 +29,19 @@ class AllocationTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return a generic transformed allocation array.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Allocation $allocation
|
||||
* @param \Pterodactyl\Models\Allocation $model
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Allocation $allocation)
|
||||
public function transform(Allocation $model)
|
||||
{
|
||||
return [
|
||||
'id' => $allocation->id,
|
||||
'ip' => $allocation->ip,
|
||||
'alias' => $allocation->ip_alias,
|
||||
'port' => $allocation->port,
|
||||
'notes' => $allocation->notes,
|
||||
'assigned' => ! is_null($allocation->server_id),
|
||||
'id' => $model->id,
|
||||
'ip' => $model->ip,
|
||||
'alias' => $model->ip_alias,
|
||||
'port' => $model->port,
|
||||
'notes' => $model->notes,
|
||||
'assigned' => ! is_null($model->server_id),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -48,8 +49,10 @@ class AllocationTransformer extends BaseTransformer
|
|||
* Load the node relationship onto a given transformation.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Allocation $allocation
|
||||
*
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function includeNode(Allocation $allocation)
|
||||
{
|
||||
|
@ -66,8 +69,10 @@ class AllocationTransformer extends BaseTransformer
|
|||
* Load the server relationship onto a given transformation.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Allocation $allocation
|
||||
*
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function includeServer(Allocation $allocation)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,7 @@ abstract class BaseTransformer extends TransformerAbstract
|
|||
* Set the HTTP request class being used for this request.
|
||||
*
|
||||
* @param \Pterodactyl\Models\ApiKey $key
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setKey(ApiKey $key)
|
||||
|
@ -69,6 +70,7 @@ abstract class BaseTransformer extends TransformerAbstract
|
|||
* models on a transformation request.
|
||||
*
|
||||
* @param string $resource
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorize(string $resource): bool
|
||||
|
@ -82,8 +84,10 @@ abstract class BaseTransformer extends TransformerAbstract
|
|||
*
|
||||
* @param string $abstract
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return \Pterodactyl\Transformers\Api\Application\BaseTransformer
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
protected function makeTransformer(string $abstract, array $parameters = [])
|
||||
|
@ -103,6 +107,7 @@ abstract class BaseTransformer extends TransformerAbstract
|
|||
* Return an ISO-8601 formatted timestamp to use in the API response.
|
||||
*
|
||||
* @param string $timestamp
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function formatTimestamp(string $timestamp): string
|
||||
|
|
|
@ -30,6 +30,7 @@ class DatabaseHostTransformer extends BaseTransformer
|
|||
* Transform database host into a representation for the application API.
|
||||
*
|
||||
* @param \Pterodactyl\Models\DatabaseHost $model
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function transform(DatabaseHost $model)
|
||||
|
@ -54,6 +55,7 @@ class DatabaseHostTransformer extends BaseTransformer
|
|||
* Include the databases associated with this host.
|
||||
*
|
||||
* @param \Pterodactyl\Models\DatabaseHost $model
|
||||
*
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
|
|
|
@ -34,6 +34,7 @@ class EggTransformer extends BaseTransformer
|
|||
* the application api.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Egg $model
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Egg $model)
|
||||
|
@ -74,8 +75,10 @@ class EggTransformer extends BaseTransformer
|
|||
* Include the Nest relationship for the given Egg in the transformation.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Egg $model
|
||||
*
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function includeNest(Egg $model)
|
||||
{
|
||||
|
@ -92,8 +95,10 @@ class EggTransformer extends BaseTransformer
|
|||
* Include the Servers relationship for the given Egg in the transformation.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Egg $model
|
||||
*
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function includeServers(Egg $model)
|
||||
{
|
||||
|
@ -111,6 +116,7 @@ class EggTransformer extends BaseTransformer
|
|||
* extending another.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Egg $model
|
||||
*
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*/
|
||||
public function includeConfig(Egg $model)
|
||||
|
@ -136,6 +142,7 @@ class EggTransformer extends BaseTransformer
|
|||
* Egg is extending another.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Egg $model
|
||||
*
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*/
|
||||
public function includeScript(Egg $model)
|
||||
|
@ -160,8 +167,10 @@ class EggTransformer extends BaseTransformer
|
|||
* Include the variables that are defined for this Egg.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Egg $model
|
||||
*
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function includeVariables(Egg $model)
|
||||
{
|
||||
|
|
|
@ -27,17 +27,17 @@ class LocationTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return a generic transformed location array.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Location $location
|
||||
* @param \Pterodactyl\Models\Location $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Location $location): array
|
||||
public function transform(Location $model): array
|
||||
{
|
||||
return [
|
||||
'id' => $location->id,
|
||||
'short' => $location->short,
|
||||
'long' => $location->long,
|
||||
$location->getUpdatedAtColumn() => $this->formatTimestamp($location->updated_at),
|
||||
$location->getCreatedAtColumn() => $this->formatTimestamp($location->created_at),
|
||||
'id' => $model->id,
|
||||
'short' => $model->short,
|
||||
'long' => $model->long,
|
||||
$model->getUpdatedAtColumn() => $this->formatTimestamp($model->updated_at),
|
||||
$model->getCreatedAtColumn() => $this->formatTimestamp($model->created_at),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -28,12 +28,13 @@ class NodeTransformer extends BaseTransformer
|
|||
* Return a node transformed into a format that can be consumed by the
|
||||
* external administrative API.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @param \Pterodactyl\Models\Node $model
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Node $node): array
|
||||
public function transform(Node $model): array
|
||||
{
|
||||
$response = collect($node->toArray())->mapWithKeys(function ($value, $key) {
|
||||
$response = collect($model->toArray())->mapWithKeys(function ($value, $key) {
|
||||
// I messed up early in 2016 when I named this column as poorly
|
||||
// as I did. This is the tragic result of my mistakes.
|
||||
$key = ($key === 'daemonSFTP') ? 'daemonSftp' : $key;
|
||||
|
@ -41,10 +42,10 @@ class NodeTransformer extends BaseTransformer
|
|||
return [snake_case($key) => $value];
|
||||
})->toArray();
|
||||
|
||||
$response[$node->getUpdatedAtColumn()] = $this->formatTimestamp($node->updated_at);
|
||||
$response[$node->getCreatedAtColumn()] = $this->formatTimestamp($node->created_at);
|
||||
$response[$model->getUpdatedAtColumn()] = $this->formatTimestamp($model->updated_at);
|
||||
$response[$model->getCreatedAtColumn()] = $this->formatTimestamp($model->created_at);
|
||||
|
||||
$resources = $node->servers()->select(['memory', 'disk'])->get();
|
||||
$resources = $model->servers()->select(['memory', 'disk'])->get();
|
||||
|
||||
$response['allocated_resources'] = [
|
||||
'memory' => $resources->sum('memory'),
|
||||
|
@ -58,8 +59,10 @@ class NodeTransformer extends BaseTransformer
|
|||
* Return the nodes associated with this location.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
*
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function includeAllocations(Node $node)
|
||||
{
|
||||
|
@ -78,8 +81,10 @@ class NodeTransformer extends BaseTransformer
|
|||
* Return the nodes associated with this location.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
*
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function includeLocation(Node $node)
|
||||
{
|
||||
|
@ -98,8 +103,10 @@ class NodeTransformer extends BaseTransformer
|
|||
* Return the nodes associated with this location.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
*
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function includeServers(Node $node)
|
||||
{
|
||||
|
|
|
@ -54,45 +54,46 @@ class ServerTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return a generic transformed server array.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @param \Pterodactyl\Models\Server $model
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Server $server): array
|
||||
public function transform(Server $model): array
|
||||
{
|
||||
return [
|
||||
'id' => $server->getKey(),
|
||||
'external_id' => $server->external_id,
|
||||
'uuid' => $server->uuid,
|
||||
'identifier' => $server->uuidShort,
|
||||
'name' => $server->name,
|
||||
'description' => $server->description,
|
||||
'suspended' => (bool) $server->suspended,
|
||||
'id' => $model->getKey(),
|
||||
'external_id' => $model->external_id,
|
||||
'uuid' => $model->uuid,
|
||||
'identifier' => $model->uuidShort,
|
||||
'name' => $model->name,
|
||||
'description' => $model->description,
|
||||
'suspended' => (bool) $model->suspended,
|
||||
'limits' => [
|
||||
'memory' => $server->memory,
|
||||
'swap' => $server->swap,
|
||||
'disk' => $server->disk,
|
||||
'io' => $server->io,
|
||||
'cpu' => $server->cpu,
|
||||
'threads' => $server->threads,
|
||||
'memory' => $model->memory,
|
||||
'swap' => $model->swap,
|
||||
'disk' => $model->disk,
|
||||
'io' => $model->io,
|
||||
'cpu' => $model->cpu,
|
||||
'threads' => $model->threads,
|
||||
],
|
||||
'feature_limits' => [
|
||||
'databases' => $server->database_limit,
|
||||
'allocations' => $server->allocation_limit,
|
||||
'backups' => $server->backup_limit,
|
||||
'databases' => $model->database_limit,
|
||||
'allocations' => $model->allocation_limit,
|
||||
'backups' => $model->backup_limit,
|
||||
],
|
||||
'user' => $server->owner_id,
|
||||
'node' => $server->node_id,
|
||||
'allocation' => $server->allocation_id,
|
||||
'nest' => $server->nest_id,
|
||||
'egg' => $server->egg_id,
|
||||
'user' => $model->owner_id,
|
||||
'node' => $model->node_id,
|
||||
'allocation' => $model->allocation_id,
|
||||
'nest' => $model->nest_id,
|
||||
'egg' => $model->egg_id,
|
||||
'container' => [
|
||||
'startup_command' => $server->startup,
|
||||
'image' => $server->image,
|
||||
'installed' => (int) $server->installed === 1,
|
||||
'environment' => $this->environmentService->handle($server),
|
||||
'startup_command' => $model->startup,
|
||||
'image' => $model->image,
|
||||
'installed' => (int) $model->installed === 1,
|
||||
'environment' => $this->environmentService->handle($model),
|
||||
],
|
||||
$server->getUpdatedAtColumn() => $this->formatTimestamp($server->updated_at),
|
||||
$server->getCreatedAtColumn() => $this->formatTimestamp($server->created_at),
|
||||
$model->getUpdatedAtColumn() => $this->formatTimestamp($model->updated_at),
|
||||
$model->getCreatedAtColumn() => $this->formatTimestamp($model->created_at),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -100,9 +101,11 @@ class ServerTransformer extends BaseTransformer
|
|||
* Return a generic array of allocations for this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
*
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function includeAllocations(Server $server)
|
||||
{
|
||||
|
@ -119,9 +122,11 @@ class ServerTransformer extends BaseTransformer
|
|||
* Return a generic array of data about subusers for this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
*
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function includeSubusers(Server $server)
|
||||
{
|
||||
|
@ -138,9 +143,11 @@ class ServerTransformer extends BaseTransformer
|
|||
* Return a generic array of data about subusers for this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
*
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function includeUser(Server $server)
|
||||
{
|
||||
|
@ -157,9 +164,11 @@ class ServerTransformer extends BaseTransformer
|
|||
* Return a generic array with nest information for this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
*
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function includeNest(Server $server)
|
||||
{
|
||||
|
@ -176,9 +185,11 @@ class ServerTransformer extends BaseTransformer
|
|||
* Return a generic array with egg information for this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
*
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function includeEgg(Server $server)
|
||||
{
|
||||
|
@ -195,9 +206,11 @@ class ServerTransformer extends BaseTransformer
|
|||
* Return a generic array of data about subusers for this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
*
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function includeVariables(Server $server)
|
||||
{
|
||||
|
@ -214,9 +227,11 @@ class ServerTransformer extends BaseTransformer
|
|||
* Return a generic array with location information for this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
*
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function includeLocation(Server $server)
|
||||
{
|
||||
|
@ -233,9 +248,11 @@ class ServerTransformer extends BaseTransformer
|
|||
* Return a generic array with node information for this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
*
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function includeNode(Server $server)
|
||||
{
|
||||
|
@ -252,9 +269,11 @@ class ServerTransformer extends BaseTransformer
|
|||
* Return a generic array with database information for this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
*
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function includeDatabases(Server $server)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue