From ac88df2cad5eab9e31d1a2c0651aea6ceb78ff29 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Wed, 12 Nov 2025 02:24:57 +0100 Subject: [PATCH] Lint CreateExcelDocumentAction --- app/Form/Actions/CreateExcelDocumentAction.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/Form/Actions/CreateExcelDocumentAction.php b/app/Form/Actions/CreateExcelDocumentAction.php index 7eeba869..42a48199 100644 --- a/app/Form/Actions/CreateExcelDocumentAction.php +++ b/app/Form/Actions/CreateExcelDocumentAction.php @@ -36,12 +36,12 @@ class CreateExcelDocumentAction $document->addSheet(SheetData::from([ 'header' => $headers, - 'data' => $activeParticipants->map(fn ($participant) => $this->rowFor($participant))->toArray(), + 'data' => $this->rowsFor($activeParticipants), 'name' => 'Alle', ])); $document->addSheet(SheetData::from([ 'header' => $headers, - 'data' => $cancelledParticipants->map(fn ($participant) => $this->rowFor($participant))->toArray(), + 'data' => $this->rowsFor($cancelledParticipants), 'name' => 'Abgemeldet', ])); @@ -51,7 +51,7 @@ class CreateExcelDocumentAction foreach ($groups as $name => $groupedParticipants) { $document->addSheet(SheetData::from([ 'header' => $headers, - 'data' => $groupedParticipants->map(fn ($participant) => $this->rowFor($participant))->toArray(), + 'data' => $this->rowsFor($groupedParticipants), 'name' => $name, ])); } @@ -66,12 +66,15 @@ class CreateExcelDocumentAction return $document; } - /** @return array */ - public function rowFor(Participant $participant): array { - return $participant->getFields()->presentValues() + /** + * @param Collection $participants + * @return array> + */ + public function rowsFor(Collection $participants): array { + return $participants->map(fn ($participant) => $participant->getFields()->presentValues() ->put('Abgemeldet am', $participant->cancelled_at?->format('d.m.Y H:i:s') ?: '') ->prepend('ID', $participant->id) - ->toArray(); + )->toArray(); } private function tempPath(): string