repository = $repository; $this->reinstallServerService = $reinstallServerService; } /** * Renames a server. * * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Settings\RenameServerRequest $request * @param \Pterodactyl\Models\Server $server * @return \Illuminate\Http\JsonResponse * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function rename(RenameServerRequest $request, Server $server) { $this->repository->update($server->id, [ 'name' => $request->input('name'), ]); return new JsonResponse([], Response::HTTP_NO_CONTENT); } /** * Reinstalls the server on the daemon. * * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Settings\ReinstallServerRequest $request * @param \Pterodactyl\Models\Server $server * @return \Illuminate\Http\JsonResponse * * @throws \Throwable */ public function reinstall(ReinstallServerRequest $request, Server $server) { $this->reinstallServerService->handle($server); return new JsonResponse([], Response::HTTP_ACCEPTED); } /** * Changes the Docker image in use by the server. * * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Settings\SetDockerImageRequest $request * @param \Pterodactyl\Models\Server $server * @return \Illuminate\Http\JsonResponse * * @throws \Throwable */ public function dockerImage(SetDockerImageRequest $request, Server $server) { if (! in_array($server->image, $server->egg->docker_images)) { throw new BadRequestHttpException( 'This server\'s Docker image has been manually set by an administrator and cannot be updated.' ); } $server->forceFill(['image' => $request->input('docker_image')])->saveOrFail(); return new JsonResponse([], Response::HTTP_NO_CONTENT); } }