File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments