pelican-panel-mirror/app/Services/Servers/ReinstallServerService.php
Boy132 d555c42644
Update all dependencies (#712)
* update composer.lock

* run pint

* fix phpstan

* update migrations (sqlite `dropForeign`)

* fix migrations

* Reset these back for now

* Alphabetize the rules

* run `php artisan filament:upgrade`

---------

Co-authored-by: Lance Pioch <git@lance.sh>
2024-11-22 09:27:57 +01:00

36 lines
866 B
PHP

<?php
namespace App\Services\Servers;
use App\Enums\ServerState;
use App\Models\Server;
use Illuminate\Database\ConnectionInterface;
use App\Repositories\Daemon\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
{
return $this->connection->transaction(function () use ($server) {
$server->fill(['status' => ServerState::Installing])->save();
$this->daemonServerRepository->setServer($server)->reinstall();
return $server->refresh();
});
}
}