fix box 1

This commit is contained in:
salam committed 2026-08-30 07:25:28 +02:00
1 parent 4ec3a86c9e
commit c49f5e2364
7 files changed
+230 -194

No files matched your search

@@ -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];