mirror of
https://github.com/pterodactyl/panel.git
synced 2026-12-01 11:55:51 -05:00
24 lines
667 B
PHP
24 lines
667 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pterodactyl\Actions\Servers;
|
|
|
|
use Pterodactyl\Contracts\Servers\TogglesServerInstallStatus;
|
|
use Pterodactyl\Exceptions\DisplayException;
|
|
use Pterodactyl\Models\Server;
|
|
|
|
final readonly class ToggleServerInstallStatus implements TogglesServerInstallStatus
|
|
{
|
|
public function toggle(Server $server): void
|
|
{
|
|
if ($server->status === Server::STATUS_INSTALL_FAILED) {
|
|
throw new DisplayException(trans('admin/server.exceptions.marked_as_failed'));
|
|
}
|
|
|
|
$server->forceFill([
|
|
'status' => $server->isInstalled() ? Server::STATUS_INSTALLING : null,
|
|
])->saveOrFail();
|
|
}
|
|
}
|