Files

27 lines
806 B
PHP
Raw Permalink Normal View History

2026-10-05 18:10:18 -04:00
<?php
declare(strict_types=1);
namespace Pterodactyl\Actions\Allocations;
use Pterodactyl\Contracts\Allocations\SetsPrimaryAllocations;
2026-10-11 14:10:47 -04:00
use Pterodactyl\Facades\Activity;
2026-10-05 18:10:18 -04:00
use Pterodactyl\Models\Allocation;
use Pterodactyl\Models\Server;
final class SetPrimaryAllocation implements SetsPrimaryAllocations
{
public function setPrimary(Server $server, Allocation $allocation): Allocation
{
$server->update(['allocation_id' => $allocation->id]);
2026-10-11 14:10:47 -04:00
Activity::event('server:allocation.primary')
->subject($server, $allocation)
->property('allocation', $allocation->toString())
->log();
2026-10-08 17:40:00 -04:00
// The allocation row is unchanged, but a loaded server relation still holds the old primary.
return $allocation->unsetRelation('server');
2026-10-05 18:10:18 -04:00
}
}