diff --git a/app/Filament/Pages/Statistic.php b/app/Filament/Pages/Statistic.php index d9dc653b..cdd25899 100644 --- a/app/Filament/Pages/Statistic.php +++ b/app/Filament/Pages/Statistic.php @@ -169,6 +169,7 @@ class Statistic extends BaseDashboard Select::make('match_id') ->live() ->hiddenLabel() + ->columnSpan(fn (Get $get) => $get('similar_past_matches') != 'none' ? 2 : 1) ->prefixIconColor(fn (Get $get): string => $get('match_id') ? 'success' : 'danger') ->prefixIcon('phosphor-calendar-check-fill') ->options(function (Get $get) { @@ -278,7 +279,9 @@ class Statistic extends BaseDashboard ************************/ Select::make('similar_past_matches') ->live() + // ->columnSpan(2) ->hiddenLabel() + ->columnSpan(fn (Get $get) => $get('similar_past_matches') != 'none' ? 2 : 1) ->suffixAction(Action::make('reset') ->icon('phosphor-x-circle') ->action(fn (callable $set) => $set('similar_past_matches', 'none')) diff --git a/app/Filament/Widgets/Data/LoadEvents.php b/app/Filament/Widgets/Data/LoadEvents.php index 158ab190..f6c0138b 100644 --- a/app/Filament/Widgets/Data/LoadEvents.php +++ b/app/Filament/Widgets/Data/LoadEvents.php @@ -17,6 +17,7 @@ class LoadEvents $team_id = (int) $filter['team_id'] ?? 0; $statistic_type = $filter['statistic_type'] ?? 'gls'; $team_position = $filter['team_position']; + $seasonmode = $filter['seasonmode']; $accuracy = (float) $filter['accuracy'] ?? 0.5; $similar_past_matches = $filter['similar_past_matches']; @@ -43,6 +44,8 @@ class LoadEvents $match = StatisticFixtures::with('home')->with('away')->where('id', (int) $match_id)->first(); + // dd($match); + if (! $match) { return []; } @@ -94,13 +97,10 @@ class LoadEvents } $expectations = LoadExpectations::load($res['all'], $match, $statistic_type); - - // dd($expectations); $label1 = ''; $label2 = ''; $label3 = ''; $label4 = ''; - if ($team_id) { foreach ($res[$team_position] as $value) { @@ -240,6 +240,9 @@ class LoadEvents $dataset_home2 = []; $dataset_away2 = []; + $home_id = $match->home_id; + $away_id = $match->away_id; + foreach ($res[$team_position] as $value) { $labels[] = round($value['starttime']->diffInDays(Carbon::now())); @@ -267,13 +270,8 @@ class LoadEvents $dataset_away[] = (int) $value['val_home']; } } else { - if ($match->home_id == $value['home_id']) { - $dataset_home[] = (int) $value['val_home']; - $dataset_away[] = (int) $value['val_away']; - } else { - $dataset_home[] = (int) $value['val_away']; - $dataset_away[] = (int) $value['val_home']; - } + $dataset_home[] = (int) $value['val_home']; + $dataset_away[] = (int) $value['val_away']; } // Home playing AWAY done and commited @@ -284,7 +282,6 @@ class LoadEvents $dataset_home2[] = (int) $value['val_away']; $dataset_away2[] = (int) $value['val_home']; } - } $n = max(count($dataset_home), count($dataset_away), count($dataset_away2), count($dataset_home2)); if ($n) { @@ -372,7 +369,7 @@ class LoadEvents ]; } - if ($label3 && $label4 && isset($dataset_home2) && isset($dataset_away2)) { + if (isset($dataset_home2) && isset($dataset_away2)) { $data['datasets'][] = [ 'label' => $label3, 'events' => $events, diff --git a/app/Filament/Widgets/StatsMedianAverage.php b/app/Filament/Widgets/StatsMedianAverage.php index a7ad9367..8d1fc70b 100644 --- a/app/Filament/Widgets/StatsMedianAverage.php +++ b/app/Filament/Widgets/StatsMedianAverage.php @@ -157,7 +157,7 @@ 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 () => $similar_past_matches == 'all' ? 'SPM Source Database' : 'SPM Source League') ->extraAttributes([ 'x-init' => "animate('number-of-events', $total_home);", 'class' => 'box-info',