2019-12-10 06:03:10 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Controllers\Api\Client\Servers;
|
|
|
|
|
|
|
|
use Illuminate\Http\Response;
|
|
|
|
use Pterodactyl\Models\Server;
|
2020-04-03 21:43:24 +00:00
|
|
|
use Illuminate\Http\JsonResponse;
|
2019-12-10 06:03:10 +00:00
|
|
|
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
2020-04-03 21:43:24 +00:00
|
|
|
use Pterodactyl\Services\Servers\ReinstallServerService;
|
2019-12-10 06:03:10 +00:00
|
|
|
use Pterodactyl\Http\Controllers\Api\Client\ClientApiController;
|
|
|
|
use Pterodactyl\Http\Requests\Api\Client\Servers\Settings\RenameServerRequest;
|
2020-04-03 21:43:24 +00:00
|
|
|
use Pterodactyl\Http\Requests\Api\Client\Servers\Settings\ReinstallServerRequest;
|
2019-12-10 06:03:10 +00:00
|
|
|
|
|
|
|
class SettingsController extends ClientApiController
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Repositories\Eloquent\ServerRepository
|
|
|
|
*/
|
|
|
|
private $repository;
|
|
|
|
|
2020-04-03 21:43:24 +00:00
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Services\Servers\ReinstallServerService
|
|
|
|
*/
|
|
|
|
private $reinstallServerService;
|
|
|
|
|
2019-12-10 06:03:10 +00:00
|
|
|
/**
|
|
|
|
* SettingsController constructor.
|
|
|
|
*
|
|
|
|
* @param \Pterodactyl\Repositories\Eloquent\ServerRepository $repository
|
2020-04-03 21:43:24 +00:00
|
|
|
* @param \Pterodactyl\Services\Servers\ReinstallServerService $reinstallServerService
|
2019-12-10 06:03:10 +00:00
|
|
|
*/
|
2020-04-03 21:43:24 +00:00
|
|
|
public function __construct(
|
|
|
|
ServerRepository $repository,
|
|
|
|
ReinstallServerService $reinstallServerService
|
|
|
|
) {
|
2019-12-10 06:03:10 +00:00
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
$this->repository = $repository;
|
2020-04-03 21:43:24 +00:00
|
|
|
$this->reinstallServerService = $reinstallServerService;
|
2019-12-10 06:03:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renames a server.
|
|
|
|
*
|
|
|
|
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Settings\RenameServerRequest $request
|
|
|
|
* @param \Pterodactyl\Models\Server $server
|
2020-04-03 21:43:24 +00:00
|
|
|
* @return \Illuminate\Http\JsonResponse
|
2019-12-10 06:03:10 +00:00
|
|
|
*
|
|
|
|
* @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'),
|
|
|
|
]);
|
|
|
|
|
2020-04-03 21:43:24 +00:00
|
|
|
return JsonResponse::create([], 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->reinstall($server);
|
|
|
|
|
|
|
|
return JsonResponse::create([], Response::HTTP_ACCEPTED);
|
2019-12-10 06:03:10 +00:00
|
|
|
}
|
|
|
|
}
|