2018-01-27 18:38:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Controllers\Api\Application\Nests;
|
|
|
|
|
|
|
|
use Pterodactyl\Models\Nest;
|
|
|
|
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
|
|
|
|
use Pterodactyl\Transformers\Api\Application\NestTransformer;
|
|
|
|
use Pterodactyl\Http\Requests\Api\Application\Nests\GetNestsRequest;
|
|
|
|
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
|
|
|
|
|
|
|
|
class NestController extends ApplicationApiController
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* NestController constructor.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function __construct(private NestRepositoryInterface $repository)
|
2018-01-27 18:38:56 +00:00
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return all Nests that exist on the Panel.
|
|
|
|
*/
|
|
|
|
public function index(GetNestsRequest $request): array
|
|
|
|
{
|
2021-03-26 16:03:51 +00:00
|
|
|
$nests = $this->repository->paginated($request->query('per_page') ?? 50);
|
2018-01-27 18:38:56 +00:00
|
|
|
|
|
|
|
return $this->fractal->collection($nests)
|
|
|
|
->transformWith($this->getTransformer(NestTransformer::class))
|
|
|
|
->toArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return information about a single Nest model.
|
|
|
|
*/
|
2022-05-22 18:10:01 +00:00
|
|
|
public function view(GetNestsRequest $request, Nest $nest): array
|
2018-01-27 18:38:56 +00:00
|
|
|
{
|
2022-05-22 18:10:01 +00:00
|
|
|
return $this->fractal->item($nest)
|
2018-01-27 18:38:56 +00:00
|
|
|
->transformWith($this->getTransformer(NestTransformer::class))
|
|
|
|
->toArray();
|
|
|
|
}
|
|
|
|
}
|