This commit is contained in:
salam committed 2026-07-27 18:36:54 +02:00
1 parent 332bdc9985
commit 3627a78989
2 files changed
+97 -95

No files matched your search

@@ -7,7 +7,7 @@ use App\Models\StatistikoEvent;
class LoadEventsAverages
{
public static function load(array &$data, array $filter,array $labels, array $events)
public static function load(array &$data, array $filter, array $labels, array $events)
{
$league_id = (int) $filter['league_id'] ?? 0;
@@ -46,7 +46,6 @@ class LoadEventsAverages
// quindi la media di questi 120 dati)
foreach ($res as $value) {
switch ($statistic_type) {
case 'gls':
$league_home[] = (int) $value['gls_h'];
@@ -78,135 +77,134 @@ class LoadEventsAverages
break;
}
if ($team_position == 'all' && ($team_id == $value['home_id'] or $team_id == $value['away_id'])) {
switch ($statistic_type) {
case 'gls':
if ($team_id == $value['home_id']) {
$team_home[] = (int) $value['gls_h'];
$team_away[] =(int) $value['gls_a'];
} else {
$team_home[] = (int) $value['gls_a'];
$team_away[] =(int) $value['gls_h'];
}
break;
case 'crn':
if ($team_id == $value['home_id']) {
$team_home[] = (int) $value['crn_h'];
$team_away[] =(int) $value['crn_a'];
} else {
$team_home[] = (int) $value['crn_a'];
$team_away[] =(int) $value['crn_h'];
}
break;
case 'fls':
if ($team_id == $value['home_id']) {
$team_home[] = (int) $value['fls_h'];
$team_away[] =(int) $value['fls_a'];
} else {
$team_home[] = (int) $value['fls_a'];
$team_away[] =(int) $value['fls_h'];
}
break;
case 'ofs':
if ($team_id == $value['home_id']) {
$team_home[] = (int) $value['ofs_h'];
$team_away[] =(int) $value['ofs_a'];
} else {
$team_home[] = (int) $value['ofs_a'];
$team_away[] =(int) $value['ofs_h'];
}
break;
case 'crd':
if ($team_id == $value['home_id']) {
$team_home[] = (int) $value['crd_h'];
$team_away[] =(int) $value['crd_a'];
} else {
$team_home[] = (int) $value['crd_a'];
$team_away[] =(int) $value['crd_h'];
}
break;
case 'snt':
if ($team_id == $value['home_id']) {
$team_home[] = (int) $value['snt_h'];
$team_away[] =(int) $value['snt_a'];
} else {
$team_home[] = (int) $value['snt_a'];
$team_away[] =(int) $value['snt_h'];
}
break;
case 'tsh':
if ($team_id == $value['home_id']) {
$team_home[] = (int) $value['tsh_h'];
$team_away[] =(int) $value['tsh_a'];
} else {
$team_home[] = (int) $value['tsh_a'];
$team_away[] =(int) $value['tsh_h'];
}
break;
}
}
// dd($team_position, $team_id, $value);
else if ($team_position == 'home' && $team_id == $value['home_id']) {
if ((!$team_position || $team_position == 'all') && ($team_id == $value['home_id'] or $team_id == $value['away_id'])) {
switch ($statistic_type) {
case 'gls':
if ($team_id == $value['home_id']) {
$team_home[] = (int) $value['gls_h'];
$team_away[] = (int) $value['gls_a'];
} else {
$team_home[] = (int) $value['gls_a'];
$team_away[] = (int) $value['gls_h'];
}
break;
case 'crn':
if ($team_id == $value['home_id']) {
$team_home[] = (int) $value['crn_h'];
$team_away[] = (int) $value['crn_a'];
} else {
$team_home[] = (int) $value['crn_a'];
$team_away[] = (int) $value['crn_h'];
}
break;
case 'fls':
if ($team_id == $value['home_id']) {
$team_home[] = (int) $value['fls_h'];
$team_away[] = (int) $value['fls_a'];
} else {
$team_home[] = (int) $value['fls_a'];
$team_away[] = (int) $value['fls_h'];
}
break;
case 'ofs':
if ($team_id == $value['home_id']) {
$team_home[] = (int) $value['ofs_h'];
$team_away[] = (int) $value['ofs_a'];
} else {
$team_home[] = (int) $value['ofs_a'];
$team_away[] = (int) $value['ofs_h'];
}
break;
case 'crd':
if ($team_id == $value['home_id']) {
$team_home[] = (int) $value['crd_h'];
$team_away[] = (int) $value['crd_a'];
} else {
$team_home[] = (int) $value['crd_a'];
$team_away[] = (int) $value['crd_h'];
}
break;
case 'snt':
if ($team_id == $value['home_id']) {
$team_home[] = (int) $value['snt_h'];
$team_away[] = (int) $value['snt_a'];
} else {
$team_home[] = (int) $value['snt_a'];
$team_away[] = (int) $value['snt_h'];
}
break;
case 'tsh':
if ($team_id == $value['home_id']) {
$team_home[] = (int) $value['tsh_h'];
$team_away[] = (int) $value['tsh_a'];
} else {
$team_home[] = (int) $value['tsh_a'];
$team_away[] = (int) $value['tsh_h'];
}
break;
}
} else if ($team_position == 'home' && $team_id == $value['home_id']) {
switch ($statistic_type) {
case 'gls':
$team_home[] = (int) $value['gls_h'];
$team_away[] =(int) $value['gls_a'];
$team_away[] = (int) $value['gls_a'];
break;
case 'crn':
$team_home[] = (int) $value['crn_h'];
$team_away[] =(int) $value['crn_a'];
$team_away[] = (int) $value['crn_a'];
break;
case 'fls':
$team_home[] = (int) $value['fls_h'];
$team_away[] =(int) $value['fls_a'];
$team_away[] = (int) $value['fls_a'];
break;
case 'ofs':
$team_home[] = (int) $value['ofs_h'];
$team_away[] =(int) $value['ofs_a'];
$team_away[] = (int) $value['ofs_a'];
break;
case 'crd':
$team_home[] = (int) $value['crd_h'];
$team_away[] =(int) $value['crd_a'];
$team_away[] = (int) $value['crd_a'];
break;
case 'snt':
$team_home[] = (int) $value['snt_h'];
$team_away[] =(int) $value['snt_a'];
$team_away[] = (int) $value['snt_a'];
break;
case 'tsh':
$team_home[] = (int) $value['tsh_h'];
$team_away[] =(int) $value['tsh_a'];
$team_away[] = (int) $value['tsh_a'];
break;
}
}
else if ($team_position == 'away' && $team_id == $value['away_id']) {
} else if ($team_position == 'away' && $team_id == $value['away_id']) {
switch ($statistic_type) {
case 'gls':
$team_home[] = (int) $value['gls_a'];
$team_away[] =(int) $value['gls_h'];
$team_away[] = (int) $value['gls_h'];
break;
case 'crn':
$team_home[] = (int) $value['crn_a'];
$team_away[] =(int) $value['crn_h'];
$team_away[] = (int) $value['crn_h'];
break;
case 'fls':
$team_home[] = (int) $value['fls_a'];
$team_away[] =(int) $value['fls_h'];
$team_away[] = (int) $value['fls_h'];
break;
case 'ofs':
$team_home[] = (int) $value['ofs_a'];
$team_away[] =(int) $value['ofs_h'];
$team_away[] = (int) $value['ofs_h'];
break;
case 'crd':
$team_home[] = (int) $value['crd_a'];
$team_away[] =(int) $value['crd_h'];
$team_away[] = (int) $value['crd_h'];
break;
case 'snt':
$team_home[] = (int) $value['snt_a'];
$team_away[] =(int) $value['snt_h'];
$team_away[] = (int) $value['snt_h'];
break;
case 'tsh':
$team_home[] = (int) $value['tsh_a'];
$team_away[] =(int) $value['tsh_h'];
$team_away[] = (int) $value['tsh_h'];
break;
}
}
@@ -219,7 +217,9 @@ class LoadEventsAverages
$average_league_home = 0;
$average_league_away = 0;
if ($team_id && $team_home){
// dd($team_home);
if ($team_id && $team_home) {
$sum = array_sum($team_home) + array_sum($team_away);
@@ -231,9 +231,9 @@ class LoadEventsAverages
$average_team_away = round(array_sum($team_away) / count($team_away), 1);
$average_league_home = $league_home ? round(array_sum($league_home) / \count($league_home), 1):0;
$average_league_home = $league_home ? round(array_sum($league_home) / \count($league_home), 1) : 0;
$average_league_away = $league_away ? round(array_sum($league_away) / \count($league_away), 1):0;
$average_league_away = $league_away ? round(array_sum($league_away) / \count($league_away), 1) : 0;
$media_league = array_merge($league_away, $league_home);
+8 -6
View File
@@ -105,6 +105,8 @@ class StatsMedianAverage extends StatsOverviewWidget
$average_league_home = 0;
$average_league_away = 0;
// Log::debug($data);
foreach ($data['datasets'] as $value) {
if ($value['label'] == 'Average Team') {
$average_team_home = $value['average_team_home'] ?? 0;
@@ -121,16 +123,16 @@ class StatsMedianAverage extends StatsOverviewWidget
$boxes = [];
// BOX 1
$boxes[] = Stat::make('Number', new HtmlString('<div id="number-of-events">' . $total_home . '</div>'))
->description('Events')
->extraAttributes(['x-init' => "animate('number-of-events', $total_home, 0)"]);
->description('Events');
// ->extraAttributes(['x-init' => "animate('number-of-events', $total_home, 0)"]);
// BOX 2
Log::debug([$home_team, $value_home]);
$boxes[] = Stat::make('Average ' . $statistic_type, self::template('avhome', 'avaway', $home_team, $away_team, $value_home, $value_away))
->description('Team ' . $team_position);
// ->extraAttributes(['x-init' => "animate('avhome', $value_home); animate('avaway', $value_away)"]);
// BOX 3
// Log::debug([$average_team_home, $average_team_away]);
$boxes[] = Stat::make('Average ' . $statistic_type, self::template('av_team_home', 'av_team_away', $home_team, $away_team, $average_team_home, $average_team_away))
->description('Team Season');
// ->extraAttributes(['x-init' => "animate('av_team_home', $average_team_home); animate('av_team_away', $average_team_away)"]);
@@ -142,15 +144,15 @@ class StatsMedianAverage extends StatsOverviewWidget
// BOX 5
$boxes[] = Stat::make('Odds', self::templateOdds($data, $win, $draw, $lost))
->description($team_position)
->extraAttributes(['x-init' => "animate('mehome', $median_home); animate('meaway', $median_away, 0)"]);
->description($team_position);
// ->extraAttributes(['x-init' => "animate('mehome', $median_home); animate('meaway', $median_away, 0)"]);
$this->columns = [
'default' => 1,
'sm' => 2,
'md' => 3,
'lg' => 4,
'xl' => $max_boxes,
'xl' => 5,
];
return $boxes;