Path: blob/1.0-develop/app/Services/Nests/NestDeletionService.php
10287 views
<?php12namespace Pterodactyl\Services\Nests;34use Pterodactyl\Contracts\Repository\NestRepositoryInterface;5use Pterodactyl\Exceptions\Service\HasActiveServersException;6use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;78class NestDeletionService9{10/**11* NestDeletionService constructor.12*/13public function __construct(14protected ServerRepositoryInterface $serverRepository,15protected NestRepositoryInterface $repository,16) {17}1819/**20* Delete a nest from the system only if there are no servers attached to it.21*22* @throws HasActiveServersException23*/24public function handle(int $nest): int25{26$count = $this->serverRepository->findCountWhere([['nest_id', '=', $nest]]);27if ($count > 0) {28throw new HasActiveServersException(trans('exceptions.nest.delete_has_servers'));29}3031return $this->repository->delete($nest);32}33}343536