2, 'xl' => 3, ]; public function resetFilters(): void { $filters = array_keys($this->filters); foreach ($filters as $filter) { switch ($filter) { case 'accuracy': $this->filters[$filter] = 0.125; break; case 'similar_past_matches': $this->filters[$filter] = 'none'; break; case 'team_position': $this->filters[$filter] = 'all'; break; case 'statistic_type': $this->filters[$filter] = 'gls'; break; case 'season_or_date': $this->filters[$filter] = 'season'; break; default; $this->filters[$filter] = null; break; } } } public function getHeading(): string|Htmlable|null { return ''; } public function filtersForm(Schema $schema): Schema { return $schema ->components([ // ToggleButtons::make('status') // ->columnSpanFull() // ->hiddenLabel() // ->inline() // ->default(1) // ->options([ // '1' => 'Soccer', // '3' => 'Basketball', // '2' => 'Ice Hockey', // '5' => 'Tennis', // ]) // ->icons([ // '1' => 'icon-soccerball', // '3' => 'icon-basketball', // '2' => 'icon-icehockey', // '5' => 'icon-tennisball', // ]), Grid::make([ 'default' => 1, 'sm' => 3, 'md' => 5, ]) ->columnSpanFull() ->schema([ Hidden::make('seasonmode'), Select::make('sofascore_category_id') ->live() ->preload() ->searchable(false) ->prefixIconColor(fn(Get $get): string => $get('sofascore_category_id') ? 'success' : 'danger') ->prefixIcon('phosphor-globe-fill') ->hiddenLabel() ->options(fn() => LoadSofaScoreCategory::load()) ->placeholder('Country') ->afterStateUpdated(function (callable $set, $state) { $set('seasonmode', SofaScoreCategory::where('id', $state)->value('season_mode')); $set('league_id', null); $set('match_id', null); $set('team_id', null); $set('ss_player_id', null); $set('season', null); }), Select::make('league_id') ->live() ->preload() ->prefixIconColor(fn(Get $get): string => $get('league_id') ? 'success' : 'danger') ->prefixIcon('phosphor-trophy-fill') ->hiddenLabel() // ->options(fn(Get $get) => SofaScoreTournament::with('sofascore_category')->where('sofa_score_category_id', $get('sofascore_category_id'))->pluck('name', 'tournament_id')) ->options(fn(Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('sofascore_category_id'))) ->placeholder('League') ->afterStateUpdated(function (callable $set, $state) { $set('match_id', null); $set('team_id', null); $set('ss_player_id', null); }), Select::make('match_id') ->live() ->hiddenLabel() ->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')); }) ->afterStateUpdated(function (callable $set) { $set('team_id', null); $set('ss_player_id', null); }) ->placeholder('Events'), Select::make('team_id') ->live() ->hiddenLabel() ->prefixIconColor(function (Get $get): string { if ($get('team_id')) { return 'success'; } elseif ($get('similar_past_matches') != 'none') { return 'gray'; } else { return 'danger'; } }) ->prefixIcon('phosphor-users-three-fill') ->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(); $arr = []; if ($res) { $arr[$res->home_id] = SofaScoreRosa::query()->where('ss_team_id', $res->home_id)->value('ss_team_name'); $arr[$res->away_id] = SofaScoreRosa::query()->where('ss_team_id', $res->away_id)->value('ss_team_name'); } return $arr; } }) ->afterStateUpdated(function (callable $set) { $set('ss_player_id', null); }) ->placeholder('Team'), Select::make('team_position') ->live() ->hiddenLabel() ->placeholder('Team Position') ->prefix('TP') ->prefixAction( Action::make('iconInfo') ->color('success') ->icon('phosphor-question-fill') ->tooltip(fn() => 'Team Position') ) ->hidden(fn(Get $get) => $get('similar_past_matches') != 'none') ->default('all') ->selectablePlaceholder(false) ->options([ 'all' => 'All', 'home' => 'Home', 'away' => 'Away', ])->afterStateUpdated(function (callable $set) { // $set('team_id', null); $set('ss_player_id', null); }), ]), Grid::make([ 'default' => 1, 'sm' => 3, 'md' => 4, ]) ->columnSpanFull() ->schema([ Select::make('statistic_type') ->live() ->hiddenLabel() ->allowHtml() ->placeholder('Statistic Type') ->prefixIconColor('success') ->prefixIcon(function (Get $get) { return match ($get('statistic_type')) { 'gls' => 'phosphor-soccer-ball-fill', 'crn' => 'phosphor-angle', 'fls' => 'phosphor-first-aid-kit', 'ofs' => 'phosphor-arrow-fat-lines-right-fill', 'crd' => 'phosphor-cards-fill', 'snt' => 'phosphor-target-fill', 'tsh' => 'phosphor-chart-polar-fill', default => 'phosphor-soccer-ball-fill', }; }) ->default('gls') ->selectablePlaceholder(false) ->options([ 'gls' => 'Goals', 'crn' => 'Corner', 'fls' => 'Fouls Commited', 'ofs' => 'Offside', 'crd' => 'Cards', 'snt' => 'Shots On Target', 'tsh' => 'Total Shots', ]), Select::make('similar_past_matches') ->live() ->hiddenLabel() ->prefix('SPM') ->placeholder('Similar Past Matches') ->suffix(fn(Get $get): string|HtmlString => $get('similar_past_matches') != 'none' ? new HtmlString('
± ' . $get('accuracy') . '
') : '') ->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()) ) ->default('none') ->selectablePlaceholder(false) ->afterStateUpdated(function (callable $set) { // $set('team_id', null); $set('ss_player_id', null); $set('team_position', null); }) ->options([ 'none' => 'None', 'league' => 'League', 'all' => 'All Database', ]), /************************ * SLIDER ************************/ Slider::make('accuracy') ->live() ->hiddenLabel() ->hidden(fn(Get $get) => $get('similar_past_matches') == 'none') ->fillTrack() ->minValue(0) ->maxValue(0.25) ->default(0.125) ->step(0.025) ->decimalPlaces(3) ->pips() ->pipsFormatter(RawJs::make(<<<'JS' `${$value.toFixed(2)}` JS)), /************************ * PLAYER ************************/ Select::make('ss_player_id') ->live() ->hiddenLabel() ->allowHtml() ->placeholder('Player') ->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() => ['id' => 'player_selector']) ->suffixAction( Action::make('iconInfo') ->icon('phosphor-question-fill') ->color('success') ->tooltip(fn() => $this->tooltip_player_info()) ) ->options(function (Get $get) { return LoadPlayer::load($get); }), Select::make('player_on_field') ->live() ->hiddenLabel() ->placeholder('Time on field') ->prefixIcon('phosphor-watch-fill') ->default('all') ->hidden(fn(Get $get) => ! $get('ss_player_id')) ->prefixIconColor('success') ->selectablePlaceholder(false) ->options([ 'all' => 'All', 'lineup' => 'Lineup', 'substituted' => 'Substituted', 'notplayed' => 'Not Played', ]), ]), Grid::make([ 'default' => 4, 'sm' => 4, ]) ->schema([ Radio::make('season_or_date') ->live() ->extraAttributes([ 'class' => 'radio-statistic-group', ]) ->hidden(fn(Get $get) => $get('similar_past_matches') != 'none') ->columnSpan([ 'default' => 4, 'sm' => 4, ]) ->inline() ->default('season') ->hiddenLabel() ->options([ 'season' => 'Season', 'date' => 'Date', ]), ]), /************************ * SEASON fulltime ************************/ Select::make('season') ->live() ->columns(2) ->hiddenLabel() ->multiple() ->placeholder('Current Season') ->prefixIconColor('success') // ->prefixIconColor(fn(Get $get): string => $get('season') ? 'success' : 'primary') ->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', '2025' => '2025', '2024' => '2024', ]) // ->options(function (Get $get) { // return LoadSeasons::load($get('seasonmode')); // }) ->afterStateUpdated(function (callable $set) { $set('ss_player_id', null); }), /************************ * SEASON halftime ************************/ Select::make('season') ->live() ->columns(2) ->hiddenLabel() ->multiple() ->placeholder('Current Season') ->prefixIconColor('success') // ->prefixIconColor(fn(Get $get): string => $get('season') ? 'success' : 'primary') ->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', '25/26' => '25/26', '24/25' => '24/25', ]) // ->options(function (Get $get) { // return LoadSeasons::load($get('seasonmode')); // }) ->afterStateUpdated(function (callable $set) { $set('ss_player_id', null); }), /************************ * DATE PICKER ************************/ DatePicker::make('start_date') ->live() ->hiddenLabel() ->hidden(fn(Get $get) => $get('season_or_date') == 'season') ->native(false) ->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)) ), DatePicker::make('end_date') ->live() ->hiddenLabel() ->hidden(fn(Get $get) => $get('season_or_date') == 'season') ->native(false) ->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::make('esc') ->label('') ->tooltip('Reset [esc]') ->icon('phosphor-x-circle') ->color('gray') ->keyBindings(['esc']) ->action('resetFilters'), ]); } protected function tooltip_similar_past_matches(): HtmlString { $str = '
'; $str .= '
Similar Past Matches (SMP)
'; $str .= '
None
'; $str .= '
Team within selected league
'; $str .= '
League
'; $str .= '
Simmilar events in league in the range of slider.
'; $str .= '
All Database
'; $str .= '
Simmilar events in database in the range of slider.
'; $str .= '
'; return new HtmlString($str); } protected function tooltip_player_info(): HtmlString { $str = '
'; $str .= '
Player Information
'; $str .= '
Events played:
'; $str .= '
sum
'; $str .= '
Stronger foot:
'; $str .= '
left | right | both
'; $str .= '
Average on field:
'; $str .= '
minutes
'; $str .= '
'; return new HtmlString($str); } }