mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-28 04:34:45 +02:00
25 lines
673 B
PHP
25 lines
673 B
PHP
<?php
|
|
|
|
namespace App\Services\Allocations;
|
|
|
|
use App\Models\Allocation;
|
|
use App\Exceptions\Service\Allocation\ServerUsingAllocationException;
|
|
|
|
class AllocationDeletionService
|
|
{
|
|
/**
|
|
* Delete an allocation from the database only if it does not have a server
|
|
* that is actively attached to it.
|
|
*
|
|
* @throws \App\Exceptions\Service\Allocation\ServerUsingAllocationException
|
|
*/
|
|
public function handle(Allocation $allocation): int
|
|
{
|
|
if (!is_null($allocation->server_id)) {
|
|
throw new ServerUsingAllocationException(trans('exceptions.allocations.server_using'));
|
|
}
|
|
|
|
return (int) $allocation->delete();
|
|
}
|
|
}
|