Skip to content

Commit cb74d10

Browse files
committed
update
1 parent 0fcf87c commit cb74d10

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
"topthink/framework": "^6.0.0",
2121
"topthink/think-orm": "^2.0",
2222
"topthink/think-annotation": "^1.0",
23-
"xiaodi/think-jwt-auth": "dev-master",
24-
"xiaodi/think-permission": "dev-master"
23+
"xiaodi/think-whoops": "^1.1",
24+
"xiaodi/think-permission": "^0.5.0",
25+
"xiaodi/think-jwt": "^0.5.0"
2526
},
2627
"require-dev": {
2728
"symfony/var-dumper": "^4.2",

extend/Category.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,25 @@ private function _getPid($id)
104104
}
105105
return 0;
106106
}
107+
108+
/**
109+
* 格式化
110+
*
111+
* @param [type] $data
112+
* @param string $child_key
113+
* @param integer $pid
114+
* @return void
115+
*/
116+
public function formatTree($data, $child_key = 'child', $id = 0)
117+
{
118+
$child = [];
119+
$field = $this->field;
120+
foreach ($data as $item) {
121+
if ($item[$field['pid']] == $id) {
122+
$child[$item[$field['id']]] = $item;
123+
$child[$item[$field['id']]][$child_key] = $this->formatTree($data, $child_key, $item[$field['id']]);
124+
}
125+
}
126+
return $child;
127+
}
107128
}

0 commit comments

Comments
 (0)