- Remove unnecessary 'where' option from various models in system module - Simplify query methods by removing redundant 'where' calls - Affected models: Config, Node, SystemAdmin, SystemMenu, SystemNode
35 lines
876 B
PHP
35 lines
876 B
PHP
<?php
|
|
|
|
namespace app\admin\model;
|
|
|
|
use app\common\model\TimeModel;
|
|
|
|
class SystemNode extends TimeModel
|
|
{
|
|
|
|
public function getNodeTreeList(): array
|
|
{
|
|
$list = $this->removeOption()->select()->toArray();
|
|
return $this->buildNodeTree($list);
|
|
}
|
|
|
|
protected function buildNodeTree($list): array
|
|
{
|
|
$newList = [];
|
|
$repeatString = " ";
|
|
foreach ($list as $vo) {
|
|
if ($vo['type'] == 1) {
|
|
$newList[] = $vo;
|
|
foreach ($list as $v) {
|
|
if ($v['type'] == 2 && str_contains($v['node'], $vo['node'] . '/')) {
|
|
$v['node'] = "{$repeatString}├{$repeatString}" . $v['node'];
|
|
$newList[] = $v;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return $newList;
|
|
}
|
|
|
|
|
|
} |