middleware('auth'); $this->middleware('admin'); } public function postNewServerGetNodes(Request $request) { if(!$request->input('location')) { return response()->json([ 'error' => 'Missing location in request.' ], 500); } return response(Node::select('id', 'name', 'public')->where('location', $request->input('location'))->get()->toJson()); } public function postNewServerGetIps(Request $request) { if(!$request->input('node')) { return response()->json([ 'error' => 'Missing node in request.' ], 500); } $ips = Allocation::where('node', $request->input('node'))->whereNull('assigned_to')->get(); $listing = []; foreach($ips as &$ip) { if (array_key_exists($ip->ip, $listing)) { $listing[$ip->ip] = array_merge($listing[$ip->ip], [$ip->port]); } else { $listing[$ip->ip] = [$ip->port]; } } return response()->json($listing); } }