Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Commit

Permalink
edge fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jaystream committed Jun 27, 2018
1 parent 0b096ea commit cbf6804
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion app/Http/Controllers/Tree/TreeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit cbf6804

Please sign in to comment.