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

@@ -8,7 +8,7 @@ use App\Models\StatistikoPlayer;
class LoadEventsQuery
{
public static function load(array $filter, array $handicap_range, array $total_range, object $match)
public static function load(array $filter, array $handicap_range, array $total_range, object $match)
{
$league_id = (int) $filter['league_id'] ?? 0;
$team_id = (int) $filter['team_id'] ?? 0;
@@ -84,8 +84,6 @@ class LoadEventsQuery
/**
* STATTISTIC DATA
*/
// dd($team_id, $home_id, $away_id);
$res = StatistikoEvent::with('home')->with('away')
->where(function ($query) use ($league_id, $similar_past_matches) {
@@ -122,13 +120,14 @@ class LoadEventsQuery
return $query->whereDate('starttime', '<=', $end);
})
->when($season, function ($query) use ($season, $season_or_date) {
if ($season_or_date == 'season')
if ($season_or_date == 'season') {
return $query->whereIn('season', $season);
}
})
->orderBy('starttime', 'ASC')
->get();
// dd($season, $res);
// dd($season, $team_id, $home_id, $away_id, $res);
$arr = [];
foreach ($res as $value) {
@@ -181,10 +180,12 @@ class LoadEventsQuery
}
$arr['all'][] = $tmp;
if ($value->home_id == $team_id)
if ($value->home_id == $team_id) {
$arr['home'][] = $tmp;
if ($value->away_id == $team_id)
}
if ($value->away_id == $team_id) {
$arr['away'][] = $tmp;
}
}
return $arr;
@@ -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];