Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Http/Controllers/Api/Application/Nests/NestController.php
10277 views
1
<?php
2
3
namespace Pterodactyl\Http\Controllers\Api\Application\Nests;
4
5
use Pterodactyl\Models\Nest;
6
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
7
use Pterodactyl\Transformers\Api\Application\NestTransformer;
8
use Pterodactyl\Http\Requests\Api\Application\Nests\GetNestsRequest;
9
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
10
11
class NestController extends ApplicationApiController
12
{
13
/**
14
* NestController constructor.
15
*/
16
public function __construct(private NestRepositoryInterface $repository)
17
{
18
parent::__construct();
19
}
20
21
/**
22
* Return all Nests that exist on the Panel.
23
*/
24
public function index(GetNestsRequest $request): array
25
{
26
$nests = $this->repository->paginated($request->query('per_page') ?? 50);
27
28
return $this->fractal->collection($nests)
29
->transformWith($this->getTransformer(NestTransformer::class))
30
->toArray();
31
}
32
33
/**
34
* Return information about a single Nest model.
35
*/
36
public function view(GetNestsRequest $request, Nest $nest): array
37
{
38
return $this->fractal->item($nest)
39
->transformWith($this->getTransformer(NestTransformer::class))
40
->toArray();
41
}
42
}
43
44