From 89cb571b56043dd5a6d293ba088f7f9faf073376 Mon Sep 17 00:00:00 2001 From: salam Date: Sat, 10 Oct 2026 15:59:48 +0200 Subject: [PATCH] wip --- .../Widgets/Boxes/AverageLeagueSeason.php | 9 ++-- app/Filament/Widgets/Boxes/AverageTeam.php | 15 +++---- .../Widgets/Boxes/AverageTeamSeason.php | 45 +++---------------- .../Widgets/Boxes/ExpectationsTeam.php | 8 ++-- ...tionMethodA.php => ExpectationMethodA.php} | 2 +- ...tionMethodB.php => ExpectationMethodB.php} | 2 +- app/Filament/Widgets/BoxesBettypeAll.php | 2 +- 7 files changed, 23 insertions(+), 60 deletions(-) rename app/Filament/Widgets/Boxes/Helper/{ExpectationCalculationMethodA.php => ExpectationMethodA.php} (98%) rename app/Filament/Widgets/Boxes/Helper/{ExpectationCalculationMethodB.php => ExpectationMethodB.php} (97%) diff --git a/app/Filament/Widgets/Boxes/AverageLeagueSeason.php b/app/Filament/Widgets/Boxes/AverageLeagueSeason.php index 76a950f8..bf807dce 100644 --- a/app/Filament/Widgets/Boxes/AverageLeagueSeason.php +++ b/app/Filament/Widgets/Boxes/AverageLeagueSeason.php @@ -8,16 +8,17 @@ use App\Models\StatistikoEvent; class AverageLeagueSeason { + /** + * BOX 6 - AVERAGE ALL LEAGUE FIXED TO ACTIVE SEASON + * + * @return void + */ public static function load(array &$expectations, array $filter) { $tournament_id = (int) $filter['league_id'] ?? 0; $seasonmode = $filter['seasonmode']; $active_season = GetSeason::active($seasonmode); - // Box 2 - // average made and got for liga selected - // fixed to active season - $res = StatistikoEvent::where('league_id', $tournament_id) ->when($active_season, function ($query) use ($active_season) { return $query->where('season', $active_season); diff --git a/app/Filament/Widgets/Boxes/AverageTeam.php b/app/Filament/Widgets/Boxes/AverageTeam.php index b69cc60c..6af3f2ee 100644 --- a/app/Filament/Widgets/Boxes/AverageTeam.php +++ b/app/Filament/Widgets/Boxes/AverageTeam.php @@ -8,8 +8,14 @@ use App\Models\StatistikoEvent; class AverageTeam { + /** + * BOX 4 - AVERAGE TEAM + * + * @return void + */ public static function load(array &$expectations, array $filter) { + $tournament_id = (int) $filter['league_id'] ?? 0; $team_position = $filter['team_position']; $team_id = (int) $filter['team_id'] ?? 0; @@ -27,15 +33,6 @@ class AverageTeam $season = GetSeason::load($season, $seasonmode); } - $active_season = GetSeason::active($seasonmode); - - // Average made and got for team selected - // Box 1 - // for selected Date or Time or All - // Box 2 - // fixed to active season - // Box 3 wie 2 - // fixed to active season but all league $res = StatistikoEvent::where('league_id', $tournament_id) ->when($start, function ($query) use ($start) { return $query->whereDate('starttime', '>=', $start); diff --git a/app/Filament/Widgets/Boxes/AverageTeamSeason.php b/app/Filament/Widgets/Boxes/AverageTeamSeason.php index 1d337d33..2603dffe 100644 --- a/app/Filament/Widgets/Boxes/AverageTeamSeason.php +++ b/app/Filament/Widgets/Boxes/AverageTeamSeason.php @@ -8,37 +8,27 @@ use App\Models\StatistikoEvent; class AverageTeamSeason { + /** + * BOX 5 - AVERAGE WITH TEAM FIXED TO ACTIVE SEASON + */ public static function load(array &$expectations, array $filter, object $match) { $tournament_id = (int) $filter['league_id'] ?? 0; - $team_position = $filter['team_position']; $team_id = (int) $filter['team_id'] ?? 0; $seasonmode = $filter['seasonmode']; - $home_id = $match->home_id; - $away_id = $match->away_id; $active_season = GetSeason::active($seasonmode); - // Box 2 - // average made and got for team selected - // fixed to active season - $res = StatistikoEvent::where('league_id', $tournament_id) ->when($active_season, function ($query) use ($active_season) { return $query->where('season', $active_season); })->when($team_id, function ($query) use ($team_id) { - return $query->orWhere('home_id', $team_id) - ->orWhere('away_id', '=', $team_id); + return $query->orWhere('home_id', $team_id)->orWhere('away_id', '=', $team_id); })->get(); - $result = []; if ($res) { - // 1) la media dei falli di tutte le partite giocate dal Flamengo - // (esempio, giocate 6 partite con falli 17-11-15-14-15-12, la media รจ 14) + $result = []; - // 2) la media dei falli di tutte le partite giocate nel campionato Brasiliano - // (esempio 6 giornate giocate = 60 partite quindi 120 squadre, quindi 120 dati tipo 17-12-12-15-8-15-13-21-..., - // quindi la media di questi 120 dati) foreach ($res as $val) { ExpectationAverage::filter($result, 'team', 'gls', $val->gls_a, $val->gls_h); ExpectationAverage::filter($result, 'team', 'crn', $val->crn_a, $val->crn_h); @@ -49,31 +39,6 @@ class AverageTeamSeason ExpectationAverage::filter($result, 'team', 'tsh', $val->tsh_a, $val->tsh_h); } - // foreach ($res as $val) { - // if ($team_position == 'home' && $team_id == $val->home_id) { - // ExpectationAverage::filter($result, 'team', 'gls', $val->gls_h, $val->gls_a); - // ExpectationAverage::filter($result, 'team', 'fls', $val->fls_h, $val->fls_a); - // ExpectationAverage::filter($result, 'team', 'ofs', $val->ofs_h, $val->ofs_a); - // ExpectationAverage::filter($result, 'team', 'crd', $val->crd_h, $val->crd_a); - // ExpectationAverage::filter($result, 'team', 'snt', $val->snt_h, $val->snt_a); - // ExpectationAverage::filter($result, 'team', 'tsh', $val->tsh_h, $val->tsh_a); - // } elseif ($team_position == 'away' && $team_id == $val->away_id) { - // ExpectationAverage::filter($result, 'team', 'gls', $val->gls_a, $val->gls_h); - // ExpectationAverage::filter($result, 'team', 'fls', $val->fls_a, $val->fls_h); - // ExpectationAverage::filter($result, 'team', 'ofs', $val->ofs_a, $val->ofs_h); - // ExpectationAverage::filter($result, 'team', 'crd', $val->crd_a, $val->crd_h); - // ExpectationAverage::filter($result, 'team', 'snt', $val->snt_a, $val->snt_h); - // ExpectationAverage::filter($result, 'team', 'tsh', $val->tsh_a, $val->tsh_h); - // } else { - // ExpectationAverage::filter($result, 'team', 'gls', $val->gls_a, $val->gls_h); - // ExpectationAverage::filter($result, 'team', 'fls', $val->fls_a, $val->fls_h); - // ExpectationAverage::filter($result, 'team', 'ofs', $val->ofs_a, $val->ofs_h); - // ExpectationAverage::filter($result, 'team', 'crd', $val->crd_a, $val->crd_h); - // ExpectationAverage::filter($result, 'team', 'snt', $val->snt_a, $val->snt_h); - // ExpectationAverage::filter($result, 'team', 'tsh', $val->tsh_a, $val->tsh_h); - // } - // } - $bets = ['gls', 'crn', 'fls', 'ofs', 'crd', 'snt', 'tsh']; if ($result) { foreach ($bets as $bet) { diff --git a/app/Filament/Widgets/Boxes/ExpectationsTeam.php b/app/Filament/Widgets/Boxes/ExpectationsTeam.php index c0466ece..7df4a840 100644 --- a/app/Filament/Widgets/Boxes/ExpectationsTeam.php +++ b/app/Filament/Widgets/Boxes/ExpectationsTeam.php @@ -2,9 +2,9 @@ namespace App\Filament\Widgets\Boxes; -use App\Filament\Widgets\Boxes\Helper\ExpectationCalculationMethodA; -use App\Filament\Widgets\Boxes\Helper\ExpectationCalculationMethodB; use App\Filament\Widgets\Boxes\Helper\ExpectationCollecting; +use App\Filament\Widgets\Boxes\Helper\ExpectationMethodA; +use App\Filament\Widgets\Boxes\Helper\ExpectationMethodB; use App\Filament\Widgets\Boxes\Helper\ExpectationsMinMax; use App\Filament\Widgets\Charts\LoadEvents\LoadEventsQueryAll; use App\Filament\Widgets\Charts\LoadEvents\LoadEventsQueryTP; @@ -53,9 +53,9 @@ class ExpectationsTeam } if (self::$collectionMethod == 'A') { - $expectations = ExpectationCalculationMethodA::calc($tmp); + $expectations = ExpectationMethodA::calc($tmp); } else { - $expectations = ExpectationCalculationMethodB::calc($tmp); + $expectations = ExpectationMethodB::calc($tmp); } ExpectationsMinMax::calc($expectations, $match); diff --git a/app/Filament/Widgets/Boxes/Helper/ExpectationCalculationMethodA.php b/app/Filament/Widgets/Boxes/Helper/ExpectationMethodA.php similarity index 98% rename from app/Filament/Widgets/Boxes/Helper/ExpectationCalculationMethodA.php rename to app/Filament/Widgets/Boxes/Helper/ExpectationMethodA.php index d0f17c9a..ea11e294 100644 --- a/app/Filament/Widgets/Boxes/Helper/ExpectationCalculationMethodA.php +++ b/app/Filament/Widgets/Boxes/Helper/ExpectationMethodA.php @@ -4,7 +4,7 @@ namespace App\Filament\Widgets\Boxes\Helper; use App\Models\StatistikoConfig; -class ExpectationCalculationMethodA +class ExpectationMethodA { public static function calc(array $expectations) { diff --git a/app/Filament/Widgets/Boxes/Helper/ExpectationCalculationMethodB.php b/app/Filament/Widgets/Boxes/Helper/ExpectationMethodB.php similarity index 97% rename from app/Filament/Widgets/Boxes/Helper/ExpectationCalculationMethodB.php rename to app/Filament/Widgets/Boxes/Helper/ExpectationMethodB.php index 89d9c903..a1b0218e 100644 --- a/app/Filament/Widgets/Boxes/Helper/ExpectationCalculationMethodB.php +++ b/app/Filament/Widgets/Boxes/Helper/ExpectationMethodB.php @@ -2,7 +2,7 @@ namespace App\Filament\Widgets\Boxes\Helper; -class ExpectationCalculationMethodB +class ExpectationMethodB { public static function calc(array $expectations) { diff --git a/app/Filament/Widgets/BoxesBettypeAll.php b/app/Filament/Widgets/BoxesBettypeAll.php index 67e37432..961fcc95 100644 --- a/app/Filament/Widgets/BoxesBettypeAll.php +++ b/app/Filament/Widgets/BoxesBettypeAll.php @@ -74,7 +74,7 @@ class BoxesBettypeAll extends StatsOverviewWidget ->description('Home - Away'); } - // BOX AVERAGE + // BOX AVERAGE TEAM if (isset($data['gls_team'])) { $boxes[] = Stat::make('Average '.$data['active_team'], self::template_tabelle_2($data)) ->extraAttributes(['class' => 'box-blank'])