2026-10-11 03:13:43 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace Pterodactyl\Actions\Servers;
|
|
|
|
|
|
|
|
|
|
use Pterodactyl\Contracts\Servers\UpdatesServerVariable;
|
2026-10-11 14:06:11 -04:00
|
|
|
use Pterodactyl\Facades\Activity;
|
|
|
|
|
use Pterodactyl\Models\EggVariable;
|
2026-10-11 03:13:43 -04:00
|
|
|
use Pterodactyl\Models\Server;
|
|
|
|
|
use Pterodactyl\Models\ServerVariable;
|
|
|
|
|
|
|
|
|
|
final readonly class UpdateServerVariable implements UpdatesServerVariable
|
|
|
|
|
{
|
|
|
|
|
public function update(Server $server, int $variableId, string $value): void
|
|
|
|
|
{
|
2026-10-11 14:06:11 -04:00
|
|
|
$original = ServerVariable::query()->where('server_id', $server->id)->where('variable_id', $variableId)->first()?->variable_value;
|
|
|
|
|
|
2026-10-11 03:13:43 -04:00
|
|
|
ServerVariable::query()->updateOrCreate(
|
|
|
|
|
['server_id' => $server->id, 'variable_id' => $variableId],
|
|
|
|
|
['variable_value' => $value],
|
|
|
|
|
);
|
2026-10-11 14:06:11 -04:00
|
|
|
|
|
|
|
|
if ($original !== $value) {
|
|
|
|
|
$variable = EggVariable::query()->findOrFail($variableId);
|
|
|
|
|
|
|
|
|
|
Activity::event('server:startup.edit')
|
|
|
|
|
->subject($server, $variable)
|
|
|
|
|
->property(['variable' => $variable->env_variable, 'old' => $original, 'new' => $value])
|
|
|
|
|
->log();
|
|
|
|
|
}
|
2026-10-11 03:13:43 -04:00
|
|
|
}
|
|
|
|
|
}
|