回答編集履歴
1
追記
answer
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
$depts = Dept::with(['staffs.area'])->get()
|
3
3
|
->map(function(Dept $dept){
|
4
4
|
$temp = [];
|
5
|
-
$dept->staffs->each(function(Staff $staff) use ($temp) {
|
5
|
+
$dept->staffs->each(function(Staff $staff) use (&$temp) {
|
6
6
|
if (isset($temp[$staff->area->id])) {
|
7
7
|
$temp[$staff->area->id]['id'] = $staff->area->id;
|
8
8
|
$temp[$staff->area->id]['name'] = $staff->area->name;
|