public static function getAll() { $conn = Connections::get(); $nodes = self::get(); $routers = array(); foreach ($nodes as $key => $node) { $routers[$key]['node'] = $node; $amount = 0; foreach ($conn as $connection) { if ($connection->connected_id == $node->id) { $amount++; } } $routers[$key]['connections'] = $amount; } return $routers; }
public function path(RequestSave $request, $id) { if (Request::isMethod('post')) { $data = $request->all(); foreach ($data['rows'] as $row) { if ($row['checkbox'] !== '0') { $conn = new Connections(); $conn->connected_id = $id; $conn->connection_id = $row['id']; $conn->colour = $row['colour']; $conn->bitrate = $row['bitrate']; $conn->save(); } } } $nodes = Node::get(); $connect = Connections::get(); return view('scripts.simulator.addpath')->with('nodes', $nodes)->with('conn', $connect)->with('self', Node::getById($id)); }
public static function getAll() { $conn = Connections::get(); $nodes = self::get(); $routers = array(); foreach ($nodes as $key => $node) { $routers[$key]['node'] = $node; $from = $to = 0; foreach ($conn as $connection) { if ($connection->connected_id == $node->id) { $from++; } if ($connection->connection_id == $node->id) { $to++; } } $routers[$key]['connections'] = $from; $routers[$key]['connections_to'] = $to; } return $routers; }