wip download details as csv and excel
This commit is contained in:
1 parent
5b5fdc9321
commit
23a04dd7e1
4 files changed
+54
-4
No files matched your search
+2
-2
@@ -32,11 +32,11 @@ class ListStatisticFixtures extends ListRecords
|
|||||||
->action(function () {
|
->action(function () {
|
||||||
StatisticFixtures::truncate();
|
StatisticFixtures::truncate();
|
||||||
}),
|
}),
|
||||||
Action::make('delete')
|
Action::make('remove_started')
|
||||||
->icon('phosphor-trash')
|
->icon('phosphor-trash')
|
||||||
->tooltip('Delete events already started')
|
->tooltip('Delete events already started')
|
||||||
->requiresConfirmation()
|
->requiresConfirmation()
|
||||||
->color('danger')
|
->color('info')
|
||||||
->action(function () {
|
->action(function () {
|
||||||
StatisticFixtures::where('starttime', '<', now())->delete();
|
StatisticFixtures::where('starttime', '<', now())->delete();
|
||||||
}),
|
}),
|
||||||
|
|||||||
+9
@@ -3,9 +3,12 @@
|
|||||||
namespace App\Filament\Clusters\StaticData\Resources\StatistikoDetails\Pages;
|
namespace App\Filament\Clusters\StaticData\Resources\StatistikoDetails\Pages;
|
||||||
|
|
||||||
use App\Filament\Clusters\StaticData\Resources\StatistikoDetails\StatistikoDetailResource;
|
use App\Filament\Clusters\StaticData\Resources\StatistikoDetails\StatistikoDetailResource;
|
||||||
|
use App\Filament\Exports\DetailsExporter;
|
||||||
use App\Models\StatistikoDetail;
|
use App\Models\StatistikoDetail;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Actions\CreateAction;
|
use Filament\Actions\CreateAction;
|
||||||
|
use Filament\Actions\ExportAction;
|
||||||
|
use Filament\Actions\Exports\Models\Export;
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
class ListStatistikoDetails extends ListRecords
|
class ListStatistikoDetails extends ListRecords
|
||||||
@@ -15,6 +18,12 @@ class ListStatistikoDetails extends ListRecords
|
|||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
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')
|
Action::make('is_active')
|
||||||
->label('Disable All')
|
->label('Disable All')
|
||||||
->icon('phosphor-pause')
|
->icon('phosphor-pause')
|
||||||
|
|||||||
+2
-2
@@ -19,11 +19,11 @@ class ListStatistikoEvents extends ListRecords
|
|||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
ExportAction::make('download_betfair')
|
ExportAction::make('download_all')
|
||||||
->columnMapping(false)
|
->columnMapping(false)
|
||||||
->exporter(EventsHistoryExporter::class)
|
->exporter(EventsHistoryExporter::class)
|
||||||
->label('Download')
|
->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'),
|
->icon('phosphor-download'),
|
||||||
Action::make('starttime')
|
Action::make('starttime')
|
||||||
->color('gray')
|
->color('gray')
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user