Prevent deleting nodes if there are active servers

This commit is contained in:
Lance Pioch 2024-04-13 16:49:53 -04:00
parent 18e5c17ebe
commit 06c773c3b1

View File

@ -2,6 +2,7 @@
namespace App\Models;
use App\Exceptions\Service\HasActiveServersException;
use App\Repositories\Daemon\DaemonConfigurationRepository;
use Exception;
use Illuminate\Support\Str;
@ -135,6 +136,10 @@ class Node extends Model
return true;
});
static::deleting(function (self $node) {
throw_if($node->servers()->count(), new HasActiveServersException(trans('exceptions.egg.delete_has_servers')));
});
}
/**