diff --git a/app/Filament/Pages/Selections/LoadSeasons.php b/app/Filament/Pages/Selections/LoadSeasons.php index 254f1326..84db58a0 100644 --- a/app/Filament/Pages/Selections/LoadSeasons.php +++ b/app/Filament/Pages/Selections/LoadSeasons.php @@ -11,18 +11,23 @@ class LoadSeasons // $res = CompetitionGroup::with('country')->where('id', $league_id)->first(); // $season_mode = $res->country->season_mode; - $res = StatistikoEvent::select('season')->where('league_id', $league_id)->get(); + // $res = StatistikoEvent::query()->where('league_id', $league_id)->get(); - if (! $res) { - return []; - } + // if (! $res) { + // return []; + // } + + // $arr = []; + // foreach ($res as $val) { + // $arr[$val->season] = $val->season; + // } + + // asort($arr); $arr = []; - foreach ($res as $val) { - $arr[$val->season] = $val->season; - } - - asort($arr); + $arr['24/25'] = '24/25'; + $arr['25/26'] = '25/26'; + $arr['26/27'] = '26/27'; return $arr; } diff --git a/app/Filament/Pages/Statistic.php b/app/Filament/Pages/Statistic.php index 98821972..fab7b630 100644 --- a/app/Filament/Pages/Statistic.php +++ b/app/Filament/Pages/Statistic.php @@ -79,10 +79,11 @@ class Statistic extends BaseDashboard Select::make('sofascore_category_id') ->live() ->preload() - ->prefixIconColor(fn(Get $get): string => $get('sofascore_category_id') ? 'success' : 'danger') + ->searchable(false) + ->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('Country') ->afterStateUpdated(function (callable $set) { $set('league_id', null); @@ -94,11 +95,11 @@ 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) => 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'))) + ->options(fn (Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('sofascore_category_id'))) ->placeholder('League') ->afterStateUpdated(function (callable $set, $state) { $set('match_id', null); @@ -109,7 +110,7 @@ class Statistic extends BaseDashboard Select::make('match_id') ->live() ->hiddenLabel() - ->prefixIconColor(fn(Get $get): string => $get('match_id') ? 'success' : 'danger') + ->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')); @@ -133,7 +134,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(); @@ -161,9 +162,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([ @@ -216,13 +217,13 @@ class Statistic extends BaseDashboard ->hiddenLabel() ->prefix('SPM') ->placeholder('Similar Past Matches') - ->suffix(fn(Get $get): string|HtmlString => $get('similar_past_matches') != 'none' ? new HtmlString('
± ' . $get('accuracy') . '
') : '') + ->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()) + ->tooltip(fn () => $this->tooltip_similar_past_matches()) ) ->default('none') ->selectablePlaceholder(false) @@ -239,7 +240,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) @@ -258,17 +259,17 @@ class Statistic extends BaseDashboard ->hiddenLabel() ->allowHtml() ->placeholder('Player') - ->hidden(fn(Get $get) => $get('similar_past_matches') != 'none') - ->prefixIconColor(fn(Get $get): string => $get('similar_past_matches') == 'none' ? 'success' : '') + ->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']) + ->extraAttributes(fn () => ['id' => 'player_selector']) ->suffixAction( 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) { return LoadPlayer::load($get); @@ -279,7 +280,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([ @@ -314,47 +315,52 @@ class Statistic extends BaseDashboard Select::make('season') ->live() ->columns(2) + ->searchable(false) ->hiddenLabel() ->multiple() ->placeholder('Current Season') ->prefixIconColor('success') // ->prefixIconColor(fn(Get $get): string => $get('season') ? 'success' : 'primary') - ->hidden(fn(Get $get) => $get('season_or_date') == 'date') + ->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')); - }) + ->options([ + '26/27' => '26/27', + '25/26' => '25/26', + '24/25' => '24/25', + ]) + // ->options(function (Get $get) { + // return LoadSeasons::load($get('league_id')); + // }) ->afterStateUpdated(function (callable $set) { $set('ss_player_id', null); }), 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)) ), ]); } diff --git a/app/Filament/Widgets/Data/LoadEvents.php b/app/Filament/Widgets/Data/LoadEvents.php index ba793565..9e9fc72a 100644 --- a/app/Filament/Widgets/Data/LoadEvents.php +++ b/app/Filament/Widgets/Data/LoadEvents.php @@ -52,7 +52,6 @@ class LoadEvents $team_position = ''; - $exp_handicap = $match->exp_away - $match->exp_home; $exp_total = $match->exp_away + $match->exp_home; @@ -71,9 +70,10 @@ class LoadEvents /** * STATTISTIC DATA */ - $res = LoadEventsQuery::load($filter, $handicap_range, $total_range, $match); + // dd($res); + $dataset_home = []; $dataset_away = []; $dataset_exp_home = []; @@ -84,11 +84,11 @@ class LoadEvents $events = []; $results = ['w' => 0, 'd' => 0, 'l' => 0, 'w2' => 0, 'l2' => 0]; - if (!$team_id || !\in_array($team_position, ['home', 'away'])) { + if (! $team_id || ! \in_array($team_position, ['home', 'away'])) { $team_position = 'all'; } - if (!isset($res['all']) || !isset($res[$team_position])) { + if (! isset($res['all']) || ! isset($res[$team_position])) { return []; } @@ -102,7 +102,10 @@ class LoadEvents $playing_date[] = $value['starttime']->format('Y-m-d H:i'); - $results_per_event[] = $value['val_home'] . ' : ' . $value['val_away']; + $results_per_event[] = $value['val_home'].' : '.$value['val_away']; + + $val_home = (int) $value['val_home']; + $val_away = (int) $value['val_away']; if ($similar_past_matches != 'none') { switch ($value['result_code']) { @@ -119,12 +122,9 @@ class LoadEvents break; } - $val_home = (int) $value['val_home']; - $val_away = (int) $value['val_away']; - if ($statistic_type == 'gls') { - $dataset_exp_home[] = (float) round($value['exp_home'], 1); - $dataset_exp_away[] = (float) round($value['exp_away'], 1); + $dataset_exp_home[] = (float) round($value['exp_home'], 1); + $dataset_exp_away[] = (float) round($value['exp_away'], 1); } } else { if ($team_position == 'home') { @@ -142,12 +142,9 @@ class LoadEvents break; } - $val_home = (int) $value['val_home']; - $val_away = (int) $value['val_away']; - if ($statistic_type == 'gls') { - $dataset_exp_home[] = (float) round($value['exp_home'], 1); - $dataset_exp_away[] = (float) round($value['exp_away'], 1); + $dataset_exp_home[] = (float) round($value['exp_home'], 1); + $dataset_exp_away[] = (float) round($value['exp_away'], 1); } } elseif ($team_position == 'away') { @@ -165,12 +162,9 @@ class LoadEvents break; } - $val_home = (int) $value['val_away']; - $val_away = (int) $value['val_home']; - if ($statistic_type == 'gls') { - $dataset_exp_home[] = (float) round($value['exp_away'], 1); - $dataset_exp_away[] = (float) round($value['exp_home'], 1); + $dataset_exp_home[] = (float) round($value['exp_away'], 1); + $dataset_exp_away[] = (float) round($value['exp_home'], 1); } } else { @@ -200,17 +194,14 @@ class LoadEvents break; } - $val_home = (int) $value['val_away']; - $val_away = (int) $value['val_home']; - if ($statistic_type == 'gls') { - $dataset_exp_home[] = (float) round($value['exp_away'], 1); - $dataset_exp_away[] = (float) round($value['exp_home'], 1); + $dataset_exp_home[] = (float) round($value['exp_away'], 1); + $dataset_exp_away[] = (float) round($value['exp_home'], 1); } } } if (isset($val_home) && isset($val_away)) { - $events[] = $value['home'] . ' vs ' . $value['away']; + $events[] = $value['home'].' vs '.$value['away']; $dataset_home[] = $val_home; $dataset_away[] = $val_away; } @@ -224,10 +215,10 @@ class LoadEvents $label2 = 'Against'; } } else { - $label1 = $match->home->ss_team_name . ' +'; - $label2 = $match->home->ss_team_name . ' -'; - $label3 = $match->away->ss_team_name . ' +'; - $label4 = $match->away->ss_team_name . ' -'; + $label1 = $match->home->ss_team_name.' +'; + $label2 = $match->home->ss_team_name.' -'; + $label3 = $match->away->ss_team_name.' +'; + $label4 = $match->away->ss_team_name.' -'; $dataset_home2 = []; $dataset_away2 = []; @@ -239,15 +230,15 @@ class LoadEvents if ($match->home_id == $value['home_id']) { $dataset_home[] = (int) $value['val_home']; $dataset_away[] = (int) $value['val_away']; - } else if ($match->home_id == $value['away_id']) { + } elseif ($match->home_id == $value['away_id']) { $dataset_home[] = (int) $value['val_away']; $dataset_away[] = (int) $value['val_home']; } // Home playing AWAY done and commited - else if ($match->away_id == $value['home_id']) { + elseif ($match->away_id == $value['home_id']) { $dataset_home2[] = (int) $value['val_home']; $dataset_away2[] = (int) $value['val_away']; - } else if ($match->away_id == $value['away_id']) { + } elseif ($match->away_id == $value['away_id']) { $dataset_home2[] = (int) $value['val_away']; $dataset_away2[] = (int) $value['val_home']; } @@ -263,7 +254,6 @@ class LoadEvents // dd($events, count($dataset_home), count($dataset_away), count($dataset_home2), count($dataset_away2)); - self::shortenEnding($labels, $dataset_home, $dataset_away); $data = [ @@ -309,7 +299,7 @@ class LoadEvents ]; if ($team_id && $statistic_type == 'gls') { $data['datasets'][] = [ - 'label' => 'Goals ' . $label1, + 'label' => 'Goals '.$label1, 'events' => $events, 'playing_date' => $playing_date, 'results_per_event' => $results_per_event, @@ -321,7 +311,7 @@ class LoadEvents 'hidden' => true, ]; $data['datasets'][] = [ - 'label' => 'Goals ' . $label2, + 'label' => 'Goals '.$label2, 'events' => $events, 'playing_date' => $playing_date, 'results_per_event' => $results_per_event, @@ -363,7 +353,6 @@ class LoadEvents // dd($data); - /** * LEAGUE AVERAGES */ diff --git a/app/Filament/Widgets/Data/LoadEvents/LoadEventsQuery.php b/app/Filament/Widgets/Data/LoadEvents/LoadEventsQuery.php index a61dfdf9..e9025d1a 100644 --- a/app/Filament/Widgets/Data/LoadEvents/LoadEventsQuery.php +++ b/app/Filament/Widgets/Data/LoadEvents/LoadEventsQuery.php @@ -8,7 +8,7 @@ use App\Models\StatistikoPlayer; class LoadEventsQuery { - public static function load(array $filter, array $handicap_range, array $total_range, object $match) + public static function load(array $filter, array $handicap_range, array $total_range, object $match) { $league_id = (int) $filter['league_id'] ?? 0; $team_id = (int) $filter['team_id'] ?? 0; @@ -84,8 +84,6 @@ class LoadEventsQuery /** * STATTISTIC DATA */ - - // dd($team_id, $home_id, $away_id); $res = StatistikoEvent::with('home')->with('away') ->where(function ($query) use ($league_id, $similar_past_matches) { @@ -122,13 +120,14 @@ class LoadEventsQuery return $query->whereDate('starttime', '<=', $end); }) ->when($season, function ($query) use ($season, $season_or_date) { - if ($season_or_date == 'season') + if ($season_or_date == 'season') { return $query->whereIn('season', $season); + } }) ->orderBy('starttime', 'ASC') ->get(); - // dd($season, $res); + // dd($season, $team_id, $home_id, $away_id, $res); $arr = []; foreach ($res as $value) { @@ -181,10 +180,12 @@ class LoadEventsQuery } $arr['all'][] = $tmp; - if ($value->home_id == $team_id) + if ($value->home_id == $team_id) { $arr['home'][] = $tmp; - if ($value->away_id == $team_id) + } + if ($value->away_id == $team_id) { $arr['away'][] = $tmp; + } } return $arr; diff --git a/app/Filament/Widgets/Data/LoadEvents/LoadExpectations.php b/app/Filament/Widgets/Data/LoadEvents/LoadExpectations.php index 995adc0d..164c4ab3 100644 --- a/app/Filament/Widgets/Data/LoadEvents/LoadExpectations.php +++ b/app/Filament/Widgets/Data/LoadEvents/LoadExpectations.php @@ -11,102 +11,141 @@ class LoadExpectations $home_id = $match->home_id; $away_id = $match->away_id; + // dd($data, $match); + $config = StatistikoConfig::where('group', $statistic_type)->get(); - $home_made_total = 1; - $home_made_home = 1; - $home_got_total = 1; - $home_got_home = 1; - $away_made_total = 1; - $away_made_home = 1; - $away_got_total = 1; - $away_got_home = 1; + $uba_home_made_total = 1; + $uba_home_made_home = 1; + $uba_home_got_total = 1; + $uba_home_got_home = 1; + $uba_away_made_total = 1; + $uba_away_made_home = 1; + $uba_away_got_total = 1; + $uba_away_got_home = 1; foreach ($config as $value) { - $varname = str_replace($statistic_type . '_', '', $value->varname); + $varname = str_replace($statistic_type.'_', '', $value->varname); switch ($varname) { case 'home_made_total': - $home_made_total = (float) $value->value; + $uba_home_made_total = (float) $value->value; break; case 'home_made_home': - $home_made_home = (float) $value->value; + $uba_home_made_home = (float) $value->value; break; case 'home_got_total': - $home_got_total = (float) $value->value; + $uba_home_got_total = (float) $value->value; break; case 'home_got_home': - $home_got_home = (float) $value->value; + $uba_home_got_home = (float) $value->value; break; case 'away_made_total': - $away_made_total = (float) $value->value; + $uba_away_made_total = (float) $value->value; break; case 'away_made_home': - $away_made_home = (float) $value->value; + $uba_away_made_home = (float) $value->value; break; case 'away_got_total': - $away_got_total = (float) $value->value; + $uba_away_got_total = (float) $value->value; break; case 'away_got_home': - $away_got_home = (float) $value->value; + $uba_away_got_home = (float) $value->value; break; } } - $h_made_t = []; - $h_made_h = []; - $h_got_t = []; - $h_got_h = []; + $home_made_total = []; + $home_made_home = []; + $home_got_total = []; + $home_got_home = []; - $a_made_t = []; - $a_made_a = []; - $a_got_t = []; - $a_got_a = []; + $away_made_total = []; + $away_made_away = []; + $away_got_total = []; + $away_got_away = []; foreach ($data as $value) { // HOME - if ($value['home_id'] == $home_id || $value['away_id'] == $home_id) { - $h_made_t[] = $value['val_home']; - $h_got_t[] = $value['val_away']; - } - if ($value['home_id'] == $home_id) { - $h_made_h[] = $value['val_home']; - $h_got_h[] = $value['val_away']; - } + // if ($value['home_id'] == $home_id || $value['away_id'] == $home_id) { + // $home_made_total[] = $value['val_home']; + // $home_got_total[] = $value['val_away']; + // } + // if ($value['home_id'] == $home_id) { + // $home_made_home[] = $value['val_home']; + // $home_got_home[] = $value['val_away']; + // } // AWAY - if ($value['home_id'] == $away_id || $value['away_id'] == $away_id) { - $a_made_t[] = $value['val_away']; - $a_made_a[] = $value['val_home']; + // if ($value['home_id'] == $away_id || $value['away_id'] == $away_id) { + // $away_made_total[] = $value['val_away']; + // $away_made_away[] = $value['val_home']; + // } + + // if ($value['away_id'] == $away_id) { + // $away_made_away[] = $value['val_away']; + // $away_got_away[] = $value['val_home']; + // } + + if ($value['home_id'] == $home_id) { + $home_made_total[] = $value['val_home']; + $home_made_home[] = $value['val_home']; + $home_got_total[] = $value['val_away']; + $home_got_home[] = $value['val_away']; + } elseif ($value['away_id'] == $home_id) { + $home_made_total[] = $value['val_away']; + $home_got_total[] = $value['val_away']; + } elseif ($value['home_id'] == $away_id) { + $home_made_total[] = $value['val_away']; + $home_got_total[] = $value['val_away']; + } elseif ($value['away_id'] == $away_id) { + $home_made_total[] = $value['val_home']; + $home_made_home[] = $value['val_home']; + $home_got_total[] = $value['val_away']; + $home_got_home[] = $value['val_home']; } if ($value['away_id'] == $away_id) { - $a_made_a[] = $value['val_away']; - $a_got_a[] = $value['val_home']; + $away_made_total[] = $value['val_away']; + $away_made_away[] = $value['val_away']; + $away_got_total[] = $value['val_home']; + $away_got_away[] = $value['val_home']; + } elseif ($value['home_id'] == $away_id) { + $away_made_total[] = $value['val_home']; + $away_got_total[] = $value['val_home']; + } elseif ($value['away_id'] == $home_id) { + $away_made_total[] = $value['val_home']; + $away_got_total[] = $value['val_home']; + } elseif ($value['home_id'] == $home_id) { + $away_made_total[] = $value['val_away']; + $away_made_away[] = $value['val_away']; + $away_got_total[] = $value['val_home']; + $away_got_away[] = $value['val_away']; } + } - $summe_home = array_sum($h_made_t) * $home_made_total; - $summe_home += array_sum($h_made_h) * $home_made_home; - $summe_home += array_sum($h_got_t) * $home_got_total; - $summe_home += array_sum($h_got_h) * $home_got_home; - $count_home = \count($h_made_t); - $count_home += \count($h_made_h); - $count_home += \count($h_got_t); - $count_home += \count($h_got_h); + $summe_home = array_sum($home_made_total) * $uba_home_made_total; + $summe_home += array_sum($home_made_home) * $uba_home_made_home; + $summe_home += array_sum($home_got_total) * $uba_home_got_total; + $summe_home += array_sum($home_got_home) * $uba_home_got_home; + $count_home = \count($home_made_total); + $count_home += \count($home_made_home); + $count_home += \count($home_got_total); + $count_home += \count($home_got_home); - $count_home = !$count_home ? 1 : $count_home; + $count_home = ! $count_home ? 1 : $count_home; $aspettativa_home = round($summe_home / $count_home, 1); - $summe_away = array_sum($a_made_t) * $away_made_total; - $summe_away += array_sum($a_made_a) * $away_made_home; - $summe_away += array_sum($a_got_t) * $away_got_total; - $summe_away += array_sum($a_got_a) * $away_got_home; - $count_away = \count($a_made_t); - $count_away += \count($a_made_a); - $count_away += \count($a_got_t); - $count_away += \count($a_got_a); + $summe_away = array_sum($away_made_total) * $uba_away_made_total; + $summe_away += array_sum($away_made_away) * $uba_away_made_home; + $summe_away += array_sum($away_got_total) * $uba_away_got_total; + $summe_away += array_sum($away_got_away) * $uba_away_got_home; + $count_away = \count($away_made_total); + $count_away += \count($away_made_away); + $count_away += \count($away_got_total); + $count_away += \count($away_got_away); - $count_away = !$count_away ? 1 : $count_away; + $count_away = ! $count_away ? 1 : $count_away; $aspettativa_away = round($summe_away / $count_away, 1); return ['home' => $aspettativa_home, 'away' => $aspettativa_away]; diff --git a/app/Filament/Widgets/StatsMedianAverage.php b/app/Filament/Widgets/StatsMedianAverage.php index 855bd458..8f422abe 100644 --- a/app/Filament/Widgets/StatsMedianAverage.php +++ b/app/Filament/Widgets/StatsMedianAverage.php @@ -12,6 +12,7 @@ use Filament\Widgets\StatsOverviewWidget\Stat; use Illuminate\Support\Carbon; use Illuminate\Support\HtmlString; use Livewire\Attributes\Reactive; + // use Illuminate\Support\Facades\Log; class StatsMedianAverage extends StatsOverviewWidget @@ -45,10 +46,11 @@ class StatsMedianAverage extends StatsOverviewWidget switch ($season_or_date) { case 'season': - if ($season) + if ($season) { $date_events = implode(', ', $season); - else + } else { $date_events = 'Current Season'; + } break; default: $start = $this->filters['start_date'] ?? 0; @@ -56,16 +58,18 @@ class StatsMedianAverage extends StatsOverviewWidget $tmp = []; if ($start) { - $tmp[] = 'From: ' . Carbon::createFromDate($start)->format('Y-m-d'); + $tmp[] = 'From: '.Carbon::createFromDate($start)->format('Y-m-d'); } - if ($end) - $tmp[] = 'To: ' . Carbon::createFromDate($end)->format('Y-m-d'); + if ($end) { + $tmp[] = 'To: '.Carbon::createFromDate($end)->format('Y-m-d'); + } - if ($tmp) + if ($tmp) { $date_events = implode('
', $tmp); - else + } else { $date_events = 'All Dates'; + } break; } @@ -77,7 +81,6 @@ class StatsMedianAverage extends StatsOverviewWidget $statistic_type = HelperStatisticType::get($this->filters); - if (! isset($data['datasets'][0])) { $data['datasets'][0]['data'] = []; $data['datasets'][1]['data'] = []; @@ -108,7 +111,6 @@ class StatsMedianAverage extends StatsOverviewWidget $lost = 0; } - if ($total_home) { $value_home = number_format($summe_home / $total_home, 1); } else { @@ -120,7 +122,6 @@ class StatsMedianAverage extends StatsOverviewWidget $value_away = 0; } - $max_boxes = 3; $average_team_home = 0; $average_team_away = 0; @@ -150,15 +151,15 @@ class StatsMedianAverage extends StatsOverviewWidget if ($similar_past_matches != 'none') { // BOX 2 $boxes[] = Stat::make('Total', self::template_box2($total_home)) - ->description(fn() => new HtmlString($date_events)) + ->description(fn () => new HtmlString($date_events)) ->extraAttributes([ 'x-init' => "animate('number-of-events', $total_home);", 'class' => 'box-info', ]); // BOX 3 - $boxes[] = Stat::make('Average ' . $statistic_type, self::template_box3('Home', 'Away', $value_home, $value_away)) - ->description('Team ' . $team_position) + $boxes[] = Stat::make('Average '.$statistic_type, self::template_box3('Home', 'Away', $value_home, $value_away)) + ->description('Team '.$team_position) ->extraAttributes([ 'x-init' => "animate('average_home', $value_home); animate('average_away', $value_away)", 'class' => 'box-success', @@ -184,22 +185,22 @@ class StatsMedianAverage extends StatsOverviewWidget // BOX 2 $boxes[] = Stat::make('Total', self::template_box2($total_home)) - ->description(fn() => new HtmlString($date_events)) + ->description(fn () => new HtmlString($date_events)) ->extraAttributes([ 'x-init' => "animate('number-of-events', $total_home);", 'class' => 'box-info', ]); // BOX 3 - $boxes[] = Stat::make('Average ' . $statistic_type, self::template_box3($home_team, $away_team, $value_home, $value_away)) - ->description('Team ' . $team_position) + $boxes[] = Stat::make('Average '.$statistic_type, self::template_box3($home_team, $away_team, $value_home, $value_away)) + ->description('Team '.$team_position) ->extraAttributes([ 'x-init' => "animate('average_home', $value_home); animate('average_away', $value_away)", 'class' => 'box-success', ]); // BOX 4 - $boxes[] = Stat::make('Average ' . $statistic_type, self::template_box4($home_team, $away_team, $average_team_home, $average_team_away)) + $boxes[] = Stat::make('Average '.$statistic_type, self::template_box4($home_team, $away_team, $average_team_home, $average_team_away)) ->description('Team Season') ->extraAttributes([ 'x-init' => "animate('av_team_home', $average_team_home); animate('av_team_away', $average_team_away)", @@ -207,7 +208,7 @@ class StatsMedianAverage extends StatsOverviewWidget ]); // BOX 5 - $boxes[] = Stat::make('Average ' . $statistic_type, self::template_box5('Home', 'Away', $average_league_home, $average_league_away)) + $boxes[] = Stat::make('Average '.$statistic_type, self::template_box5('Home', 'Away', $average_league_home, $average_league_away)) ->description('League Season') ->extraAttributes([ 'x-init' => "animate('av_league_home', $average_league_home); animate('av_league_away', $average_league_away)", @@ -238,8 +239,8 @@ class StatsMedianAverage extends StatsOverviewWidget protected function template_box1(float $expectations_home, float $expectations_away): HtmlString { return new HtmlString('
- ' . $expectations_home . ' - ' . $expectations_away . ' + '.$expectations_home.' + '.$expectations_away.' Home Away
'); @@ -249,7 +250,7 @@ class StatsMedianAverage extends StatsOverviewWidget protected function template_box2(float $total_home): HtmlString { return new HtmlString('
- ' . $total_home . ' + '.$total_home.' Events
'); } @@ -258,10 +259,10 @@ class StatsMedianAverage extends StatsOverviewWidget protected function template_box3(string $home_team, string $away_team, float $value_home, float $value_away): HtmlString { return new HtmlString('
- ' . $value_home . ' - ' . $value_away . ' - ' . $home_team . ' - ' . $away_team . ' + '.$value_home.' + '.$value_away.' + '.$home_team.' + '.$away_team.'
'); } @@ -269,10 +270,10 @@ class StatsMedianAverage extends StatsOverviewWidget protected function template_box4(string $home_team, string $away_team, float $value_home, float $value_away): HtmlString { return new HtmlString('
- ' . $value_home . ' - ' . $value_away . ' - ' . $home_team . ' - ' . $away_team . ' + '.$value_home.' + '.$value_away.' + '.$home_team.' + '.$away_team.'
'); } @@ -280,10 +281,10 @@ class StatsMedianAverage extends StatsOverviewWidget protected function template_box5(string $home_team, string $away_team, float $value_home, float $value_away): HtmlString { return new HtmlString('
- ' . $value_home . ' - ' . $value_away . ' - ' . $home_team . ' - ' . $away_team . ' + '.$value_home.' + '.$value_away.' + '.$home_team.' + '.$away_team.'
'); } @@ -291,26 +292,25 @@ class StatsMedianAverage extends StatsOverviewWidget protected function templateOdds(array &$data, float $win, float $draw, float $lost): HtmlString { if ($data['similar_past_matches'] != 'none') { - $name_win = '1 (' . $data['results']['w'] . ')'; - $name_draw = 'X (' . $data['results']['d'] . ')'; - $name_lost = '2 (' . $data['results']['l'] . ')'; + $name_win = '1 ('.$data['results']['w'].')'; + $name_draw = 'X ('.$data['results']['d'].')'; + $name_lost = '2 ('.$data['results']['l'].')'; } else { - $name_win = 'Win (' . $data['results']['w'] . ')'; - $name_draw = 'Draw (' . $data['results']['d'] . ')'; - $name_lost = 'Lost (' . $data['results']['l'] . ')'; + $name_win = 'Win ('.$data['results']['w'].')'; + $name_draw = 'Draw ('.$data['results']['d'].')'; + $name_lost = 'Lost ('.$data['results']['l'].')'; } return new HtmlString('
- ' . number_format($win, 2) . ' - ' . number_format($draw, 2) . ' - ' . number_format($lost, 2) . ' - ' . $name_win . ' - ' . $name_draw . ' - ' . $name_lost . ' + '.number_format($win, 2).' + '.number_format($draw, 2).' + '.number_format($lost, 2).' + '.$name_win.' + '.$name_draw.' + '.$name_lost.'
'); } - protected function getMedian(array $arr) { sort($arr); diff --git a/composer.lock b/composer.lock index 525a3798..5d1cbc70 100644 --- a/composer.lock +++ b/composer.lock @@ -4705,24 +4705,24 @@ }, { "name": "mongodb/mongodb", - "version": "2.2.0", + "version": "2.3.0", "source": { "type": "git", - "url": "https://github.com/mongodb/mongo-php-library.git", - "reference": "bbb13f969e37e047fd822527543df55fdc1c9298" + "url": "https://github.com/mongodb/mongo-php-library", + "reference": "12e56461166d915e3dd8e4969ad0940ed5207d88" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mongodb/mongo-php-library/zipball/bbb13f969e37e047fd822527543df55fdc1c9298", - "reference": "bbb13f969e37e047fd822527543df55fdc1c9298", + "url": "https://api.github.com/repos/mongodb/mongo-php-library/zipball/12e56461166d915e3dd8e4969ad0940ed5207d88", + "reference": "12e56461166d915e3dd8e4969ad0940ed5207d88", "shasum": "" }, "require": { "composer-runtime-api": "^2.0", - "ext-mongodb": "^2.2", + "ext-mongodb": "^2.3", "php": "^8.1", "psr/log": "^1.1.4|^2|^3", - "symfony/polyfill-php85": "^1.32" + "symfony/polyfill-php85": "^1.33" }, "replace": { "mongodb/builder": "*" @@ -4774,11 +4774,7 @@ "mongodb", "persistence" ], - "support": { - "issues": "https://github.com/mongodb/mongo-php-library/issues", - "source": "https://github.com/mongodb/mongo-php-library/tree/2.2.0" - }, - "time": "2026-02-11T11:39:56+00:00" + "time": "2026-04-28T12:50:06+00:00" }, { "name": "monolog/monolog",