Skip to content

Commit 0c4bd6f

Browse files
authored
Create reference.md
1 parent 3207e3f commit 0c4bd6f

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

reference.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+

0 commit comments

Comments
 (0)