wip download details as csv and excel

This commit is contained in:
salam committed 2026-08-12 11:52:38 +02:00
1 parent 5b5fdc9321
commit 23a04dd7e1
4 files changed
+54 -4

No files matched your search

@@ -32,11 +32,11 @@ class ListStatisticFixtures extends ListRecords
->action(function () {
StatisticFixtures::truncate();
}),
Action::make('delete')
Action::make('remove_started')
->icon('phosphor-trash')
->tooltip('Delete events already started')
->requiresConfirmation()
->color('danger')
->color('info')
->action(function () {
StatisticFixtures::where('starttime', '<', now())->delete();
}),
@@ -3,9 +3,12 @@
namespace App\Filament\Clusters\StaticData\Resources\StatistikoDetails\Pages;
use App\Filament\Clusters\StaticData\Resources\StatistikoDetails\StatistikoDetailResource;
use App\Filament\Exports\DetailsExporter;
use App\Models\StatistikoDetail;
use Filament\Actions\Action;
use Filament\Actions\CreateAction;
use Filament\Actions\ExportAction;
use Filament\Actions\Exports\Models\Export;
use Filament\Resources\Pages\ListRecords;
class ListStatistikoDetails extends ListRecords
@@ -15,6 +18,12 @@ class ListStatistikoDetails extends ListRecords
protected function getHeaderActions(): array
{
return [
ExportAction::make('download_all')
->columnMapping(false)
->exporter(DetailsExporter::class)
->label('Download')
->fileName(fn(Export $export): string => 'details-' . date('d.m.Y-H.i') . "-{$export->getKey()}")
->icon('phosphor-download'),
Action::make('is_active')
->label('Disable All')
->icon('phosphor-pause')
@@ -19,11 +19,11 @@ class ListStatistikoEvents extends ListRecords
protected function getHeaderActions(): array
{
return [
ExportAction::make('download_betfair')
ExportAction::make('download_all')
->columnMapping(false)
->exporter(EventsHistoryExporter::class)
->label('Download')
->fileName(fn (Export $export): string => 'events-history-'.date('d.m.Y-H.i')."-{$export->getKey()}")
->fileName(fn(Export $export): string => 'events-history-' . date('d.m.Y-H.i') . "-{$export->getKey()}")
->icon('phosphor-download'),
Action::make('starttime')
->color('gray')
+41
View File
@@ -0,0 +1,41 @@
<?php
namespace App\Filament\Exports;
use App\Models\StatistikoDetail;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
use Illuminate\Support\Number;
class DetailsExporter extends Exporter
{
protected static ?string $model = StatistikoDetail::class;
public static function getColumns(): array
{
return [
ExportColumn::make('ss_player_id'),
ExportColumn::make('ss_team_id'),
ExportColumn::make('player_name'),
ExportColumn::make('ss_national_team_id'),
ExportColumn::make('height'),
ExportColumn::make('nationality'),
ExportColumn::make('position'),
ExportColumn::make('preferred_foot'),
ExportColumn::make('last_update'),
ExportColumn::make('is_active'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your StatistikoDetail export has completed and ' . Number::format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . Number::format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;
}
}