parent
3b5e1fc7b1
commit
ac2abd89e6
6 changed files with 9 additions and 31 deletions
|
@ -60,10 +60,9 @@ interface NodeRepositoryInterface extends RepositoryInterface, SearchableInterfa
|
|||
public function getNodeServers($id);
|
||||
|
||||
/**
|
||||
* Return a collection of nodes beloning to a specific location for use on frontend display.
|
||||
* Return a collection of nodes for all locations to use in server creation UI.
|
||||
*
|
||||
* @param int $location
|
||||
* @return mixed
|
||||
*/
|
||||
public function getNodesForLocation($location);
|
||||
public function getNodesForServerCreation();
|
||||
}
|
||||
|
|
|
@ -231,6 +231,7 @@ class ServersController extends Controller
|
|||
$nests = $this->nestRepository->getWithEggs();
|
||||
|
||||
Javascript::put([
|
||||
'nodeData' => $this->nodeRepository->getNodesForServerCreation(),
|
||||
'nests' => $nests->map(function ($item) {
|
||||
return array_merge($item->toArray(), [
|
||||
'eggs' => $item->eggs->keyBy('id')->toArray(),
|
||||
|
@ -262,17 +263,6 @@ class ServersController extends Controller
|
|||
return redirect()->route('admin.servers.view', $server->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a tree of all avaliable nodes in a given location.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function nodes(Request $request)
|
||||
{
|
||||
return $this->nodeRepository->getNodesForLocation($request->input('location'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the index when viewing a specific server.
|
||||
*
|
||||
|
|
|
@ -129,9 +129,9 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getNodesForLocation($location)
|
||||
public function getNodesForServerCreation()
|
||||
{
|
||||
$instance = $this->getBuilder()->with('allocations')->where('location_id', $location)->get();
|
||||
$instance = $this->getBuilder()->with('allocations')->get();
|
||||
|
||||
return $instance->map(function ($item) {
|
||||
$filtered = $item->allocations->where('server_id', null)->map(function ($map) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue