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
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface
|
|
|
|
*/
|
|
|
|
private $repository;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* NestController constructor.
|
|
|
|
*
|
|
|
|
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository
|
|
|
|
*/
|
|
|
|
public function __construct(NestRepositoryInterface $repository)
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
$this->repository = $repository;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return all Nests that exist on the Panel.
|
|
|
|
*
|
|
|
|
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\GetNestsRequest $request
|
2021-01-01 22:55:30 +00:00
|
|
|
*
|
2018-01-27 18:38:56 +00:00
|
|
|
* @return array
|
2021-01-01 22:55:30 +00:00
|
|
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
2018-01-27 18:38:56 +00:00
|
|
|
*/
|
|
|
|
public function index(GetNestsRequest $request): array
|
|
|
|
{
|
2021-01-03 19:32:39 +00:00
|
|
|
$nests = $this->repository->paginated(1);
|
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.
|
|
|
|
*
|
|
|
|
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\GetNestsRequest $request
|
2021-01-01 22:55:30 +00:00
|
|
|
* @param \Pterodactyl\Models\Nest $nest
|
|
|
|
*
|
2018-01-27 18:38:56 +00:00
|
|
|
* @return array
|
2021-01-01 22:55:30 +00:00
|
|
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
2018-01-27 18:38:56 +00:00
|
|
|
*/
|
2021-01-01 22:55:30 +00:00
|
|
|
public function view(GetNestsRequest $request, Nest $nest): array
|
2018-01-27 18:38:56 +00:00
|
|
|
{
|
2021-01-01 22:55:30 +00:00
|
|
|
return $this->fractal->item($nest)
|
2018-01-27 18:38:56 +00:00
|
|
|
->transformWith($this->getTransformer(NestTransformer::class))
|
|
|
|
->toArray();
|
|
|
|
}
|
|
|
|
}
|