Path: blob/1.0-develop/app/Services/Databases/Hosts/HostDeletionService.php
10263 views
<?php12namespace Pterodactyl\Services\Databases\Hosts;34use Pterodactyl\Exceptions\Service\HasActiveServersException;5use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;6use Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface;78class HostDeletionService9{10/**11* HostDeletionService constructor.12*/13public function __construct(14private DatabaseRepositoryInterface $databaseRepository,15private DatabaseHostRepositoryInterface $repository,16) {17}1819/**20* Delete a specified host from the Panel if no databases are21* attached to it.22*23* @throws HasActiveServersException24*/25public function handle(int $host): int26{27$count = $this->databaseRepository->findCountWhere([['database_host_id', '=', $host]]);28if ($count > 0) {29throw new HasActiveServersException(trans('exceptions.databases.delete_has_databases'));30}3132return $this->repository->delete($host);33}34}353637