wip fix error box 3

This commit is contained in:
salam committed 2026-10-12 21:51:50 +02:00
1 parent 2728944c39
commit e52722d3e1
9 files changed
+455 -119

No files matched your search

+25 -97
View File
@@ -7,8 +7,6 @@ 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;
use App\Utilities\Round;
class ExpectationsTeam
{
@@ -19,20 +17,8 @@ class ExpectationsTeam
/**
* STATTISTIC DATA
*/
$team_id = (int) $filter['team_id'] ?? 0;
$team_position = $filter['team_position'];
$similar_past_matches = $filter['similar_past_matches'];
if ($similar_past_matches != 'none') {
$team_id = 0;
$team_position = '';
$home_team = $match->home->ss_team_name;
$away_team = $match->away->ss_team_name;
} else {
$home_team = 'In Favour';
$away_team = 'Against';
}
$res = LoadEventsQueryAll::load($filter, $match);
if (! $res) {
@@ -42,13 +28,13 @@ class ExpectationsTeam
$tmp = [];
foreach ($res as $value) {
// dd($match->home_id, $match->away_id, $value);
ExpectationCollecting::sort($similar_past_matches, $tmp, 'gls', $value->home_id, $value->away_id, $value->gls_h, $value->gls_a, $match);
ExpectationCollecting::sort($similar_past_matches, $tmp, 'fls', $value->home_id, $value->away_id, $value->fls_h, $value->fls_a, $match);
ExpectationCollecting::sort($similar_past_matches, $tmp, 'ofs', $value->home_id, $value->away_id, $value->ofs_h, $value->ofs_a, $match);
ExpectationCollecting::sort($similar_past_matches, $tmp, 'crd', $value->home_id, $value->away_id, $value->crd_h, $value->crd_a, $match);
ExpectationCollecting::sort($similar_past_matches, $tmp, 'snt', $value->home_id, $value->away_id, $value->snt_h, $value->snt_a, $match);
ExpectationCollecting::sort($similar_past_matches, $tmp, 'tsh', $value->home_id, $value->away_id, $value->tsh_h, $value->tsh_a, $match);
ExpectationCollecting::sort($similar_past_matches, $tmp, 'crn', $value->home_id, $value->away_id, $value->crn_h, $value->crn_a, $match);
ExpectationCollecting::sort($similar_past_matches, $expectations, 'gls', $value->home_id, $value->away_id, $value->gls_h, $value->gls_a, $match);
ExpectationCollecting::sort($similar_past_matches, $expectations, 'fls', $value->home_id, $value->away_id, $value->fls_h, $value->fls_a, $match);
ExpectationCollecting::sort($similar_past_matches, $expectations, 'ofs', $value->home_id, $value->away_id, $value->ofs_h, $value->ofs_a, $match);
ExpectationCollecting::sort($similar_past_matches, $expectations, 'crd', $value->home_id, $value->away_id, $value->crd_h, $value->crd_a, $match);
ExpectationCollecting::sort($similar_past_matches, $expectations, 'snt', $value->home_id, $value->away_id, $value->snt_h, $value->snt_a, $match);
ExpectationCollecting::sort($similar_past_matches, $expectations, 'tsh', $value->home_id, $value->away_id, $value->tsh_h, $value->tsh_a, $match);
ExpectationCollecting::sort($similar_past_matches, $expectations, 'crn', $value->home_id, $value->away_id, $value->crn_h, $value->crn_a, $match);
}
if ($expectations) {
@@ -56,87 +42,29 @@ class ExpectationsTeam
$expectations = ExpectationMethodA::calc($tmp);
} else {
$expectations = ExpectationMethodB::calc($tmp);
ExpectationsMinMax::calc($expectations, $match);
}
}
$expectations['gls']['name'] = 'Goals';
$expectations['crn']['name'] = 'Corner';
$expectations['fls']['name'] = 'Fouls';
$expectations['ofs']['name'] = 'Offsides';
$expectations['crd']['name'] = 'Cards';
$expectations['snt']['name'] = 'Shots on Target';
$expectations['tsh']['name'] = 'Total Shots';
$expectations['home'] = $home_team;
$expectations['away'] = $away_team;
$res_tp = LoadEventsQueryTP::load($filter, $match);
$count_tp = $res_tp->count();
$expectations['count_events'] = $count_tp;
$expectations += ['win_count' => 0, 'draw_count' => 0, 'lost_count' => 0];
foreach ($res_tp as $value) {
if ($team_id && $team_position == 'home') {
switch ($value['result_code']) {
case '1':
$expectations['win_count']++;
break;
case 'X':
$expectations['draw_count']++;
break;
case '2':
$expectations['lost_count']++;
break;
}
} elseif ($team_id && $team_position == 'away') {
switch ($value['result_code']) {
case '1':
$expectations['win_count']++;
break;
case 'X':
$expectations['draw_count']++;
break;
case '2':
$expectations['lost_count']++;
break;
}
} else {
switch ($value['result_code']) {
case '1':
$expectations['win_count']++;
break;
case 'X':
$expectations['draw_count']++;
break;
case '2':
$expectations['lost_count']++;
break;
}
}
}
$expectations['win_odd'] = $expectations['win_count'] ? number_format(Round::odd($count_tp / $expectations['win_count']), 2) : 0;
$expectations['draw_odd'] = $expectations['draw_count'] ? number_format(Round::odd($count_tp / $expectations['draw_count']), 2) : 0;
$expectations['lost_odd'] = $expectations['lost_count'] ? number_format(Round::odd($count_tp / $expectations['lost_count']), 2) : 0;
}
public static function template()
{
$arr = [];
$bets = ['gls', 'crn', 'fls', 'ofs', 'crd', 'snt', 'tsh'];
foreach ($bets as $bet) {
foreach (['team_home', 'team_away'] as $team) {
foreach (['scored', 'conceded'] as $sc) {
foreach (['home', 'away'] as $ha) {
foreach (['evt', 'sum'] as $es) {
$arr[$bet][$team][$sc][$ha][$es] = 0;
}
}
}
}
}
// public static function template()
// {
// $arr = [];
// $bets = ['gls', 'crn', 'fls', 'ofs', 'crd', 'snt', 'tsh'];
// foreach ($bets as $bet) {
// foreach (['team_home', 'team_away'] as $team) {
// foreach (['scored', 'conceded'] as $sc) {
// foreach (['home', 'away'] as $ha) {
// foreach (['evt', 'sum'] as $es) {
// $arr[$bet][$team][$sc][$ha][$es] = 0;
// }
// }
// }
// }
// }
return $arr;
}
// return $arr;
// }
}