Add server build management to API
This commit is contained in:
parent
d3dba3fcf9
commit
aca0819bcd
8 changed files with 202 additions and 128 deletions
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Repositories\Eloquent;
|
||||
|
||||
use Pterodactyl\Models\Node;
|
||||
use Illuminate\Support\Collection;
|
||||
use Pterodactyl\Models\Allocation;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
|
@ -68,4 +67,31 @@ class AllocationRepository extends EloquentRepository implements AllocationRepos
|
|||
->orderByRaw('INET_ATON(ip) ASC')
|
||||
->get($this->getColumns());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all of the allocations that exist for a node that are not currently
|
||||
* allocated.
|
||||
*
|
||||
* @param int $node
|
||||
* @return array
|
||||
*/
|
||||
public function getUnassignedAllocationIds(int $node): array
|
||||
{
|
||||
$results = $this->getBuilder()->select('id')->whereNull('server_id')->where('node_id', $node)->get();
|
||||
|
||||
return $results->pluck('id')->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all allocations that are currently assigned to a given server.
|
||||
*
|
||||
* @param int $server
|
||||
* @return array
|
||||
*/
|
||||
public function getAssignedAllocationIds(int $server): array
|
||||
{
|
||||
$results = $this->getBuilder()->select('id')->where('server_id', $server)->get();
|
||||
|
||||
return $results->pluck('id')->toArray();
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue