Begin working on administrative server view changes
Also includes tests for the DatabaseCreation service.
This commit is contained in:
parent
0c513f24d5
commit
580e5ac569
18 changed files with 584 additions and 135 deletions
|
@ -37,4 +37,31 @@ class NodeRepository extends SearchableRepository implements NodeRepositoryInter
|
|||
{
|
||||
return Node::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getNodesForLocation($location)
|
||||
{
|
||||
$instance = $this->getBuilder()->with('allocations')->where('location_id', $location)->get();
|
||||
|
||||
return $instance->map(function ($item) {
|
||||
$filtered = $item->allocations->where('server_id', null)->map(function ($map) {
|
||||
return collect($map)->only(['id', 'ip', 'port']);
|
||||
});
|
||||
|
||||
$item->ports = $filtered->map(function ($map) {
|
||||
return [
|
||||
'id' => $map['id'],
|
||||
'text' => sprintf('%s:%s', $map['ip'], $map['port']),
|
||||
];
|
||||
})->values();
|
||||
|
||||
return [
|
||||
'id' => $item->id,
|
||||
'text' => $item->name,
|
||||
'allocations' => $item->ports,
|
||||
];
|
||||
})->values();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue