add download button for evenrs and players history
This commit is contained in:
1 parent
db027c4238
commit
10baadb780
4 files changed
+175
No files matched your search
+10
@@ -3,10 +3,13 @@
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatistikoEvents\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\StatistikoEvents\StatistikoEventsResource;
|
||||
use App\Filament\Exports\EventsHistoryExporter;
|
||||
use App\Models\StatistikoEvent;
|
||||
use DateTime;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\ExportAction;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListStatistikoEvents extends ListRecords
|
||||
@@ -16,6 +19,12 @@ class ListStatistikoEvents extends ListRecords
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ExportAction::make('download_betfair')
|
||||
->columnMapping(false)
|
||||
->exporter(EventsHistoryExporter::class)
|
||||
->label('Download')
|
||||
->fileName(fn (Export $export): string => 'events-history-'.date('d.m.Y-H.i')."-{$export->getKey()}")
|
||||
->icon('phosphor-download'),
|
||||
Action::make('starttime')
|
||||
->color('gray')
|
||||
->tooltip('Find events with wrong starttime')
|
||||
@@ -25,6 +34,7 @@ class ListStatistikoEvents extends ListRecords
|
||||
->icon('heroicon-o-trash'))
|
||||
->modalContent(function () {
|
||||
$events = StatistikoEvent::with('league')->with('home')->with('away')->where('starttime', '<', new DateTime('-10 years'))->get();
|
||||
|
||||
return view('filament.pages.list-fixtures-starttime', ['events' => $events]);
|
||||
})->action(function () {
|
||||
$events = StatistikoEvent::with('league')->with('home')->with('away')->where('starttime', '<', new DateTime('-10 years'))->get();
|
||||
|
||||
+9
@@ -3,10 +3,13 @@
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatistikoPlayers\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\StatistikoPlayers\StatistikoPlayerResource;
|
||||
use App\Filament\Exports\PlayerHistoryExporter;
|
||||
use App\Models\StatistikoPlayer;
|
||||
use DateTime;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\ExportAction;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListStatistikoPlayers extends ListRecords
|
||||
@@ -16,6 +19,12 @@ class ListStatistikoPlayers extends ListRecords
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ExportAction::make('download_betfair')
|
||||
->columnMapping(false)
|
||||
->exporter(PlayerHistoryExporter::class)
|
||||
->label('Download')
|
||||
->fileName(fn (Export $export): string => 'player-history-'.date('d.m.Y-H.i')."-{$export->getKey()}")
|
||||
->icon('phosphor-download'),
|
||||
Action::make('starttime')
|
||||
->color('gray')
|
||||
->tooltip('Find events with wrong starttime')
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\StatistikoEvent;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
use Illuminate\Support\Number;
|
||||
|
||||
class EventsHistoryExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = StatistikoEvent::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ExportColumn::make('match_id'),
|
||||
ExportColumn::make('sport_id'),
|
||||
ExportColumn::make('league_id'),
|
||||
ExportColumn::make('home_id'),
|
||||
ExportColumn::make('away_id'),
|
||||
ExportColumn::make('starttime'),
|
||||
ExportColumn::make('season'),
|
||||
ExportColumn::make('gls_h'),
|
||||
ExportColumn::make('gls_a'),
|
||||
ExportColumn::make('crn_h'),
|
||||
ExportColumn::make('crn_a'),
|
||||
ExportColumn::make('fls_h'),
|
||||
ExportColumn::make('fls_a'),
|
||||
ExportColumn::make('ofs_h'),
|
||||
ExportColumn::make('ofs_a'),
|
||||
ExportColumn::make('snt_h'),
|
||||
ExportColumn::make('snt_a'),
|
||||
ExportColumn::make('tsh_h'),
|
||||
ExportColumn::make('tsh_a'),
|
||||
ExportColumn::make('crd_h'),
|
||||
ExportColumn::make('crd_a'),
|
||||
ExportColumn::make('exp_home'),
|
||||
ExportColumn::make('exp_away'),
|
||||
ExportColumn::make('exp_handicap'),
|
||||
ExportColumn::make('exp_total'),
|
||||
ExportColumn::make('result_code'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your events history 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\PlayerHistory;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
use Illuminate\Support\Number;
|
||||
|
||||
class PlayerHistoryExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = PlayerHistory::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ExportColumn::make('match_id'),
|
||||
ExportColumn::make('ss_player_id'),
|
||||
ExportColumn::make('tm_player_id'),
|
||||
ExportColumn::make('sport_id'),
|
||||
ExportColumn::make('activeteam_id'),
|
||||
ExportColumn::make('assists'),
|
||||
ExportColumn::make('bcc'),
|
||||
ExportColumn::make('bcm'),
|
||||
ExportColumn::make('blocked_shots'),
|
||||
ExportColumn::make('card_red'),
|
||||
ExportColumn::make('card_yellow'),
|
||||
ExportColumn::make('card_yellowred'),
|
||||
ExportColumn::make('clearance_off_line'),
|
||||
ExportColumn::make('clearances'),
|
||||
ExportColumn::make('cross_done'),
|
||||
ExportColumn::make('description_event_during_the_match'),
|
||||
ExportColumn::make('dispossessed'),
|
||||
ExportColumn::make('dribbled_past'),
|
||||
ExportColumn::make('dribbles_won'),
|
||||
ExportColumn::make('errors_lead_to_a_goal'),
|
||||
ExportColumn::make('errors_lead_to_a_shot'),
|
||||
ExportColumn::make('fouls'),
|
||||
ExportColumn::make('goals'),
|
||||
ExportColumn::make('good_high_claim'),
|
||||
ExportColumn::make('hit_woodwork'),
|
||||
ExportColumn::make('ingamepenalty_missed'),
|
||||
ExportColumn::make('interceptions'),
|
||||
ExportColumn::make('key_pass'),
|
||||
ExportColumn::make('last_man_tackle'),
|
||||
ExportColumn::make('lineup'),
|
||||
ExportColumn::make('long_balls'),
|
||||
ExportColumn::make('minute_event_during_the_match'),
|
||||
ExportColumn::make('minutes_played'),
|
||||
ExportColumn::make('offsides'),
|
||||
ExportColumn::make('own_goals'),
|
||||
ExportColumn::make('pass'),
|
||||
ExportColumn::make('penalty_committed'),
|
||||
ExportColumn::make('penalty_miss'),
|
||||
ExportColumn::make('penalty_save'),
|
||||
ExportColumn::make('penalty_won'),
|
||||
ExportColumn::make('penaltyshoutout_missed'),
|
||||
ExportColumn::make('penaltyshoutout_scored'),
|
||||
ExportColumn::make('player_position'),
|
||||
ExportColumn::make('playerrating_value'),
|
||||
ExportColumn::make('playersubstitute_id'),
|
||||
ExportColumn::make('possessions_lost'),
|
||||
ExportColumn::make('punches'),
|
||||
ExportColumn::make('runs_out'),
|
||||
ExportColumn::make('saves'),
|
||||
ExportColumn::make('saves_from_in_box'),
|
||||
ExportColumn::make('shots_blocked'),
|
||||
ExportColumn::make('shots_off_target'),
|
||||
ExportColumn::make('shots_on_target'),
|
||||
ExportColumn::make('subtype_event_during_the_match'),
|
||||
ExportColumn::make('total_aerial_duels'),
|
||||
ExportColumn::make('total_cross'),
|
||||
ExportColumn::make('total_dribbles'),
|
||||
ExportColumn::make('total_duels_aerial_won'),
|
||||
ExportColumn::make('total_ground_duels'),
|
||||
ExportColumn::make('total_ground_duels_won'),
|
||||
ExportColumn::make('total_long_balls'),
|
||||
ExportColumn::make('total_pass'),
|
||||
ExportColumn::make('total_runs_out'),
|
||||
ExportColumn::make('total_tackles'),
|
||||
ExportColumn::make('touches'),
|
||||
ExportColumn::make('type_event_during_the_match'),
|
||||
ExportColumn::make('updated_at'),
|
||||
ExportColumn::make('was_fouled'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your player history 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