wip copy data from statistiko
This commit is contained in:
1 parent
750b8bc571
commit
31dd27dd73
2 files changed
+140
-39
No files matched your search
@@ -6,6 +6,7 @@ use App\Actions\LoadSofaScoreCategory;
|
||||
use App\Actions\LoadStatisticFixturesLeaguesOptions;
|
||||
use App\Actions\LoadStatisticFixturesMatchOptions;
|
||||
use App\Filament\Pages\Selections\LoadPlayerSelection;
|
||||
use App\Filament\Widgets\Boxes\LoadEventsBoxes;
|
||||
use App\Models\SofaScoreCategory;
|
||||
use App\Models\SofaScoreRosa;
|
||||
use App\Models\StatisticFixtures;
|
||||
@@ -17,6 +18,7 @@ use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Slider;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Dashboard as BaseDashboard;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Schemas\Components\Actions;
|
||||
@@ -137,10 +139,10 @@ class Statistic extends BaseDashboard
|
||||
->live()
|
||||
->preload()
|
||||
->searchable(false)
|
||||
->prefixIconColor(fn(Get $get): string => $get('sofascore_category_id') ? 'success' : 'danger')
|
||||
->prefixIconColor(fn (Get $get): string => $get('sofascore_category_id') ? 'success' : 'danger')
|
||||
->prefixIcon('phosphor-globe-fill')
|
||||
->hiddenLabel()
|
||||
->options(fn() => LoadSofaScoreCategory::load())
|
||||
->options(fn () => LoadSofaScoreCategory::load())
|
||||
->placeholder('Select Country')
|
||||
->afterStateUpdated(function (callable $set, $state) {
|
||||
$set('seasonmode', SofaScoreCategory::where('id', $state)->value('season_mode'));
|
||||
@@ -153,10 +155,10 @@ class Statistic extends BaseDashboard
|
||||
Select::make('league_id')
|
||||
->live()
|
||||
->preload()
|
||||
->prefixIconColor(fn(Get $get): string => $get('league_id') ? 'success' : 'danger')
|
||||
->prefixIconColor(fn (Get $get): string => $get('league_id') ? 'success' : 'danger')
|
||||
->prefixIcon('phosphor-trophy-fill')
|
||||
->hiddenLabel()
|
||||
->options(fn(Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('sofascore_category_id')))
|
||||
->options(fn (Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('sofascore_category_id')))
|
||||
->placeholder('Select League')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('match_id', null);
|
||||
@@ -167,8 +169,8 @@ class Statistic extends BaseDashboard
|
||||
Select::make('match_id')
|
||||
->live()
|
||||
->hiddenLabel()
|
||||
->columnSpan(fn(Get $get) => $get('similar_past_matches') != 'none' ? 2 : 1)
|
||||
->prefixIconColor(fn(Get $get): string => $get('match_id') ? 'success' : 'danger')
|
||||
->columnSpan(fn (Get $get) => $get('similar_past_matches') != 'none' ? 2 : 1)
|
||||
->prefixIconColor(fn (Get $get): string => $get('match_id') ? 'success' : 'danger')
|
||||
->prefixIcon('phosphor-calendar-check-fill')
|
||||
->options(function (Get $get) {
|
||||
return LoadStatisticFixturesMatchOptions::load($get('league_id'));
|
||||
@@ -181,7 +183,7 @@ class Statistic extends BaseDashboard
|
||||
->placeholder('Select Event'),
|
||||
Action::make('esc')
|
||||
->hiddenLabel()
|
||||
->visible(fn(Get $get) => $get('similar_past_matches') != 'none')
|
||||
->visible(fn (Get $get) => $get('similar_past_matches') != 'none')
|
||||
->tooltip('Clear all (esc)')
|
||||
->icon('phosphor-x-circle')
|
||||
->color('warning')
|
||||
@@ -201,7 +203,7 @@ class Statistic extends BaseDashboard
|
||||
}
|
||||
})
|
||||
->prefixIcon('phosphor-users-three-fill')
|
||||
->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
|
||||
->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
|
||||
->options(function (Get $get) {
|
||||
if ($get('match_id')) {
|
||||
$res = StatisticFixtures::where('id', $get('match_id'))->first();
|
||||
@@ -230,9 +232,9 @@ class Statistic extends BaseDashboard
|
||||
Action::make('iconInfo')
|
||||
->color('success')
|
||||
->icon('phosphor-question-fill')
|
||||
->tooltip(fn() => 'Team Position')
|
||||
->tooltip(fn () => 'Team Position')
|
||||
)
|
||||
->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
|
||||
->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
|
||||
->default('all')
|
||||
->selectablePlaceholder(false)
|
||||
->options([
|
||||
@@ -287,20 +289,20 @@ class Statistic extends BaseDashboard
|
||||
->live()
|
||||
// ->columnSpan(2)
|
||||
->hiddenLabel()
|
||||
->columnSpan(fn(Get $get) => $get('similar_past_matches') != 'none' ? 2 : 1)
|
||||
->columnSpan(fn (Get $get) => $get('similar_past_matches') != 'none' ? 2 : 1)
|
||||
->suffixAction(Action::make('reset')
|
||||
->icon('phosphor-x-circle')
|
||||
->action(fn(callable $set) => $set('similar_past_matches', 'none'))
|
||||
->color(fn(Get $get): string => $get('similar_past_matches') != 'none' ? 'info' : 'gray'))
|
||||
->action(fn (callable $set) => $set('similar_past_matches', 'none'))
|
||||
->color(fn (Get $get): string => $get('similar_past_matches') != 'none' ? 'info' : 'gray'))
|
||||
->placeholder('Similar Past Matches')
|
||||
->suffix(fn(Get $get): string|HtmlString => $get('similar_past_matches') != 'none' ? new HtmlString('<div class="text-center w-24 font-bold rounded p-1 bg-blue-600 dark:bg-blue-700 text-white dark:text-gray-300">± ' . $get('accuracy') . '</div>') : '')
|
||||
->suffix(fn (Get $get): string|HtmlString => $get('similar_past_matches') != 'none' ? new HtmlString('<div class="text-center w-24 font-bold rounded p-1 bg-blue-600 dark:bg-blue-700 text-white dark:text-gray-300">± '.$get('accuracy').'</div>') : '')
|
||||
->prefix('SPM')
|
||||
->prefixAction(
|
||||
Action::make('iconInfo')
|
||||
->icon('phosphor-question-fill')
|
||||
// ->color(fn(Get $get): string => $get('similar_past_matches') != 'none' ? 'success' : 'primary')
|
||||
->color('success')
|
||||
->tooltip(fn() => $this->tooltip_similar_past_matches())
|
||||
->tooltip(fn () => $this->tooltip_similar_past_matches())
|
||||
)
|
||||
->default('none')
|
||||
->selectablePlaceholder(false)
|
||||
@@ -320,7 +322,7 @@ class Statistic extends BaseDashboard
|
||||
Slider::make('accuracy')
|
||||
->live()
|
||||
->hiddenLabel()
|
||||
->hidden(fn(Get $get) => $get('similar_past_matches') == 'none')
|
||||
->hidden(fn (Get $get) => $get('similar_past_matches') == 'none')
|
||||
->fillTrack()
|
||||
->minValue(0)
|
||||
->maxValue(0.25)
|
||||
@@ -340,13 +342,13 @@ class Statistic extends BaseDashboard
|
||||
->allowHtml()
|
||||
->columnSpan(2)
|
||||
->placeholder('Player')
|
||||
->visible(fn(Get $get) => $get('team_id'))
|
||||
->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
|
||||
->prefixIconColor(fn(Get $get): string => $get('similar_past_matches') == 'none' ? 'success' : '')
|
||||
->visible(fn (Get $get) => $get('team_id'))
|
||||
->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
|
||||
->prefixIconColor(fn (Get $get): string => $get('similar_past_matches') == 'none' ? 'success' : '')
|
||||
->prefixIcon('icon-player')
|
||||
->preload()
|
||||
->searchable()
|
||||
->extraAttributes(fn() => [
|
||||
->extraAttributes(fn () => [
|
||||
'id' => 'player_selector',
|
||||
'style' => 'width: 100%;',
|
||||
])
|
||||
@@ -354,7 +356,7 @@ class Statistic extends BaseDashboard
|
||||
Action::make('iconInfo')
|
||||
->icon('phosphor-question-fill')
|
||||
->color('success')
|
||||
->tooltip(fn() => $this->tooltip_player_info())
|
||||
->tooltip(fn () => $this->tooltip_player_info())
|
||||
)
|
||||
->options(function (Get $get) {
|
||||
$team_id = $get('team_id');
|
||||
@@ -371,7 +373,7 @@ class Statistic extends BaseDashboard
|
||||
->placeholder('Time on field')
|
||||
->prefixIcon('phosphor-watch-fill')
|
||||
->default('all')
|
||||
->hidden(fn(Get $get) => ! $get('ss_player_id'))
|
||||
->hidden(fn (Get $get) => ! $get('ss_player_id'))
|
||||
->prefixIconColor('success')
|
||||
->selectablePlaceholder(false)
|
||||
->options([
|
||||
@@ -392,7 +394,7 @@ class Statistic extends BaseDashboard
|
||||
->extraAttributes([
|
||||
'class' => 'radio-statistic-group',
|
||||
])
|
||||
->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
|
||||
->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
|
||||
->columnSpan(2)
|
||||
->inline()
|
||||
->default('season')
|
||||
@@ -411,8 +413,8 @@ class Statistic extends BaseDashboard
|
||||
->multiple()
|
||||
->placeholder('Current Season')
|
||||
->prefixIconColor('success')
|
||||
->visible(fn(Get $get) => $get('seasonmode'))
|
||||
->hidden(fn(Get $get) => $get('seasonmode') == 'halfyear' || $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
|
||||
->visible(fn (Get $get) => $get('seasonmode'))
|
||||
->hidden(fn (Get $get) => $get('seasonmode') == 'halfyear' || $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
|
||||
->prefixIcon('phosphor-calendar-star-fill')
|
||||
->options([
|
||||
'2026' => '2026',
|
||||
@@ -432,8 +434,8 @@ class Statistic extends BaseDashboard
|
||||
->multiple()
|
||||
->placeholder('Current Season')
|
||||
->prefixIconColor('success')
|
||||
->visible(fn(Get $get) => $get('seasonmode'))
|
||||
->hidden(fn(Get $get) => $get('seasonmode') == 'fullyear' || $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
|
||||
->visible(fn (Get $get) => $get('seasonmode'))
|
||||
->hidden(fn (Get $get) => $get('seasonmode') == 'fullyear' || $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
|
||||
->prefixIcon('phosphor-calendar-star-fill')
|
||||
->options([
|
||||
'26/27' => '26/27',
|
||||
@@ -449,53 +451,150 @@ class Statistic extends BaseDashboard
|
||||
DatePicker::make('start_date')
|
||||
->live()
|
||||
->hiddenLabel()
|
||||
->hidden(fn(Get $get) => $get('season_or_date') == 'season')
|
||||
->hidden(fn (Get $get) => $get('season_or_date') == 'season')
|
||||
->native(false)
|
||||
->prefixIconColor(fn(Get $get): string => $get('start_date') ? 'success' : 'primary')
|
||||
->prefixIconColor(fn (Get $get): string => $get('start_date') ? 'success' : 'primary')
|
||||
->prefixIcon('phosphor-calendar-fill')
|
||||
->prefix('Start')
|
||||
->suffixAction(
|
||||
Action::make('clear_start')
|
||||
->icon('phosphor-x')
|
||||
->color('gray')
|
||||
->action(fn(Set $set) => $set('start_date', null))
|
||||
->action(fn (Set $set) => $set('start_date', null))
|
||||
),
|
||||
DatePicker::make('end_date')
|
||||
->live()
|
||||
->hiddenLabel()
|
||||
->hidden(fn(Get $get) => $get('season_or_date') == 'season')
|
||||
->hidden(fn (Get $get) => $get('season_or_date') == 'season')
|
||||
->native(false)
|
||||
->prefixIconColor(fn(Get $get): string => $get('end_date') ? 'success' : 'primary')
|
||||
->prefixIconColor(fn (Get $get): string => $get('end_date') ? 'success' : 'primary')
|
||||
->prefixIcon('phosphor-calendar-fill')
|
||||
->prefix('End')
|
||||
->suffixAction(
|
||||
Action::make('clear_end')
|
||||
->icon('phosphor-x')
|
||||
->color('gray')
|
||||
->action(fn(Set $set) => $set('end_date', null))
|
||||
->action(fn (Set $set) => $set('end_date', null))
|
||||
),
|
||||
Actions::make([
|
||||
Action::make('esc')
|
||||
->hiddenLabel()
|
||||
->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
|
||||
->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
|
||||
->tooltip('Clear all (esc)')
|
||||
->icon('phosphor-x-circle')
|
||||
->color(fn(Get $get) => $get('sofascore_category_id') ? 'warning' : 'gray')
|
||||
->color(fn (Get $get) => $get('sofascore_category_id') ? 'warning' : 'gray')
|
||||
->keyBindings(['esc'])
|
||||
->action('resetFilters'),
|
||||
Action::make('copy')
|
||||
->hiddenLabel()
|
||||
->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
|
||||
->visible(fn(Get $get) => $get('team_id'))
|
||||
->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
|
||||
->visible(fn (Get $get) => $get('team_id'))
|
||||
->tooltip('Copy data for pasting into spreadsheet')
|
||||
->color('success')
|
||||
->icon('phosphor-copy')
|
||||
->action('resetFilters'),
|
||||
])
|
||||
->action(function ($livewire) {
|
||||
// 1. Call your custom Livewire function to generate the data
|
||||
$dataToCopy = $livewire->generateDynamicPayload();
|
||||
|
||||
$this->js("navigator.clipboard.writeText(`$dataToCopy`)");
|
||||
|
||||
// 3. Send a helpful Filament Toast notification to the UI
|
||||
Notification::make()
|
||||
->title('Copied to clipboard!')
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
]),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function generateDynamicPayload(): string
|
||||
{
|
||||
$data = LoadEventsBoxes::load($this->filters, false);
|
||||
|
||||
$header = ['Team', 'Event', 'Odd 1', 'Odd X', 'Odd 2', 'Category', 'EXP H', 'EXP A', 'AGV+', 'AGV-', 'AGV Team Season H', 'AGV Team Season A', 'AGV League H', 'AGV League A'];
|
||||
$copystring = implode(';', $header)."\n";
|
||||
$row = [];
|
||||
$row[] = $data['active_team'];
|
||||
$row[] = $data['count_events'];
|
||||
$row[] = $data['win_odd'];
|
||||
$row[] = $data['draw_odd'];
|
||||
$row[] = $data['lost_odd'];
|
||||
$row[] = 'Goals';
|
||||
$row[] = $data['gls']['home'];
|
||||
$row[] = $data['gls']['away'];
|
||||
$row[] = $data['gls_team']['home'];
|
||||
$row[] = $data['gls_team']['away'];
|
||||
$row[] = $data['gls_team_season']['home'];
|
||||
$row[] = $data['gls_team_season']['away'];
|
||||
$row[] = $data['gls_liga_season']['home'];
|
||||
$row[] = $data['gls_liga_season']['away'];
|
||||
$copystring .= implode(';', $row)."\n";
|
||||
$row = [];
|
||||
$row = array_fill(0, 5, '');
|
||||
$row[] = 'Fouls';
|
||||
$row[] = $data['fls']['home'];
|
||||
$row[] = $data['fls']['away'];
|
||||
$row[] = $data['fls_team']['home'];
|
||||
$row[] = $data['fls_team']['away'];
|
||||
$row[] = $data['fls_team_season']['home'];
|
||||
$row[] = $data['fls_team_season']['away'];
|
||||
$row[] = $data['fls_liga_season']['home'];
|
||||
$row[] = $data['fls_liga_season']['away'];
|
||||
$copystring .= implode(';', $row)."\n";
|
||||
$row = [];
|
||||
$row = array_fill(0, 5, '');
|
||||
$row[] = 'Offside';
|
||||
$row[] = $data['ofs']['home'];
|
||||
$row[] = $data['ofs']['away'];
|
||||
$row[] = $data['ofs_team']['home'];
|
||||
$row[] = $data['ofs_team']['away'];
|
||||
$row[] = $data['ofs_team_season']['home'];
|
||||
$row[] = $data['ofs_team_season']['away'];
|
||||
$row[] = $data['ofs_liga_season']['home'];
|
||||
$row[] = $data['ofs_liga_season']['away'];
|
||||
$copystring .= implode(';', $row)."\n";
|
||||
$row = [];
|
||||
$row = array_fill(0, 5, '');
|
||||
$row[] = 'Cards';
|
||||
$row[] = $data['crd']['home'];
|
||||
$row[] = $data['crd']['away'];
|
||||
$row[] = $data['crd_team']['home'];
|
||||
$row[] = $data['crd_team']['away'];
|
||||
$row[] = $data['crd_team_season']['home'];
|
||||
$row[] = $data['crd_team_season']['away'];
|
||||
$row[] = $data['crd_liga_season']['home'];
|
||||
$row[] = $data['crd_liga_season']['away'];
|
||||
$copystring .= implode(';', $row)."\n";
|
||||
$row = [];
|
||||
$row = array_fill(0, 5, '');
|
||||
$row[] = 'Shots on traget';
|
||||
$row[] = $data['snt']['home'];
|
||||
$row[] = $data['snt']['away'];
|
||||
$row[] = $data['snt_team']['home'];
|
||||
$row[] = $data['snt_team']['away'];
|
||||
$row[] = $data['snt_team_season']['home'];
|
||||
$row[] = $data['snt_team_season']['away'];
|
||||
$row[] = $data['snt_liga_season']['home'];
|
||||
$row[] = $data['snt_liga_season']['away'];
|
||||
$copystring .= implode(';', $row)."\n";
|
||||
$row = [];
|
||||
$row = array_fill(0, 5, '');
|
||||
$row[] = 'Total Shots';
|
||||
$row[] = $data['tsh']['home'];
|
||||
$row[] = $data['tsh']['away'];
|
||||
$row[] = $data['tsh_team']['home'];
|
||||
$row[] = $data['tsh_team']['away'];
|
||||
$row[] = $data['tsh_team_season']['home'];
|
||||
$row[] = $data['tsh_team_season']['away'];
|
||||
$row[] = $data['tsh_liga_season']['home'];
|
||||
$row[] = $data['tsh_liga_season']['away'];
|
||||
$copystring .= implode(';', $row)."\n";
|
||||
|
||||
return $copystring;
|
||||
}
|
||||
|
||||
protected function tooltip_similar_past_matches(): HtmlString
|
||||
{
|
||||
$str = '<div class="m-3 grid grid-cols-4 gap-2 max-w-lg">';
|
||||
|
||||
@@ -33,6 +33,8 @@ class BoxesBettypeAll extends StatsOverviewWidget
|
||||
{
|
||||
$data = LoadEventsBoxes::load($this->filters, false);
|
||||
|
||||
// dd($data);
|
||||
|
||||
$similar_past_matches = $this->filters['similar_past_matches'];
|
||||
$team_position = $this->filters['team_position'];
|
||||
|
||||
|
||||
Reference in new issue
Block a user