Files

28 lines
775 B
PHP
Raw Permalink Normal View History

2026-10-05 18:10:18 -04:00
<?php
declare(strict_types=1);
namespace Pterodactyl\Actions\Nodes;
2026-10-11 03:05:36 -04:00
use Illuminate\Support\Facades\DB;
2026-10-05 18:10:18 -04:00
use Pterodactyl\Contracts\Nodes\DeletesNodes;
use Pterodactyl\Exceptions\Service\HasActiveServersException;
use Pterodactyl\Models\Node;
final class DeleteNode implements DeletesNodes
{
public function delete(Node $node): void
{
if ($node->servers()->exists()) {
throw new HasActiveServersException(trans('exceptions.node.servers_attached'));
}
2026-10-11 03:05:36 -04:00
DB::transaction(function () use ($node): void {
// Tag attachments are polymorphic, so no foreign key removes them with the node.
$node->eggTags()->detach();
$node->deploymentTags()->detach();
$node->delete();
});
2026-10-05 18:10:18 -04:00
}
}