2018-01-27 18:38:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Controllers\Api\Application\Nests;
|
|
|
|
|
|
|
|
use Pterodactyl\Models\Egg;
|
|
|
|
use Pterodactyl\Models\Nest;
|
|
|
|
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
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Return all eggs that exist for a given nest.
|
|
|
|
*/
|
2022-05-22 18:10:01 +00:00
|
|
|
public function index(GetEggsRequest $request, Nest $nest): array
|
2018-01-27 18:38:56 +00:00
|
|
|
{
|
2022-05-22 18:10:01 +00:00
|
|
|
return $this->fractal->collection($nest->eggs)
|
2018-01-27 18:38:56 +00:00
|
|
|
->transformWith($this->getTransformer(EggTransformer::class))
|
|
|
|
->toArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a single egg that exists on the specified nest.
|
|
|
|
*/
|
2022-05-22 18:10:01 +00:00
|
|
|
public function view(GetEggRequest $request, Nest $nest, Egg $egg): array
|
2018-01-27 18:38:56 +00:00
|
|
|
{
|
2022-05-22 18:10:01 +00:00
|
|
|
return $this->fractal->item($egg)
|
2018-01-27 18:38:56 +00:00
|
|
|
->transformWith($this->getTransformer(EggTransformer::class))
|
|
|
|
->toArray();
|
|
|
|
}
|
|
|
|
}
|