This commit is contained in:
salam committed 2026-10-29 15:39:57 +01:00
1 parent 15a900b2a8
commit c6bfe04b6a
2 files changed
+99 -1

No files matched your search

@@ -13,6 +13,7 @@ use Filament\Actions\Exports\Models\Export;
use Filament\Forms\Components\Select;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Database\Eloquent\Builder;
use Symfony\Component\HttpFoundation\StreamedResponse;
class ListStatistikoPlayers extends ListRecords
{
@@ -21,11 +22,100 @@ class ListStatistikoPlayers extends ListRecords
protected function getHeaderActions(): array
{
return [
Action::make('clean_download')
->label('Direkter Download')
->icon('heroicon-o-arrow-down-tray')
->action(function (): StreamedResponse {
return response()->streamDownload(function () {
// 1. Output-Stream öffnen
$output = fopen('php://output', 'w');
// 2. CSV-Header schreiben
fputcsv($output, ['ID', 'Nachricht', 'Level', 'Erstellt am']);
// 3. MongoDB Cursor nutzen (Lädt immer nur 1 Dokument gleichzeitig in den RAM)
StatistikoPlayer::cursor()->each(function ($row) use ($output) {
fputcsv($output, [
$row->match_id ?? '',
$row->ss_player_id ?? '',
$row->tm_player_id ?? '',
$row->sport_id ?? '',
$row->activeteam_id ?? '',
$row->assists ?? '',
$row->bcc ?? '',
$row->bcm ?? '',
$row->blocked_shots ?? '',
$row->card_red ?? '',
$row->card_yellow ?? '',
$row->card_yellowred ?? '',
$row->clearance_off_line ?? '',
$row->clearances ?? '',
$row->cross_done ?? '',
$row->description_event_during_the_match ?? '',
$row->dispossessed ?? '',
$row->dribbled_past ?? '',
$row->dribbles_won ?? '',
$row->errors_lead_to_a_goal ?? '',
$row->errors_lead_to_a_shot ?? '',
$row->fouls ?? '',
$row->goals ?? '',
$row->good_high_claim ?? '',
$row->hit_woodwork ?? '',
$row->ingamepenalty_missed ?? '',
$row->interceptions ?? '',
$row->key_pass ?? '',
$row->last_man_tackle ?? '',
$row->lineup ?? '',
$row->long_balls ?? '',
$row->minute_event_during_the_match ?? '',
$row->minutes_played ?? '',
$row->offsides ?? '',
$row->own_goals ?? '',
$row->pass ?? '',
$row->penalty_committed ?? '',
$row->penalty_miss ?? '',
$row->penalty_save ?? '',
$row->penalty_won ?? '',
$row->penaltyshoutout_missed ?? '',
$row->penaltyshoutout_scored ?? '',
$row->player_position ?? '',
$row->playerrating_value ?? '',
$row->playersubstitute_id ?? '',
$row->possessions_lost ?? '',
$row->punches ?? '',
$row->runs_out ?? '',
$row->saves ?? '',
$row->saves_from_in_box ?? '',
$row->shots_blocked ?? '',
$row->shots_off_target ?? '',
$row->shots_on_target ?? '',
$row->subtype_event_during_the_match ?? '',
$row->total_aerial_duels ?? '',
$row->total_cross ?? '',
$row->total_dribbles ?? '',
$row->total_duels_aerial_won ?? '',
$row->total_ground_duels ?? '',
$row->total_ground_duels_won ?? '',
$row->total_long_balls ?? '',
$row->total_pass ?? '',
$row->total_runs_out ?? '',
$row->total_tackles ?? '',
$row->touches ?? '',
$row->type_event_during_the_match ?? '',
$row->updated_at ?? '',
$row->was_fouled ?? '',
]);
});
// 4. Stream schließen
fclose($output);
}, 'player-history_all_'.now()->format('Y-m-d_H-i-s').'.csv');
}),
ExportAction::make('download_players')
->label('Download')
->icon('phosphor-download')
->columnMapping(false)
->chunkSize(1000)
->chunkSize(250)
->exporter(StatistikoPlayerExporter::class)
->fileName(function (Export $export): string {
$options = $export->getOptions();