add spreadseert

This commit is contained in:
philipp lang 2023-03-31 00:41:28 +02:00
parent e6ab3344e3
commit c9eb8adc03
1 changed files with 12 additions and 0 deletions

View File

@ -68,6 +68,7 @@ class ProcessSubmitJob implements ShouldQueue
$this->makeSheet($s, $group, $groupParticipants);
}
$s = $this->addStat($s);
$spreadsheetFile = $s->generate();
$filesystem->write($this->event->slug.'/anmeldungen.xlsx', file_get_contents($spreadsheetFile));
}
@ -83,6 +84,8 @@ class ProcessSubmitJob implements ShouldQueue
$s = $this->newSpreadsheet();
$this->makeSheet($s, 'Alle', $participants);
$s->headers([new SpreadsheetHeader('Stamm'), new SpreadsheetHeader('TN')]);
$s = $this->addStat($s);
$spreadsheetFile = $s->generate();
$filesystem->write($participantGroup.'/anmeldungen-'.$this->event->slug.'.xlsx', file_get_contents($spreadsheetFile));
@ -95,6 +98,15 @@ class ProcessSubmitJob implements ShouldQueue
return (new Spreadsheet('Anmeldezahlen '.$this->event->title))->headers($headers);
}
private function addStat(Spreadsheet $s): Spreadsheet
{
$groupBy = $this->event->loadConfig('groupBy');
$stat = Participant::where('event_id', $this->event->id)->get()->groupBy(fn ($p) => data_get($p->payload, $groupBy))->map(fn ($p) => $p->count())->map(fn ($key, $value) => [$value, $key])->values();
$s->sheet('Statistik', $stat->toArray());
return $s;
}
private function getfields()
{
return collect($this->event->loadConfig('fields'));