remove the nested array

This commit is contained in:
2025-01-26 10:09:22 +03:30
parent 2e10afa5eb
commit 01a30c763c
2 changed files with 8 additions and 12 deletions

View File

@@ -252,7 +252,7 @@ class RoadItemsReportController extends Controller
$request->toDate, $request->toDate,
); );
$name = "گزارش کشوری از فعالیت روزانه و جاری({}) - جدول 2 " . verta()->now()->format('Y-m-d H-i') . '.xlsx'; $name = "گزارش کشوری از فعالیت روزانه و جاری - جدول 2 " . verta()->now()->format('Y-m-d H-i') . '.xlsx';
return Excel::download(new CountryActivityPerSubItemReport($activities), $name); return Excel::download(new CountryActivityPerSubItemReport($activities), $name);
} }
@@ -268,7 +268,7 @@ class RoadItemsReportController extends Controller
$request->province_id $request->province_id
); );
$name = "گزارش استانی از فعالیت روزانه و جاری({}) - جدول 2 " . verta()->now()->format('Y-m-d H-i') . '.xlsx'; $name = "گزارش استانی از فعالیت روزانه و جاری - جدول 2 " . verta()->now()->format('Y-m-d H-i') . '.xlsx';
return Excel::download(new ProvinceActivityPerSubItemReport($activities), $name); return Excel::download(new ProvinceActivityPerSubItemReport($activities), $name);
} }

View File

@@ -37,14 +37,12 @@ class RoadItemReportService
]; ];
foreach ($subItems as $subItem) { foreach ($subItems as $subItem) {
$totalItemCount[] = [ $totalItemCount["Count_{$subItem->sub_item}"] = $activities->sum("Count_{$subItem->sub_item}");
"total_count_{$subItem->sub_item}" => $activities->sum("Count_{$subItem->sub_item}"), $totalItemCount["Sum_{$subItem->sub_item}"] = $activities->sum("Sum_{$subItem->sub_item}");
"total_sum_{$subItem->sub_item}" => $activities->sum("Sum_{$subItem->sub_item}"),
];
} }
return [ return [
'data' => $activities->push($totalItemCount), 'data' => $activities->push((object)$totalItemCount),
'fromDate' => $fromDate, 'fromDate' => $fromDate,
'toDate' => $toDate, 'toDate' => $toDate,
'details' => $subItems->keyBy('sub_item'), 'details' => $subItems->keyBy('sub_item'),
@@ -81,14 +79,12 @@ class RoadItemReportService
]; ];
foreach ($subItems as $subItem) { foreach ($subItems as $subItem) {
$totalItemCount[] = [ $totalItemCount["Count_{$subItem->sub_item}"] = $activities->sum("Count_{$subItem->sub_item}");
"total_count_{$subItem->sub_item}" => $activities->sum("Count_{$subItem->sub_item}"), $totalItemCount["Sum_{$subItem->sub_item}"] = $activities->sum("Sum_{$subItem->sub_item}");
"total_sum_{$subItem->sub_item}" => $activities->sum("Sum_{$subItem->sub_item}"),
];
} }
return collect([ return collect([
'data' => $activities->push($totalItemCount), 'data' => $activities->push((object)$totalItemCount),
'fromDate' => $fromDate, 'fromDate' => $fromDate,
'toDate' => $toDate, 'toDate' => $toDate,
'details' => $subItems->keyBy('sub_item') 'details' => $subItems->keyBy('sub_item')