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() ->schema([ Select::make('league_id') ->live() ->prefixIconColor(fn(Get $get): string => $get('league_id') ? 'success' : 'danger') ->prefixIcon('phosphor-trophy-fill') ->hiddenLabel() ->options(fn() => LoadStatisticFixturesLeaguesOptions::load(1)) ->placeholder('League') ->afterStateUpdated(function (callable $set, $state) { $set('match_id', null); $set('team_id', null); $set('ss_player_id', null); $set('season', 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::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)), 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() ->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) // ->afterStateUpdated(function (callable $set) { // // $set('team_id', null); // $set('ss_player_id', null); // }) ->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', ]) ->columnSpan([ 'default' => 4, 'sm' => 4, ]) ->inline() ->default('season') ->hiddenLabel() ->options([ 'season' => 'Season', 'date' => 'Date', ]), ]), Select::make('season') ->live() ->columns(2) ->hiddenLabel() ->multiple() ->placeholder('All Seasons') ->prefixIconColor('success') // ->prefixIconColor(fn(Get $get): string => $get('season') ? 'success' : 'primary') ->hidden(fn(Get $get) => $get('season_or_date') == 'date') ->prefixIcon('phosphor-calendar-star-fill') ->preload() ->options(function (Get $get) { return LoadSeasons::load($get('league_id')); }), 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)) ), ]); } 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); } }