public function getNew(Request $request) { return view('admin.servers.new', ['locations' => Models\Location::all(), 'services' => Models\Service::all()]); }
public function getView(Request $request, $id) { $node = Models\Node::findOrFail($id); $allocations = []; $alloc = Models\Allocation::select('ip', 'port', 'assigned_to')->where('node', $node->id)->orderBy('ip', 'asc')->orderBy('port', 'asc')->get(); if ($alloc) { foreach ($alloc as &$alloc) { if (!array_key_exists($alloc->ip, $allocations)) { $allocations[$alloc->ip] = [['port' => $alloc->port, 'assigned_to' => $alloc->assigned_to]]; } else { array_push($allocations[$alloc->ip], ['port' => $alloc->port, 'assigned_to' => $alloc->assigned_to]); } } } return view('admin.nodes.view', ['node' => $node, 'servers' => Models\Server::select('servers.*', 'users.email as a_ownerEmail', 'services.name as a_serviceName')->join('users', 'users.id', '=', 'servers.owner')->join('services', 'services.id', '=', 'servers.service')->where('node', $id)->paginate(10), 'stats' => Models\Server::select(DB::raw('SUM(memory) as memory, SUM(disk) as disk'))->where('node', $node->id)->first(), 'locations' => Models\Location::all(), 'allocations' => json_decode(json_encode($allocations), false)]); }