dev-master
9999999-devtree
Apache-2.0
The Requires
- php ~5.6|~7.0
- illuminate/support 5.3.*||5.4.*||5.5.*
by klgd
1.0.x-dev
1.0.9999999.9999999-devtree
Apache-2.0
The Requires
- php ~5.6|~7.0
- illuminate/support 5.3.*||5.4.*
by klgd
tree
是一个将数据格式化为树形结构的类库, (*1)
执行命令:, (*3)
bash
composer require scolib/tree
, (*4)
或 在 composer.json 文件中:, (*5)
"require": {
"scolib/tree": "^1.0"
}
并执行 composer update
, (*6)
<?php namespace App\Repositories; use Sco\Tree\Traits\TreeTrait; class MyClass { use TreeTrait; // 自定义属性(可选) protected $treeNodeIdName = 'id'; protected $treeNodeParentIdName = 'parent_id'; protected $treeSpacer = ' '; protected $treeFirstIcon = ' │ '; protected $treeMiddleIcon = ' ├─ '; protected $treeLastIcon = ' └─ '; /** * 获取待处理的原始节点数据 * * 必须实现 * * return \Illuminate\Support\Collection */ public function getTreeAllNodes() { } }
public function setAllNodes(Collection $nodes) public function getSubLevel($parentId) public function getDescendants($parentId, $depth = 0, $adds = '') public function getLayerOfDescendants($id) public function getSelf($id) public function getParent($id) public function getAncestors($id, $depth = 0)
tree
Apache-2.0
tree
Apache-2.0