wip
This commit is contained in:
1 parent
bca5e9ec23
commit
d954a9fa5c
19 files changed
+5718
-479
No files matched your search
@@ -13,7 +13,7 @@ class LoadPerformance
|
||||
|
||||
public static $events_data = [];
|
||||
|
||||
public static function load(array $filter)
|
||||
public static function load(array $filter, bool $hasdots)
|
||||
{
|
||||
// dd($filter);
|
||||
|
||||
@@ -43,6 +43,7 @@ class LoadPerformance
|
||||
if ($val->home_id == $home_id or $val->away_id == $home_id or $val->home_id == $away_id or $val->away_id == $away_id) {
|
||||
|
||||
$labels[] = round($val->starttime->diffInDays(Carbon::now()));
|
||||
|
||||
$label_formatted[$val->match_id] = $val->starttime->format('d. F Y H:i');
|
||||
|
||||
if ($val->home_id == $home_id or $val->away_id == $home_id) {
|
||||
@@ -66,6 +67,8 @@ class LoadPerformance
|
||||
$res = StatistikoPlayer::whereIn('match_id', $away_matches)->select('match_id', 'minutes_played', 'playerrating_value', 'player_position')->get();
|
||||
$aways = self::filterMatches($res, $away_matches);
|
||||
|
||||
self::shortenEnding($labels, $homes, $aways);
|
||||
|
||||
$data = [
|
||||
'datasets' => [
|
||||
[
|
||||
@@ -75,6 +78,7 @@ class LoadPerformance
|
||||
'tension' => 0.5,
|
||||
'borderColor' => '#fb2c36',
|
||||
'backgroundColor' => '#fb2c36',
|
||||
'pointStyle' => $hasdots,
|
||||
],
|
||||
[
|
||||
'label' => 'Defence',
|
||||
@@ -84,6 +88,7 @@ class LoadPerformance
|
||||
'borderColor' => '#c10007',
|
||||
'backgroundColor' => '#c10007',
|
||||
'fill' => false,
|
||||
'pointStyle' => $hasdots,
|
||||
],
|
||||
[
|
||||
'label' => 'Attak',
|
||||
@@ -93,6 +98,7 @@ class LoadPerformance
|
||||
'borderColor' => '#c10007',
|
||||
'backgroundColor' => '#c10007',
|
||||
'fill' => false,
|
||||
'pointStyle' => $hasdots,
|
||||
],
|
||||
[
|
||||
'label' => 'Midfield',
|
||||
@@ -102,6 +108,7 @@ class LoadPerformance
|
||||
'borderColor' => '#c10007',
|
||||
'backgroundColor' => '#c10007',
|
||||
'fill' => false,
|
||||
'pointStyle' => $hasdots,
|
||||
],
|
||||
[
|
||||
'label' => $match->away->name,
|
||||
@@ -111,6 +118,7 @@ class LoadPerformance
|
||||
'borderColor' => '#fdc700',
|
||||
'backgroundColor' => '#fdc700',
|
||||
'fill' => false,
|
||||
'pointStyle' => $hasdots,
|
||||
],
|
||||
[
|
||||
'label' => 'Defence',
|
||||
@@ -120,6 +128,7 @@ class LoadPerformance
|
||||
'borderColor' => '#d08700',
|
||||
'backgroundColor' => '#d08700',
|
||||
'fill' => false,
|
||||
'pointStyle' => $hasdots,
|
||||
],
|
||||
[
|
||||
'label' => 'Attak',
|
||||
@@ -129,6 +138,7 @@ class LoadPerformance
|
||||
'borderColor' => '#d08700',
|
||||
'backgroundColor' => '#d08700',
|
||||
'fill' => false,
|
||||
'pointStyle' => $hasdots,
|
||||
],
|
||||
[
|
||||
'label' => 'Midfield',
|
||||
@@ -138,6 +148,7 @@ class LoadPerformance
|
||||
'borderColor' => '#d08700',
|
||||
'backgroundColor' => '#d08700',
|
||||
'fill' => false,
|
||||
'pointStyle' => $hasdots,
|
||||
],
|
||||
],
|
||||
'labels' => $labels,
|
||||
@@ -149,6 +160,7 @@ class LoadPerformance
|
||||
|
||||
public static function filterMatches($res, $matches)
|
||||
{
|
||||
|
||||
$result = [];
|
||||
foreach ($res as $value) {
|
||||
|
||||
@@ -207,6 +219,43 @@ class LoadPerformance
|
||||
}
|
||||
}
|
||||
|
||||
// dd($return);
|
||||
// while (array_last($return['all']) == null) {
|
||||
// }
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function shortenEnding(array &$labels, array &$homes, array &$aways)
|
||||
{
|
||||
$count_home = 0;
|
||||
$count_away = 0;
|
||||
for ($i = \count($homes['all']) - 1; $i > 0; $i--) {
|
||||
if ($homes['all'][$i] == null) {
|
||||
$count_home++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for ($i = \count($aways['all']) - 1; $i > 0; $i--) {
|
||||
if ($aways['all'][$i] == null) {
|
||||
$count_away++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$keeps = count($homes['all']) - min($count_home, $count_away) - 1;
|
||||
|
||||
$homes['all'] = array_slice($homes['all'], 0, $keeps);
|
||||
$homes['def'] = array_slice($homes['def'], 0, $keeps);
|
||||
$homes['att'] = array_slice($homes['att'], 0, $keeps);
|
||||
$homes['mid'] = array_slice($homes['mid'], 0, $keeps);
|
||||
$aways['all'] = array_slice($aways['all'], 0, $keeps);
|
||||
$aways['def'] = array_slice($aways['def'], 0, $keeps);
|
||||
$aways['att'] = array_slice($aways['att'], 0, $keeps);
|
||||
$aways['mid'] = array_slice($aways['mid'], 0, $keeps);
|
||||
$labels = array_slice($labels, 0, $keeps);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user