diff --git a/app/Http/Controllers/Api/Application/Nests/NestController.php b/app/Http/Controllers/Api/Application/Nests/NestController.php index 89d40c6a..e37295be 100644 --- a/app/Http/Controllers/Api/Application/Nests/NestController.php +++ b/app/Http/Controllers/Api/Application/Nests/NestController.php @@ -12,9 +12,9 @@ use Pterodactyl\Transformers\Api\Application\NestTransformer; use Pterodactyl\Http\Requests\Api\Application\Nests\GetNestRequest; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Pterodactyl\Http\Requests\Api\Application\Nests\GetNestsRequest; -use Pterodactyl\Http\Requests\Api\Application\Nests\StoreEggRequest; +use Pterodactyl\Http\Requests\Api\Application\Nests\StoreNestRequest; use Pterodactyl\Http\Requests\Api\Application\Nests\UpdateNestRequest; -use Pterodactyl\Http\Requests\Api\Application\Nests\DeleteEggRequest; +use Pterodactyl\Http\Requests\Api\Application\Nests\DeleteNestRequest; use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController; class NestController extends ApplicationApiController @@ -75,7 +75,7 @@ class NestController extends ApplicationApiController $perPage = $request->query('per_page', 10); if ($perPage < 1) { $perPage = 10; - } else if ($perPage > 100) { + } elseif ($perPage > 100) { throw new BadRequestHttpException('"per_page" query parameter must be below 100.'); } @@ -105,13 +105,13 @@ class NestController extends ApplicationApiController /** * Creates a new nest. * - * @param \Pterodactyl\Http\Requests\Api\Application\Nests\StoreEggRequest $request + * @param \Pterodactyl\Http\Requests\Api\Application\Nests\StoreNestRequest $request * * @return array * @throws \Illuminate\Contracts\Container\BindingResolutionException * @throws \Pterodactyl\Exceptions\Model\DataValidationException */ - public function store(StoreEggRequest $request): array + public function store(StoreNestRequest $request): array { $nest = $this->nestCreationService->handle($request->validated()); @@ -143,13 +143,13 @@ class NestController extends ApplicationApiController /** * Deletes an existing nest. * - * @param \Pterodactyl\Http\Requests\Api\Application\Nests\DeleteEggRequest $request + * @param \Pterodactyl\Http\Requests\Api\Application\Nests\DeleteNestRequest $request * @param \Pterodactyl\Models\Nest $nest * * @return \Illuminate\Http\JsonResponse * @throws \Pterodactyl\Exceptions\Service\HasActiveServersException */ - public function delete(DeleteEggRequest $request, Nest $nest): JsonResponse + public function delete(DeleteNestRequest $request, Nest $nest): JsonResponse { $this->nestDeletionService->handle($nest->id); diff --git a/app/Http/Requests/Api/Application/Nests/UpdateNestRequest.php b/app/Http/Requests/Api/Application/Nests/UpdateNestRequest.php index 59536a8f..7f425ddf 100644 --- a/app/Http/Requests/Api/Application/Nests/UpdateNestRequest.php +++ b/app/Http/Requests/Api/Application/Nests/UpdateNestRequest.php @@ -4,7 +4,7 @@ namespace Pterodactyl\Http\Requests\Api\Application\Nests; use Pterodactyl\Models\Nest; -class UpdateNestRequest extends StoreEggRequest +class UpdateNestRequest extends StoreNestRequest { /** * ? diff --git a/resources/scripts/api/admin/nests/updateNest.ts b/resources/scripts/api/admin/nests/updateNest.ts new file mode 100644 index 00000000..9a87c76d --- /dev/null +++ b/resources/scripts/api/admin/nests/updateNest.ts @@ -0,0 +1,12 @@ +import http from '@/api/http'; +import { Nest, rawDataToNest } from '@/api/admin/nests/getNests'; + +export default (id: number, name: string, description?: string): Promise => { + return new Promise((resolve, reject) => { + http.patch(`/api/application/nests/${id}`, { + name, description, + }) + .then(({ data }) => resolve(rawDataToNest(data))) + .catch(reject); + }); +};