misc_pterodactyl-panel/app/Services/Servers/ReinstallServerService.php

36 lines
869 B
PHP
Raw Normal View History

<?php
namespace Pterodactyl\Services\Servers;
use Pterodactyl\Models\Server;
use Illuminate\Database\ConnectionInterface;
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
class ReinstallServerService
{
/**
* ReinstallService constructor.
*/
public function __construct(
private ConnectionInterface $connection,
private DaemonServerRepository $daemonServerRepository
) {
}
/**
* Reinstall a server on the remote daemon.
*
* @throws \Throwable
*/
public function handle(Server $server): Server
{
2020-06-25 05:18:48 +00:00
return $this->connection->transaction(function () use ($server) {
$server->fill(['status' => Server::STATUS_INSTALLING])->save();
$this->daemonServerRepository->setServer($server)->reinstall();
2020-10-06 04:54:29 +00:00
return $server->refresh();
2020-06-25 05:18:48 +00:00
});
}
}