mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-24 10:44:45 +02:00

* Fix copy paste AllocationsRelationManager * We shouldn't let the user know if the user is correct but the password isn't * Add missing `trans()` `EditServer` * Add missing `trans()` User `ServersRelationManager` * Replace every `__()` with `trans()` helper * Fix `exceptions` `User` Model * Replace `Translator->get()` with `trans()` helper * Revert "We shouldn't let the user know if the user is correct but the password isn't" This reverts commit e156ee4b38e9e969662a532648c78fdc1e9b0166. that's stock laravel, therefore it needs to stay
28 lines
609 B
PHP
28 lines
609 B
PHP
<?php
|
|
|
|
namespace App\Services\Nodes;
|
|
|
|
use App\Models\Node;
|
|
use App\Exceptions\Service\HasActiveServersException;
|
|
|
|
class NodeDeletionService
|
|
{
|
|
/**
|
|
* Delete a node from the panel if no servers are attached to it.
|
|
*
|
|
* @throws HasActiveServersException
|
|
*/
|
|
public function handle(int|Node $node): int
|
|
{
|
|
if (is_int($node)) {
|
|
$node = Node::findOrFail($node);
|
|
}
|
|
|
|
if ($node->servers()->count() > 0) {
|
|
throw new HasActiveServersException(trans('exceptions.node.servers_attached'));
|
|
}
|
|
|
|
return (int) $node->delete();
|
|
}
|
|
}
|