Path: blob/1.0-develop/app/Http/Controllers/Api/Application/Servers/ServerDetailsController.php
10277 views
<?php12namespace Pterodactyl\Http\Controllers\Api\Application\Servers;34use Pterodactyl\Models\Server;5use Pterodactyl\Services\Servers\BuildModificationService;6use Pterodactyl\Services\Servers\DetailsModificationService;7use Pterodactyl\Transformers\Api\Application\ServerTransformer;8use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;9use Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerDetailsRequest;10use Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerBuildConfigurationRequest;1112class ServerDetailsController extends ApplicationApiController13{14/**15* ServerDetailsController constructor.16*/17public function __construct(18private BuildModificationService $buildModificationService,19private DetailsModificationService $detailsModificationService,20) {21parent::__construct();22}2324/**25* Update the details for a specific server.26*27* @throws \Pterodactyl\Exceptions\DisplayException28* @throws \Pterodactyl\Exceptions\Model\DataValidationException29* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException30*/31public function details(UpdateServerDetailsRequest $request, Server $server): array32{33$updated = $this->detailsModificationService->returnUpdatedModel()->handle(34$server,35$request->validated()36);3738return $this->fractal->item($updated)39->transformWith($this->getTransformer(ServerTransformer::class))40->toArray();41}4243/**44* Update the build details for a specific server.45*46* @throws \Pterodactyl\Exceptions\DisplayException47* @throws \Pterodactyl\Exceptions\Model\DataValidationException48* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException49*/50public function build(UpdateServerBuildConfigurationRequest $request, Server $server): array51{52$server = $this->buildModificationService->handle($server, $request->validated());5354return $this->fractal->item($server)55->transformWith($this->getTransformer(ServerTransformer::class))56->toArray();57}58}596061