Fix CSV exports (missing data, add id, column name clash)

This commit is contained in:
Julien Nahum
2024-02-23 10:50:35 +01:00
parent e64d0d5da2
commit e85e4df7fe
4 changed files with 61 additions and 19 deletions

View File

@@ -16,7 +16,7 @@ class FormSubmissionExport implements FromArray, WithHeadingRow
$contentRow = [];
foreach ($submissionData as $i => $row) {
if($i==0){
$headingRow[] = array_keys($row);
$headingRow[] = $this->cleanColumnNames(array_keys($row));
}
$contentRow[] = array_values($row);
}
@@ -27,6 +27,13 @@ class FormSubmissionExport implements FromArray, WithHeadingRow
];
}
private function cleanColumnNames(array $columnNames): array
{
return collect($columnNames)->map(function ($columnName) {
return preg_replace('/\s\(.*\)/', '', $columnName);
})->toArray();
}
public function array(): array
{
return $this->submissionData;