diff --git a/app/Http/Controllers/Tree/TreeController.php b/app/Http/Controllers/Tree/TreeController.php index 126b22bc3..ac8a4936f 100644 --- a/app/Http/Controllers/Tree/TreeController.php +++ b/app/Http/Controllers/Tree/TreeController.php @@ -121,6 +121,27 @@ public function edge($parent_id = 1, $nest = 1){ $tree = $this->getChildren($parents, (int)$nest, false); - return $tree; + $this->linkData = []; + $link = $this->edgeLink($tree[0]['id'],$tree[0]['children']); + + $data['tree'] = $tree; + $data['links'] = $link; + return $data; + } + + + public function edgeLink($currentID, $children){ + + foreach ($children as $key => $value) { + $this->linkData[] = [ + 'source' => $currentID, + 'target' => $value['id'], + 'type' => rand(1,2) + ]; + + $this->edgeLink($value['id'],$value['children']); + } + + return $this->linkData; } }