File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ 因为要用到递归,所以变量加了&
2+
3+ public function index(){
4+ $arr = array();
5+ $item = Department::where('id','=',1)->first();
6+ /*
7+ $arr[ 'id'] = $item->id;
8+ $arr[ 'uuid'] = $item->uuid;
9+ $arr[ 'title'] = $item->title;
10+ $arr[ 'description'] = $item->description;
11+ $data = $this->children($arr);
12+ * /
13+ return view('department.index', [ 'department' => $item] );
14+ }
15+
16+ /*
17+ public function children(&$data){
18+ $childrenData = Department::where('parent','=',$data[ 'uuid'] )->get();
19+
20+ if($childrenData){
21+ $i = 0;
22+ foreach ($childrenData as $v){
23+ //递归加入子项
24+ $data['children'][$i]['id'] = $v->id;
25+ $data['children'][$i]['uuid'] = $v->uuid;
26+ $data['children'][$i]['title'] = $v->title;
27+ $data['children'][$i]['description'] = $v->description;
28+
29+ $this->children($data['children'][$i]);
30+ $i++;
31+ }
32+
33+ }
34+ return $data;
35+ }*/
36+
You can’t perform that action at this time.
0 commit comments