Add server build management to API

This commit is contained in:
Dane Everitt 2018-01-21 16:02:03 -06:00
parent d3dba3fcf9
commit aca0819bcd
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
8 changed files with 202 additions and 128 deletions

View file

@ -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();
}
}