From 4f7f9f28f18b0fd842003e6f001573abcca54ee2 Mon Sep 17 00:00:00 2001 From: salam Date: Wed, 7 Oct 2026 10:42:31 +0200 Subject: [PATCH] TP ma mostra sempre il valore come se TP = ALL --- .../Widgets/Boxes/ExpectationsTeam.php | 12 ++++---- .../Boxes/Helper/ExpectationCounting.php | 29 +++++++++++++++++++ .../Widgets/Boxes/LoadEventsBoxes.php | 1 + 3 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 app/Filament/Widgets/Boxes/Helper/ExpectationCounting.php diff --git a/app/Filament/Widgets/Boxes/ExpectationsTeam.php b/app/Filament/Widgets/Boxes/ExpectationsTeam.php index f2d437fc..5b89302b 100644 --- a/app/Filament/Widgets/Boxes/ExpectationsTeam.php +++ b/app/Filament/Widgets/Boxes/ExpectationsTeam.php @@ -4,6 +4,7 @@ namespace App\Filament\Widgets\Boxes; use App\Filament\Widgets\Boxes\Helper\ExpectationCalculation; use App\Filament\Widgets\Boxes\Helper\ExpectationCollecting; +use App\Filament\Widgets\Boxes\Helper\ExpectationCounting; use App\Filament\Widgets\Charts\LoadEvents\LoadEventsQueryAll; use App\Utilities\Round; use Illuminate\Support\Facades\Log; @@ -31,10 +32,14 @@ class ExpectationsTeam $res = LoadEventsQueryAll::load($filter, $match); - $count_events = $res->count(); + $count_events = ExpectationCounting::count($team_position, $team_id, $res); + + // Log::debug('count_events ' . $count_events); + if (! $res) { return []; } + $tmp = []; foreach ($res as $value) { ExpectationCollecting::sort($similar_past_matches, $tmp, 'gls', $value->home_id, $value->away_id, $value->gls_h, $value->gls_a, $match); @@ -46,7 +51,6 @@ class ExpectationsTeam ExpectationCollecting::sort($similar_past_matches, $tmp, 'crn', $value->home_id, $value->away_id, $value->crn_h, $value->crn_a, $match); } - // Log::debug('expectations '.$count_events, $tmp); $expectations = ExpectationCalculation::calc($tmp); $expectations['gls']['name'] = 'Goals'; @@ -58,8 +62,6 @@ class ExpectationsTeam $expectations['home'] = $home_team; $expectations['away'] = $away_team; - // Log::debug('expectations '.$count_events, $expectations); - $expectations += ['win_count' => 0, 'draw_count' => 0, 'lost_count' => 0]; foreach ($res as $value) { if ($team_id && $team_position == 'home') { @@ -74,7 +76,6 @@ class ExpectationsTeam $expectations['lost_count']++; break; } - } elseif ($team_id && $team_position == 'away') { switch ($value['result_code']) { case '1': @@ -87,7 +88,6 @@ class ExpectationsTeam $expectations['lost_count']++; break; } - } else { switch ($value['result_code']) { case '1': diff --git a/app/Filament/Widgets/Boxes/Helper/ExpectationCounting.php b/app/Filament/Widgets/Boxes/Helper/ExpectationCounting.php new file mode 100644 index 00000000..9b38c6bb --- /dev/null +++ b/app/Filament/Widgets/Boxes/Helper/ExpectationCounting.php @@ -0,0 +1,29 @@ +home_id == $team_id) + $count++; + break; + case 'away': + if ($value->away_id == $team_id) + $count++; + break; + + default: + $count++; + break; + } + } + + return $count; + } +} diff --git a/app/Filament/Widgets/Boxes/LoadEventsBoxes.php b/app/Filament/Widgets/Boxes/LoadEventsBoxes.php index 926647a3..9560cab7 100644 --- a/app/Filament/Widgets/Boxes/LoadEventsBoxes.php +++ b/app/Filament/Widgets/Boxes/LoadEventsBoxes.php @@ -27,6 +27,7 @@ class LoadEventsBoxes } $expectations = []; + ExpectationsTeam::load($expectations, $filter, $match); if ($team_id == $match->home_id) {