|
|
|
|
@ -31,7 +31,11 @@ class CreateExcelDocumentAction
|
|
|
|
|
private function allSheet(Collection $participants): TableDocumentData
|
|
|
|
|
{
|
|
|
|
|
$document = TableDocumentData::from(['title' => 'Anmeldungen für ' . $this->form->name, 'sheets' => []]);
|
|
|
|
|
$headers = $this->form->getFields()->map(fn ($field) => $field->name)->push('Abgemeldet am')->prepend('ID')->toArray();
|
|
|
|
|
$headers = [
|
|
|
|
|
'ID',
|
|
|
|
|
...$this->form->getFields()->names(),
|
|
|
|
|
'Abgemeldet am',
|
|
|
|
|
];
|
|
|
|
|
[$activeParticipants, $cancelledParticipants] = $participants->partition(fn ($participant) => $participant->cancelled_at === null);
|
|
|
|
|
|
|
|
|
|
$document->addSheet(SheetData::from([
|
|
|
|
|
@ -68,10 +72,11 @@ class CreateExcelDocumentAction
|
|
|
|
|
|
|
|
|
|
/** @return array<string, mixed> */
|
|
|
|
|
public function rowFor(Participant $participant): array {
|
|
|
|
|
return $this->form->getFields()->map(fn ($field) => $participant->getFields()->find($field)->presentRaw())
|
|
|
|
|
->put('Abgemeldet am', $participant->cancelled_at?->format('d.m.Y H:i:s') ?: '')
|
|
|
|
|
->prepend('ID', $participant->id)
|
|
|
|
|
->toArray();
|
|
|
|
|
return [
|
|
|
|
|
'ID' => $participant->id,
|
|
|
|
|
...$this->form->getFields()->map(fn ($field) => $participant->getFields()->find($field)->presentRaw()),
|
|
|
|
|
'Abgemeldet am' => $participant->cancelled_at?->format('d.m.Y H:i:s') ?: '',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function tempPath(): string
|
|
|
|
|
|