mirror of
https://github.com/pterodactyl/panel.git
synced 2026-12-02 20:35:50 -05:00
Co-authored-by: Anthony <anthony@infraly.co> Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
27 lines
706 B
PHP
27 lines
706 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pterodactyl\Actions\Allocations;
|
|
|
|
use Pterodactyl\Contracts\Allocations\DeletesAllocations;
|
|
use Pterodactyl\Exceptions\Service\Allocation\ServerUsingAllocationException;
|
|
use Pterodactyl\Models\Allocation;
|
|
|
|
final class DeleteAllocation implements DeletesAllocations
|
|
{
|
|
/**
|
|
* Delete an allocation, provided no server is attached to it.
|
|
*
|
|
* @throws ServerUsingAllocationException
|
|
*/
|
|
public function delete(Allocation $allocation): void
|
|
{
|
|
if ($allocation->server_id !== null) {
|
|
throw new ServerUsingAllocationException(trans('exceptions.allocations.server_using'));
|
|
}
|
|
|
|
$allocation->delete();
|
|
}
|
|
}
|