Fix CSV exports (missing data, add id, column name clash)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user