-
Notifications
You must be signed in to change notification settings - Fork 217
Expand file tree
/
Copy pathSystemNode.php
More file actions
49 lines (40 loc) · 1.43 KB
/
SystemNode.php
File metadata and controls
49 lines (40 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
// +----------------------------------------------------------------------
// | EasyAdmin
// +----------------------------------------------------------------------
// | PHP交流群: 763822524
// +----------------------------------------------------------------------
// | 开源协议 https://mit-license.org
// +----------------------------------------------------------------------
// | github开源项目:https://github.com/zhongshaofa/EasyAdmin
// +----------------------------------------------------------------------
namespace app\admin\model;
use app\common\model\TimeModel;
class SystemNode extends TimeModel
{
public function getNodeTreeList()
{
$list = $this->order(['node' => 'asc', 'id' => 'desc'])
->select()
->toArray();
$list = $this->buildNodeTree($list);
return $list;
}
protected function buildNodeTree($list)
{
$newList = [];
$repeatString = " ";
foreach ($list as $vo) {
if ($vo['type'] == 1) {
$newList[] = $vo;
foreach ($list as $v) {
if ($v['type'] == 2 && strpos($v['node'], $vo['node'] . '/') !== false) {
$v['node'] = "{$repeatString}├{$repeatString}" . $v['node'];
$newList[] = $v;
}
}
}
}
return $newList;
}
}