2, 'xl' => 3, ]; public function getActiveTab() { return $this->activeTab; } public function getHeading(): string|Htmlable|null { return ''; } public function filtersForm(Schema $schema): Schema { return $schema ->components([ Grid::make([ 'default' => 1, 'sm' => 3, 'md' => 4, ]) ->columnSpanFull() ->extraAttributes([ 'class' => 'p-5 bg-blue-50 dark:bg-blue-950 rounded-lg border border-blue-200 dark:border-blue-800', ]) ->schema([ Select::make('league_id') // ->prefixIconColor('primary') ->prefixIconColor(fn(Get $get): string => $get('league_id') ? 'success' : 'danger') ->prefixIcon('phosphor-trophy') ->hiddenLabel() ->options(fn() => LoadStatisticFixturesLeaguesOptions::load(1)) ->live() ->placeholder('League') ->afterStateUpdated(function (callable $set, $state) { $set('match_id', null); $set('team_id', null); $set('tm_player_id', null); $set('season', null); }), Select::make('match_id') ->hiddenLabel() ->prefixIconColor(fn(Get $get): string => $get('match_id') ? 'success' : 'danger') ->prefixIcon('phosphor-calendar-check') ->options(function (Get $get) { return LoadStatisticFixturesMatchOptions::load($get('league_id')); }) ->afterStateUpdated(function (callable $set) { $set('team_id', null); $set('tm_player_id', null); }) ->live() ->placeholder('Events'), Select::make('team_id') ->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') ->hidden(fn(Get $get) => $get('similar_past_matches') != 'none') ->options(function (Get $get) { if ($get('match_id')) { $res = StatisticFixtures::where('id', $get('match_id'))->get(); $arr = []; foreach ($res as $value) { $arr[] = $value->home_id; $arr[] = $value->away_id; } return Element::query()->whereIn('id', $arr)->pluck('name', 'id'); } }) ->afterStateUpdated(function (callable $set) { $set('tm_player_id', null); }) ->live() ->placeholder('Team'), Select::make('team_position') ->hiddenLabel() ->placeholder('Team Position') ->prefix('Team Position') ->prefixIcon('phosphor-map-pin') ->hidden(fn(Get $get) => $get('similar_past_matches') != 'none') ->default('all') ->selectablePlaceholder(false) ->options([ 'all' => 'All', 'home' => 'Home', 'away' => 'Away', ]) ->live(), Select::make('statistic_type') ->hiddenLabel() ->placeholder('Statistic Type') ->prefixIconColor('success') ->prefixIcon('phosphor-arrows-out-line-vertical') ->default('none') ->selectablePlaceholder(false) ->options([ 'gls' => 'Goals', 'crn' => 'Corner', 'fls' => 'Fouls Commited', 'ofs' => 'Offside', 'crd' => 'Cards', 'snt' => 'Shots On Target', 'tsh' => 'Total Shots', ]) ->live(), Select::make('similar_past_matches') ->hiddenLabel() ->placeholder('Similar Past Matches') ->prefixIconColor('primary') ->suffix(fn(Get $get): string|HtmlString => $get('similar_past_matches') != 'none' ? new HtmlString('
± ' . $get('accuracy') . '
') : '') // ->columnSpan([ // 'default' => 1, // 'sm' => 2, // ]) ->prefixAction( Action::make('iconInfo') ->icon('phosphor-question') ->tooltip(fn() => $this->tooltip_similar_past_matches()) ) ->default('none') ->live() ->selectablePlaceholder(false) ->afterStateUpdated(function (callable $set) { $set('team_id', null); $set('tm_player_id', null); $set('team_position', null); }) ->options([ 'none' => 'SPM: None', 'league' => 'SPM: League', 'all' => 'SPM: All Database', ]), Slider::make('accuracy') // ->label('Accuracy min: 0, max: 0.25, steps: 0.025') ->hiddenLabel() ->hidden(fn(Get $get) => $get('similar_past_matches') == 'none') ->fillTrack() ->minValue(0) ->maxValue(0.25) ->default(0.125) ->step(0.025) ->decimalPlaces(3) // ->tooltips() // ->columnSpan([ // 'default' => 1, // 'xl' => 2, // ]) ->pips() ->pipsFormatter(RawJs::make(<<<'JS' `${$value.toFixed(2)}` JS)) ->live(), Select::make('tm_player_id') ->hiddenLabel() ->allowHtml() ->placeholder('Player') ->hidden(fn(Get $get) => $get('similar_past_matches') != 'none') ->prefixIconColor(fn(Get $get): string => $get('similar_past_matches') == 'none' ? 'primary' : '') ->prefixIcon('icon-player') ->suffixAction( Action::make('copyCostToPrice') ->action(function (callable $set) { $set('tm_player_id', null); $set('player_on_field', null); }) ->color('gray') ->icon('phosphor-x'), ) ->preload() ->options(function (Get $get) { return LoadPlayer::load($get('team_id')); }) ->live(), Select::make('player_on_field') ->hiddenLabel() ->placeholder('Time on field') ->prefixIcon('phosphor-watch') ->default('all') ->hidden(fn(Get $get) => ! $get('tm_player_id') or $get('similar_past_matches') != 'none') ->prefixIconColor(fn(Get $get): string => ($get('tm_player_id') and $get('similar_past_matches') == 'none') ? 'primary' : '') ->selectablePlaceholder(false) ->options([ 'all' => 'All', 'lineup' => 'Lineup', 'substituted' => 'Substituted', 'notplayed' => 'Not Played', ]) ->live(), Select::make('season') ->columns(2) ->hiddenLabel() ->multiple() ->placeholder('Season') ->hidden(fn(Get $get) => $get('season_or_date') == 'date') ->prefixIcon('phosphor-calendar-star') ->prefixIconColor('primary') ->preload() ->options(function (Get $get) { return LoadSeasons::load($get('league_id')); }) ->afterStateUpdated(function (callable $set) { $set('team_id', null); $set('tm_player_id', null); }) ->live(), DatePicker::make('start_date') ->hiddenLabel() ->hidden(fn(Get $get) => $get('season_or_date') == 'season') ->native(false) ->prefixIconColor('primary') ->prefixIcon('phosphor-calendar') ->live() ->prefix('Start') ->suffixAction( Action::make('clear_start') ->icon('phosphor-x') ->color('gray') ->action(fn(Set $set) => $set('start_date', null)) ), DatePicker::make('end_date') ->hiddenLabel() ->hidden(fn(Get $get) => $get('season_or_date') == 'season') ->native(false) ->prefixIconColor('primary') ->prefixIcon('phosphor-calendar') ->live() ->prefix('End') ->suffixAction( Action::make('clear_end') ->icon('phosphor-x') ->color('gray') ->action(fn(Set $set) => $set('end_date', null)) ), Radio::make('season_or_date') ->columnSpan([ 'default' => 1, 'sm' => 2, 'md' => 3, ]) ->inline() ->live() ->default('season') ->hiddenLabel() ->options([ 'season' => 'Season', 'date' => 'Date', ]), ]), ]); } 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); } }