Path: blob/1.0-develop/app/Services/Allocations/AllocationDeletionService.php
14042 views
<?php12namespace Pterodactyl\Services\Allocations;34use Pterodactyl\Models\Allocation;5use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;6use Pterodactyl\Exceptions\Service\Allocation\ServerUsingAllocationException;78class AllocationDeletionService9{10/**11* AllocationDeletionService constructor.12*/13public function __construct(private AllocationRepositoryInterface $repository)14{15}1617/**18* Delete an allocation from the database only if it does not have a server19* that is actively attached to it.20*21* @throws ServerUsingAllocationException22*/23public function handle(Allocation $allocation): int24{25if (!is_null($allocation->server_id)) {26throw new ServerUsingAllocationException(trans('exceptions.allocations.server_using'));27}2829return $this->repository->delete($allocation->id);30}31}323334