This commit is contained in:
salam committed 2026-06-16 15:44:12 +02:00
1 parent c9114b5e65
commit 640328c1ca
3 files changed
+115 -33

No files matched your search

+108 -31
View File
@@ -37,6 +37,7 @@ class LoadPerformance
$home_matches = [];
$away_matches = [];
$league_matches = [];
$date_home = [];
$date_away = [];
$events_home = [];
@@ -45,6 +46,7 @@ class LoadPerformance
$results_away = [];
$labels = [];
foreach ($res as $val) {
$league_matches[] = $val->match_id;
if ($val->home_id == $home_id or $val->away_id == $home_id) {
$labels[] = round($val->starttime->diffInDays(Carbon::now()));
@@ -69,10 +71,14 @@ class LoadPerformance
$aways = self::filterMatches($res, $away_matches);
self::shortenEnding($labels, $homes, $aways);
$home_av = self::makeAv($homes);
$away_av = self::makeAv($aways);
$res = StatistikoPlayer::whereIn('match_id', $league_matches)->select('match_id', 'minutes_played', 'playerrating_value', 'player_position')->get();
$league = self::filterMatches($res, $league_matches);
$league_av = self::leagueAv($league, count($homes['all']));
$data = [
'datasets' => [
[
@@ -88,7 +94,7 @@ class LoadPerformance
'pointStyle' => $hasdots,
],
[
'label' => 'Average All',
'label' => 'Average Team',
'playing_date' => $date_home,
'results_per_event' => $results_home,
'events' => $events_home,
@@ -108,8 +114,8 @@ class LoadPerformance
'data' => $homes['def'] ?? [],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#c10007',
'backgroundColor' => '#c10007',
'borderColor' => '#ff6900',
'backgroundColor' => '#ff6900',
'fill' => false,
'pointStyle' => $hasdots,
'hidden' => true,
@@ -122,8 +128,8 @@ class LoadPerformance
'data' => $home_av['def'],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#c10007',
'backgroundColor' => '#c10007',
'borderColor' => '#ff6900',
'backgroundColor' => '#ff6900',
'pointStyle' => false,
'hidden' => true,
'borderDash' => [5, 5],
@@ -136,8 +142,8 @@ class LoadPerformance
'data' => $homes['att'] ?? [],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#c10007',
'backgroundColor' => '#c10007',
'borderColor' => '#ff6900',
'backgroundColor' => '#ff6900',
'fill' => false,
'pointStyle' => $hasdots,
'hidden' => true,
@@ -150,8 +156,8 @@ class LoadPerformance
'data' => $home_av['att'] ?? [],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#c10007',
'backgroundColor' => '#c10007',
'borderColor' => '#ff6900',
'backgroundColor' => '#ff6900',
'fill' => false,
'pointStyle' => false,
'hidden' => true,
@@ -165,8 +171,8 @@ class LoadPerformance
'data' => $homes['mid'] ?? [],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#c10007',
'backgroundColor' => '#c10007',
'borderColor' => '#ff6900',
'backgroundColor' => '#ff6900',
'fill' => false,
'pointStyle' => $hasdots,
'hidden' => true,
@@ -179,8 +185,8 @@ class LoadPerformance
'data' => $home_av['mid'] ?? [],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#c10007',
'backgroundColor' => '#c10007',
'borderColor' => '#ff6900',
'backgroundColor' => '#ff6900',
'fill' => false,
'pointStyle' => false,
'borderDash' => [5, 5],
@@ -194,22 +200,22 @@ class LoadPerformance
'data' => $aways['all'] ?? [],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#fdc700',
'backgroundColor' => '#fdc700',
'borderColor' => '#00c950',
'backgroundColor' => '#00c950',
'fill' => false,
'pointStyle' => $hasdots,
'hidden' => true,
],
[
'label' => 'Average All',
'label' => 'Average Team',
'playing_date' => $date_away,
'results_per_event' => $results_away,
'events' => $events_away,
'data' => $away_av['all'] ?? [],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#fdc700',
'backgroundColor' => '#fdc700',
'borderColor' => '#00c950',
'backgroundColor' => '#00c950',
'fill' => false,
'pointStyle' => false,
'borderDash' => [5, 5],
@@ -223,8 +229,8 @@ class LoadPerformance
'data' => $aways['def'] ?? [],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#d08700',
'backgroundColor' => '#d08700',
'borderColor' => '#009966',
'backgroundColor' => '#009966',
'fill' => false,
'pointStyle' => $hasdots,
'hidden' => true,
@@ -237,8 +243,8 @@ class LoadPerformance
'data' => $away_av['def'] ?? [],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#d08700',
'backgroundColor' => '#d08700',
'borderColor' => '#009966',
'backgroundColor' => '#009966',
'fill' => false,
'pointStyle' => false,
'borderDash' => [5, 5],
@@ -252,8 +258,8 @@ class LoadPerformance
'data' => $aways['att'] ?? [],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#d08700',
'backgroundColor' => '#d08700',
'borderColor' => '#009966',
'backgroundColor' => '#009966',
'fill' => false,
'pointStyle' => $hasdots,
'hidden' => true,
@@ -266,8 +272,8 @@ class LoadPerformance
'data' => $away_av['att'] ?? [],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#d08700',
'backgroundColor' => '#d08700',
'borderColor' => '#009966',
'backgroundColor' => '#009966',
'fill' => false,
'pointStyle' => false,
'borderDash' => [5, 5],
@@ -281,8 +287,8 @@ class LoadPerformance
'data' => $aways['mid'] ?? [],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#d08700',
'backgroundColor' => '#d08700',
'borderColor' => '#009966',
'backgroundColor' => '#009966',
'fill' => false,
'pointStyle' => $hasdots,
'hidden' => true,
@@ -295,13 +301,69 @@ class LoadPerformance
'data' => $away_av['mid'] ?? [],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#d08700',
'backgroundColor' => '#d08700',
'borderColor' => '#009966',
'backgroundColor' => '#009966',
'fill' => false,
'pointStyle' => false,
'borderDash' => [5, 5],
'hidden' => true,
],
[
'label' => 'Average League',
'playing_date' => $date_home,
'results_per_event' => $results_home,
'events' => $events_home,
'data' => $league_av['all'],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#00a6f4',
'backgroundColor' => '#00a6f4',
'pointStyle' => false,
'borderDash' => [5, 5],
'hidden' => true,
],
[
'label' => 'Average Defence',
'playing_date' => $date_home,
'results_per_event' => $results_home,
'events' => $events_home,
'data' => $league_av['def'],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#155dfc',
'backgroundColor' => '#155dfc',
'pointStyle' => false,
'borderDash' => [5, 5],
'hidden' => true,
],
[
'label' => 'Average Attak',
'playing_date' => $date_home,
'results_per_event' => $results_home,
'events' => $events_home,
'data' => $league_av['att'],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#155dfc',
'backgroundColor' => '#155dfc',
'pointStyle' => false,
'borderDash' => [5, 5],
'hidden' => true,
],
[
'label' => 'Average Midfield',
'playing_date' => $date_home,
'results_per_event' => $results_home,
'events' => $events_home,
'data' => $league_av['mid'],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#155dfc',
'backgroundColor' => '#155dfc',
'pointStyle' => false,
'borderDash' => [5, 5],
'hidden' => true,
],
],
'labels' => $labels,
];
@@ -432,4 +494,19 @@ class LoadPerformance
return $ret;
}
public static function leagueAv(array &$arr, $len)
{
$all = array_sum($arr['all']) / count($arr['all']);
$def = array_sum($arr['def']) / count($arr['def']);
$mid = array_sum($arr['mid']) / count($arr['mid']);
$att = array_sum($arr['att']) / count($arr['att']);
$ret = [];
$ret['all'] = array_fill(0, $len, round($all, 2));
$ret['def'] = array_fill(0, $len, round($def, 2));
$ret['mid'] = array_fill(0, $len, round($mid, 2));
$ret['att'] = array_fill(0, $len, round($att, 2));
return $ret;
}
}