nestCreationService = $nestCreationService; $this->nestDeletionService = $nestDeletionService; $this->nestUpdateService = $nestUpdateService; $this->eggImporterService = $eggImporterService; } /** * Return all Nests that exist on the Panel. * * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function index(GetNestsRequest $request): array { $perPage = (int) $request->query('per_page', '10'); if ($perPage > 100) { throw new QueryValueOutOfRangeHttpException('per_page', 1, 100); } $nests = QueryBuilder::for(Nest::query()) ->allowedFilters(['id', 'name', 'author']) ->allowedSorts(['id', 'name', 'author']); if ($perPage > 0) { $nests = $nests->paginate($perPage); } return $this->fractal->collection($nests) ->transformWith(NestTransformer::class) ->toArray(); } /** * Return information about a single Nest model. * * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function view(GetNestRequest $request, Nest $nest): array { return $this->fractal->item($nest) ->transformWith(NestTransformer::class) ->toArray(); } /** * Creates a new nest. * * @throws \Illuminate\Contracts\Container\BindingResolutionException * @throws \Pterodactyl\Exceptions\Model\DataValidationException */ public function store(StoreNestRequest $request): array { $nest = $this->nestCreationService->handle($request->validated()); return $this->fractal->item($nest) ->transformWith(NestTransformer::class) ->toArray(); } /** * Imports an egg. */ public function import(ImportEggRequest $request, Nest $nest): array { $egg = $this->eggImporterService->handleContent( $nest->id, $request->getContent(), $request->headers->get('Content-Type'), ); return $this->fractal->item($egg) ->transformWith(EggTransformer::class) ->toArray(); } /** * Updates an existing nest. * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function update(UpdateNestRequest $request, Nest $nest): array { $this->nestUpdateService->handle($nest->id, $request->validated()); return $this->fractal->item($nest) ->transformWith(NestTransformer::class) ->toArray(); } /** * Deletes an existing nest. * * @throws \Pterodactyl\Exceptions\Service\HasActiveServersException */ public function delete(DeleteNestRequest $request, Nest $nest): Response { $this->nestDeletionService->handle($nest->id); return $this->returnNoContent(); } }