feat: 添加获取系统前台各模块url接口
This commit is contained in:
@@ -7,10 +7,11 @@ if (!function_exists('array_to_tree')) {
|
||||
* @param array $data 数据
|
||||
* @param int $pid 父级ID
|
||||
* @param string $with 转换依据字段
|
||||
* @param int $level 层级
|
||||
* @param int|bool $level 层级
|
||||
* @param bool $keep_pid 是否保留pid
|
||||
* @return array
|
||||
*/
|
||||
function array_to_tree(array $data, int $pid, string $with = 'pid', int|false $level = 1)
|
||||
function array_to_tree(array $data, int $pid, string $with = 'pid', int|bool $level = 1, bool $keep_pid = true)
|
||||
{
|
||||
$ret = [];
|
||||
foreach ($data as $item) {
|
||||
@@ -20,6 +21,9 @@ if (!function_exists('array_to_tree')) {
|
||||
$item['level'] = $level;
|
||||
$lv = $level + 1;
|
||||
}
|
||||
if ($keep_pid === false) {
|
||||
unset($item[$with]);
|
||||
}
|
||||
$children = array_to_tree($data, $item['id'], $with, $lv);
|
||||
if ($children) {
|
||||
$item['children'] = $children;
|
||||
|
||||
Reference in New Issue
Block a user