public function run() { $nodes = $this->getNodes(); // Build the above list of nodes as a heirarchical tree // of categories. foreach ($nodes as $node_name => $node_data) { // Create each root node. $root_node = Menu::create(['name' => $node_name, 'url' => $node_data['url']]); // Create the children of the root node. if (!empty($node_data['children'])) { $this->createNodes($root_node, $node_data['children']); } } }