Replace allocation repository

This commit is contained in:
Lance Pioch 2022-10-23 02:02:58 -04:00
parent 860b2d890b
commit cd49324d46
10 changed files with 95 additions and 164 deletions

View file

@ -3,18 +3,10 @@
namespace Pterodactyl\Services\Allocations;
use Pterodactyl\Models\Allocation;
use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
use Pterodactyl\Exceptions\Service\Allocation\ServerUsingAllocationException;
class AllocationDeletionService
{
/**
* AllocationDeletionService constructor.
*/
public function __construct(private AllocationRepositoryInterface $repository)
{
}
/**
* Delete an allocation from the database only if it does not have a server
* that is actively attached to it.
@ -27,6 +19,6 @@ class AllocationDeletionService
throw new ServerUsingAllocationException(trans('exceptions.allocations.server_using'));
}
return $this->repository->delete($allocation->id);
return $allocation->delete();
}
}

View file

@ -4,10 +4,10 @@ namespace Pterodactyl\Services\Allocations;
use Exception;
use IPTools\Network;
use Pterodactyl\Models\Allocation;
use Pterodactyl\Models\Node;
use Illuminate\Database\ConnectionInterface;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
use Pterodactyl\Exceptions\Service\Allocation\CidrOutOfRangeException;
use Pterodactyl\Exceptions\Service\Allocation\PortOutOfRangeException;
use Pterodactyl\Exceptions\Service\Allocation\InvalidPortMappingException;
@ -25,7 +25,7 @@ class AssignmentService
/**
* AssignmentService constructor.
*/
public function __construct(protected AllocationRepositoryInterface $repository, protected ConnectionInterface $connection)
public function __construct(protected ConnectionInterface $connection)
{
}
@ -101,7 +101,7 @@ class AssignmentService
];
}
$this->repository->insertIgnore($insertData);
Allocation::query()->insertOrIgnore($insertData);
}
}