api(application): relocate egg endpoints
This commit is contained in:
parent
5946210e18
commit
58cfa98b9c
23 changed files with 309 additions and 112 deletions
|
@ -1,67 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Api\Application\Nests;
|
||||
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Pterodactyl\Models\Nest;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
use Pterodactyl\Transformers\Api\Application\EggTransformer;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nests\Eggs\GetEggRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nests\Eggs\GetEggsRequest;
|
||||
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
|
||||
|
||||
class EggController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* EggController constructor.
|
||||
*
|
||||
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
|
||||
*/
|
||||
public function __construct(EggRepositoryInterface $repository)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, Nest $nest): array
|
||||
{
|
||||
$eggs = $this->repository->findWhere([
|
||||
['nest_id', '=', $nest->id],
|
||||
]);
|
||||
|
||||
return $this->fractal->collection($eggs)
|
||||
->transformWith($this->getTransformer(EggTransformer::class))
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, Egg $egg): array
|
||||
{
|
||||
return $this->fractal->item($egg)
|
||||
->transformWith($this->getTransformer(EggTransformer::class))
|
||||
->toArray();
|
||||
}
|
||||
}
|
|
@ -12,9 +12,9 @@ use Pterodactyl\Transformers\Api\Application\NestTransformer;
|
|||
use Pterodactyl\Http\Requests\Api\Application\Nests\GetNestRequest;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nests\GetNestsRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nests\StoreNestRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nests\StoreEggRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nests\UpdateNestRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nests\DeleteNestRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nests\DeleteEggRequest;
|
||||
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
|
||||
|
||||
class NestController extends ApplicationApiController
|
||||
|
@ -105,13 +105,13 @@ class NestController extends ApplicationApiController
|
|||
/**
|
||||
* Creates a new nest.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\StoreNestRequest $request
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\StoreEggRequest $request
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
public function store(StoreNestRequest $request): array
|
||||
public function store(StoreEggRequest $request): array
|
||||
{
|
||||
$nest = $this->nestCreationService->handle($request->validated());
|
||||
|
||||
|
@ -143,13 +143,13 @@ class NestController extends ApplicationApiController
|
|||
/**
|
||||
* Deletes an existing nest.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\DeleteNestRequest $request
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\DeleteEggRequest $request
|
||||
* @param \Pterodactyl\Models\Nest $nest
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
|
||||
*/
|
||||
public function delete(DeleteNestRequest $request, Nest $nest): JsonResponse
|
||||
public function delete(DeleteEggRequest $request, Nest $nest): JsonResponse
|
||||
{
|
||||
$this->nestDeletionService->handle($nest->id);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue