components([ Section::make() ->compact() ->schema([ Select::make('league_id') ->prefixIcon('phosphor-trophy') ->options(fn () => LoadStatisticFixturesLeaguesOptions::load(1)) ->preload() ->searchable() ->live() ->label('League') ->afterStateUpdated(function (callable $set) { $set('team_id', null); }), Select::make('team_id') ->prefixIcon('icon-team') ->options(function (Get $get) { if ($get('league_id')) { $res = StatisticFixtures::where('league_id', $get('league_id'))->get(); $arr = []; foreach ($res as $value) { $arr[] = $value->home_id; $arr[] = $value->away_id; } $arr = array_unique($arr); return Element::query()->whereIn('id', $arr)->orderBy('name')->pluck('name', 'id'); } }) ->afterStateUpdated(function (callable $set) { $set('tm_player_id', null); }) ->preload() ->searchable() ->live() ->label('Team'), DatePicker::make('start_date') ->native(false) ->prefixIcon('phosphor-calendar') ->suffixAction( Action::make('clear_start') ->icon('phosphor-x') ->color('gray') ->action(fn (Set $set) => $set('start_date', null)) ), DatePicker::make('end_date') ->native(false) ->prefixIcon('phosphor-calendar') ->suffixAction( Action::make('clear_end') ->icon('phosphor-x') ->color('gray') ->action(fn (Set $set) => $set('end_date', null)) ), ])->columns(4) ->columnSpanFull(), Section::make() ->compact() ->collapsible() ->schema([ Select::make('tm_player_id') ->label('Player') ->prefixIcon('icon-player') ->preload() ->searchable() ->options(function (Get $get) { return StatistikoDetail::where('txodds_id', $get('team_id'))->pluck('name', 'tm_player_id'); }) ->live(), Select::make('team_position') ->prefixIcon('phosphor-map-pin') ->default('all') ->selectablePlaceholder(false) ->options([ 'all' => 'All', 'home' => 'Home', 'away' => 'Away', ]), Select::make('statistic_type') ->prefixIcon('phosphor-cell-signal-full') ->default('none') ->selectablePlaceholder(false) ->options([ 'gls' => 'Goals', 'crn' => 'Corner', 'fls' => 'Fouls commited', 'ofs' => 'Offside', 'crd' => 'Cards', 'snt' => 'Shot on target', 'tsh' => 'Total shots', ]), Select::make('similar_past_matches') ->prefixIcon('phosphor-align-center-horizontal') ->suffixAction( Action::make('iconInfo') ->color('gray') ->icon('phosphor-question') ->tooltip(fn () => $this->tooltip_similar_past_matches()) ) ->default('none') ->live() ->selectablePlaceholder(false) ->options([ 'none' => 'None', 'league' => 'League', 'all' => 'All Database', ]), Slider::make('accuracy') ->disabled(fn (Get $get) => $get('similar_past_matches') == 'none') ->fillTrack() ->default(5) ->step(0.1) ->decimalPlaces(1) ->tooltips() ->range(minValue: 0, maxValue: 1) ->pips(), ])->columns(5) ->columnSpanFull(), ]); } protected function getFooterWidgets(): array { return [ MedianAverageWidget::make(), PunctualChart::make(), MovingAverageChart::make(), ]; } protected function tooltip_similar_past_matches(): HtmlString { $str = '
'; $str .= '
None
'; $str .= '
Only selected team within selected league is considered.
'; $str .= '
League
'; $str .= '
All events in seleceted league are considered, filtered expected goal handicap and total parameter in the range of Accuracy Slider setting.
'; $str .= '
All Database
'; $str .= '
Eintire database is considered, filtered expected goal handicap and total parameter in the range of the
Accuracy Slider setting.
'; $str .= '
'; return new HtmlString($str); } }