wip bug average season tem and league
This commit is contained in:
1 parent
537cdd1b31
commit
c4ef7514e3
5 files changed
+310
-168
No files matched your search
@@ -291,7 +291,7 @@ class Statistic extends BaseDashboard
|
|||||||
return LoadSeasons::load($get('league_id'));
|
return LoadSeasons::load($get('league_id'));
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function (callable $set) {
|
->afterStateUpdated(function (callable $set) {
|
||||||
$set('team_id', null);
|
// $set('team_id', null);
|
||||||
$set('tm_player_id', null);
|
$set('tm_player_id', null);
|
||||||
})
|
})
|
||||||
->live(),
|
->live(),
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class HelperTeamPosition
|
|||||||
{
|
{
|
||||||
public static function get($filter): string
|
public static function get($filter): string
|
||||||
{
|
{
|
||||||
$tmp = $filter['team_position'] ?? 'none';
|
$tmp = $filter['team_position'] ?? 'Position Both';
|
||||||
|
|
||||||
return ucfirst($tmp);
|
return ucfirst($tmp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Filament\Widgets\Data;
|
namespace App\Filament\Widgets\Data;
|
||||||
|
|
||||||
|
use App\Filament\Widgets\Data\LoadEvents\LoadEventsAverages;
|
||||||
use App\Models\CompetitionGroup;
|
use App\Models\CompetitionGroup;
|
||||||
use App\Models\StatisticFixtures;
|
use App\Models\StatisticFixtures;
|
||||||
use App\Models\StatistikoDetail;
|
use App\Models\StatistikoDetail;
|
||||||
@@ -237,7 +238,6 @@ class LoadEvents
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
||||||
if ($team_position == 'home') {
|
if ($team_position == 'home') {
|
||||||
switch ($value['result_code']) {
|
switch ($value['result_code']) {
|
||||||
case '1':
|
case '1':
|
||||||
@@ -444,7 +444,6 @@ class LoadEvents
|
|||||||
$label2 = 'Against';
|
$label2 = 'Against';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
self::shortenEnding($labels, $dataset_home, $dataset_away);
|
self::shortenEnding($labels, $dataset_home, $dataset_away);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
@@ -517,160 +516,11 @@ class LoadEvents
|
|||||||
* LEAGUE AVERAGES
|
* LEAGUE AVERAGES
|
||||||
*/
|
*/
|
||||||
if ($similar_past_matches == 'none') {
|
if ($similar_past_matches == 'none') {
|
||||||
$res = CompetitionGroup::with('country')->where('id', $league_id)->first();
|
LoadEventsAverages::load($data, $filter, $labels, $events);
|
||||||
$season_mode = $res->country->season_mode;
|
|
||||||
if ($season_mode == 'fullyear') {
|
|
||||||
$season = date('Y');
|
|
||||||
} else {
|
|
||||||
$season = date('y') - 1 . '/' . date('Y');
|
|
||||||
}
|
|
||||||
|
|
||||||
$res = StatistikoEvent::where('league_id', $league_id)
|
|
||||||
->where('season', $season)
|
|
||||||
->orderBy('starttime', 'ASC')
|
|
||||||
->get();
|
|
||||||
|
|
||||||
if ($res) {
|
|
||||||
|
|
||||||
$media_team_h = [];
|
|
||||||
$media_team_a = [];
|
|
||||||
$media_league_h = [];
|
|
||||||
$media_league_a = [];
|
|
||||||
|
|
||||||
// 1) la media dei falli di tutte le partite giocate dal Flamengo
|
|
||||||
// (esempio, giocate 6 partite con falli 17-11-15-14-15-12, la media è 14)
|
|
||||||
|
|
||||||
// 2) la media dei falli di tutte le partite giocate nel campionato Brasiliano
|
|
||||||
// (esempio 6 giornate giocate = 60 partite quindi 120 squadre, quindi 120 dati tipo 17-12-12-15-8-15-13-21-...,
|
|
||||||
// quindi la media di questi 120 dati)
|
|
||||||
|
|
||||||
foreach ($res as $value) {
|
|
||||||
if (
|
|
||||||
($team_position == 'all' && ($team_id == $value['home_id'] or $team_id == $value['away_id'])) or
|
|
||||||
($team_position == 'home' && $team_id == $value['home_id']) or
|
|
||||||
($team_position == 'away' && $team_id == $value['away_id'])
|
|
||||||
) {
|
|
||||||
switch ($statistic_type) {
|
|
||||||
case 'gls':
|
|
||||||
$media_team_h[] = (int) $value['gls_h'];
|
|
||||||
$media_team_a[] = (int) $value['gls_a'];
|
|
||||||
break;
|
|
||||||
case 'crn':
|
|
||||||
$media_team_h[] = (int) $value['crn_h'];
|
|
||||||
$media_team_a[] = (int) $value['crn_a'];
|
|
||||||
break;
|
|
||||||
case 'fls':
|
|
||||||
$media_team_h[] = (int) $value['fls_h'];
|
|
||||||
$media_team_a[] = (int) $value['fls_a'];
|
|
||||||
break;
|
|
||||||
case 'ofs':
|
|
||||||
$media_team_h[] = (int) $value['ofs_h'];
|
|
||||||
$media_team_a[] = (int) $value['ofs_a'];
|
|
||||||
break;
|
|
||||||
case 'crd':
|
|
||||||
$media_team_h[] = (int) $value['crd_h'];
|
|
||||||
$media_team_a[] = (int) $value['crd_a'];
|
|
||||||
break;
|
|
||||||
case 'snt':
|
|
||||||
$media_team_h[] = (int) $value['snt_h'];
|
|
||||||
$media_team_a[] = (int) $value['snt_a'];
|
|
||||||
break;
|
|
||||||
case 'tsh':
|
|
||||||
$media_team_h[] = (int) $value['tsh_h'];
|
|
||||||
$media_team_a[] = (int) $value['tsh_a'];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($statistic_type) {
|
|
||||||
case 'gls':
|
|
||||||
$media_league_h[] = (int) $value['gls_h'];
|
|
||||||
$media_league_a[] = (int) $value['gls_a'];
|
|
||||||
break;
|
|
||||||
case 'crn':
|
|
||||||
$media_league_h[] = (int) $value['crn_h'];
|
|
||||||
$media_league_a[] = (int) $value['crn_a'];
|
|
||||||
break;
|
|
||||||
case 'fls':
|
|
||||||
$media_league_h[] = (int) $value['fls_h'];
|
|
||||||
$media_league_a[] = (int) $value['fls_a'];
|
|
||||||
break;
|
|
||||||
case 'ofs':
|
|
||||||
$media_league_h[] = (int) $value['ofs_h'];
|
|
||||||
$media_league_a[] = (int) $value['ofs_a'];
|
|
||||||
break;
|
|
||||||
case 'crd':
|
|
||||||
$media_league_h[] = (int) $value['crd_h'];
|
|
||||||
$media_league_a[] = (int) $value['crd_a'];
|
|
||||||
break;
|
|
||||||
case 'snt':
|
|
||||||
$media_league_h[] = (int) $value['snt_h'];
|
|
||||||
$media_league_a[] = (int) $value['snt_a'];
|
|
||||||
break;
|
|
||||||
case 'tsh':
|
|
||||||
$media_league_h[] = (int) $value['tsh_h'];
|
|
||||||
$media_league_a[] = (int) $value['tsh_a'];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$average_team = 0;
|
|
||||||
$average_team_h = 0;
|
|
||||||
$average_team_a = 0;
|
|
||||||
$average_league = 0;
|
|
||||||
$average_league_h = 0;
|
|
||||||
$average_league_a = 0;
|
|
||||||
if ($team_id && $media_team_h){
|
|
||||||
$sum = array_sum($media_team_h) + array_sum($media_team_a);
|
|
||||||
$count = count($media_team_h) + count($media_team_a);
|
|
||||||
$average_team = round($sum / $count, 1);
|
|
||||||
$average_team_h = round(array_sum($media_team_h) / count($media_team_h), 1);
|
|
||||||
$average_team_a = round(array_sum($media_team_a) / count($media_team_a), 1);
|
|
||||||
|
|
||||||
$average_league_h = $media_league_h ? round(array_sum($media_league_h) / \count($media_league_h), 1):0;
|
|
||||||
$average_league_a = $media_league_a ? round(array_sum($media_league_a) / \count($media_league_a), 1):0;
|
|
||||||
|
|
||||||
$media_league = array_merge($media_league_a, $media_league_h);
|
|
||||||
$average_league = $media_league ? round(array_sum($media_league) / \count($media_league), 1) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data_team = array_fill(0, count($labels), $average_team);
|
|
||||||
$data_league = array_fill(0, count($labels), $average_league);
|
|
||||||
|
|
||||||
$data['datasets'][] = [
|
|
||||||
'label' => 'Average Team',
|
|
||||||
'events' => $events,
|
|
||||||
'data' => $data_team,
|
|
||||||
'tension' => 0.5,
|
|
||||||
'borderColor' => '#ad46ff',
|
|
||||||
'backgroundColor' => '#ad46ff',
|
|
||||||
'borderDash' => [5, 5],
|
|
||||||
'pointStyle' => false,
|
|
||||||
'hidden' => false,
|
|
||||||
'average_team_h' => $average_team_h,
|
|
||||||
'average_team_a' => $average_team_a,
|
|
||||||
];
|
|
||||||
$data['datasets'][] = [
|
|
||||||
'label' => 'Average League',
|
|
||||||
'events' => $events,
|
|
||||||
'data' => $data_league,
|
|
||||||
'tension' => 0.5,
|
|
||||||
'borderColor' => '#00bba7',
|
|
||||||
'backgroundColor' => '#00bba7',
|
|
||||||
'borderDash' => [5, 5],
|
|
||||||
'pointStyle' => false,
|
|
||||||
'hidden' => false,
|
|
||||||
'average_league_h' => $average_league_h,
|
|
||||||
'average_league_a' => $average_league_a,
|
|
||||||
];
|
|
||||||
// dd($data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$last_query = $data;
|
self::$last_query = $data;
|
||||||
|
|
||||||
// dd($data);
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,274 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Widgets\Data\LoadEvents;
|
||||||
|
|
||||||
|
use App\Models\CompetitionGroup;
|
||||||
|
use App\Models\StatistikoEvent;
|
||||||
|
|
||||||
|
class LoadEventsAverages
|
||||||
|
{
|
||||||
|
public static function load(array &$data, array $filter,array $labels, array $events)
|
||||||
|
{
|
||||||
|
$league_id = (int) $filter['league_id'] ?? 0;
|
||||||
|
|
||||||
|
$team_position = $filter['team_position'];
|
||||||
|
|
||||||
|
$team_id = (int) $filter['team_id'] ?? 0;
|
||||||
|
|
||||||
|
$statistic_type = $filter['statistic_type'] ?? 'gls';
|
||||||
|
|
||||||
|
|
||||||
|
$res = CompetitionGroup::with('country')->where('id', $league_id)->first();
|
||||||
|
$season_mode = $res->country->season_mode;
|
||||||
|
if ($season_mode == 'fullyear') {
|
||||||
|
$season = date('Y');
|
||||||
|
} else {
|
||||||
|
$season = date('y') - 1 . '/' . date('Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = StatistikoEvent::where('league_id', $league_id)
|
||||||
|
->where('season', $season)
|
||||||
|
->orderBy('starttime', 'ASC')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if ($res) {
|
||||||
|
|
||||||
|
$team_home = [];
|
||||||
|
$team_away = [];
|
||||||
|
$league_home = [];
|
||||||
|
$league_away = [];
|
||||||
|
|
||||||
|
// 1) la media dei falli di tutte le partite giocate dal Flamengo
|
||||||
|
// (esempio, giocate 6 partite con falli 17-11-15-14-15-12, la media è 14)
|
||||||
|
|
||||||
|
// 2) la media dei falli di tutte le partite giocate nel campionato Brasiliano
|
||||||
|
// (esempio 6 giornate giocate = 60 partite quindi 120 squadre, quindi 120 dati tipo 17-12-12-15-8-15-13-21-...,
|
||||||
|
// quindi la media di questi 120 dati)
|
||||||
|
|
||||||
|
foreach ($res as $value) {
|
||||||
|
|
||||||
|
switch ($statistic_type) {
|
||||||
|
case 'gls':
|
||||||
|
$league_home[] = (int) $value['gls_h'];
|
||||||
|
$league_away[] = (int) $value['gls_a'];
|
||||||
|
break;
|
||||||
|
case 'crn':
|
||||||
|
$league_home[] = (int) $value['crn_h'];
|
||||||
|
$league_away[] = (int) $value['crn_a'];
|
||||||
|
break;
|
||||||
|
case 'fls':
|
||||||
|
$league_home[] = (int) $value['fls_h'];
|
||||||
|
$league_away[] = (int) $value['fls_a'];
|
||||||
|
break;
|
||||||
|
case 'ofs':
|
||||||
|
$league_home[] = (int) $value['ofs_h'];
|
||||||
|
$league_away[] = (int) $value['ofs_a'];
|
||||||
|
break;
|
||||||
|
case 'crd':
|
||||||
|
$league_home[] = (int) $value['crd_h'];
|
||||||
|
$league_away[] = (int) $value['crd_a'];
|
||||||
|
break;
|
||||||
|
case 'snt':
|
||||||
|
$league_home[] = (int) $value['snt_h'];
|
||||||
|
$league_away[] = (int) $value['snt_a'];
|
||||||
|
break;
|
||||||
|
case 'tsh':
|
||||||
|
$league_home[] = (int) $value['tsh_h'];
|
||||||
|
$league_away[] = (int) $value['tsh_a'];
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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'];
|
||||||
|
break;
|
||||||
|
case 'crn':
|
||||||
|
$team_home[] = (int) $value['crn_h'];
|
||||||
|
$team_away[] =(int) $value['crn_a'];
|
||||||
|
break;
|
||||||
|
case 'fls':
|
||||||
|
$team_home[] = (int) $value['fls_h'];
|
||||||
|
$team_away[] =(int) $value['fls_a'];
|
||||||
|
break;
|
||||||
|
case 'ofs':
|
||||||
|
$team_home[] = (int) $value['ofs_h'];
|
||||||
|
$team_away[] =(int) $value['ofs_a'];
|
||||||
|
break;
|
||||||
|
case 'crd':
|
||||||
|
$team_home[] = (int) $value['crd_h'];
|
||||||
|
$team_away[] =(int) $value['crd_a'];
|
||||||
|
break;
|
||||||
|
case 'snt':
|
||||||
|
$team_home[] = (int) $value['snt_h'];
|
||||||
|
$team_away[] =(int) $value['snt_a'];
|
||||||
|
break;
|
||||||
|
case 'tsh':
|
||||||
|
$team_home[] = (int) $value['tsh_h'];
|
||||||
|
$team_away[] =(int) $value['tsh_a'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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'];
|
||||||
|
break;
|
||||||
|
case 'crn':
|
||||||
|
$team_home[] = (int) $value['crn_a'];
|
||||||
|
$team_away[] =(int) $value['crn_h'];
|
||||||
|
break;
|
||||||
|
case 'fls':
|
||||||
|
$team_home[] = (int) $value['fls_a'];
|
||||||
|
$team_away[] =(int) $value['fls_h'];
|
||||||
|
break;
|
||||||
|
case 'ofs':
|
||||||
|
$team_home[] = (int) $value['ofs_a'];
|
||||||
|
$team_away[] =(int) $value['ofs_h'];
|
||||||
|
break;
|
||||||
|
case 'crd':
|
||||||
|
$team_home[] = (int) $value['crd_a'];
|
||||||
|
$team_away[] =(int) $value['crd_h'];
|
||||||
|
break;
|
||||||
|
case 'snt':
|
||||||
|
$team_home[] = (int) $value['snt_a'];
|
||||||
|
$team_away[] =(int) $value['snt_h'];
|
||||||
|
break;
|
||||||
|
case 'tsh':
|
||||||
|
$team_home[] = (int) $value['tsh_a'];
|
||||||
|
$team_away[] =(int) $value['tsh_h'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$average_team = 0;
|
||||||
|
$average_team_home = 0;
|
||||||
|
$average_team_away = 0;
|
||||||
|
$average_league = 0;
|
||||||
|
$average_league_home = 0;
|
||||||
|
$average_league_away = 0;
|
||||||
|
|
||||||
|
if ($team_id && $team_home){
|
||||||
|
|
||||||
|
$sum = array_sum($team_home) + array_sum($team_away);
|
||||||
|
|
||||||
|
$count = count($team_home) + count($team_away);
|
||||||
|
|
||||||
|
$average_team = round($sum / $count, 1);
|
||||||
|
|
||||||
|
$average_team_home = round(array_sum($team_home) / count($team_home), 1);
|
||||||
|
|
||||||
|
$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_away = $league_away ? round(array_sum($league_away) / \count($league_away), 1):0;
|
||||||
|
|
||||||
|
$media_league = array_merge($league_away, $league_home);
|
||||||
|
|
||||||
|
$average_league = $media_league ? round(array_sum($media_league) / \count($media_league), 1) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data_team = array_fill(0, count($labels), $average_team);
|
||||||
|
$data_league = array_fill(0, count($labels), $average_league);
|
||||||
|
|
||||||
|
$data['datasets'][] = [
|
||||||
|
'label' => 'Average Team',
|
||||||
|
'events' => $events,
|
||||||
|
'data' => $data_team,
|
||||||
|
'tension' => 0.5,
|
||||||
|
'borderColor' => '#ad46ff',
|
||||||
|
'backgroundColor' => '#ad46ff',
|
||||||
|
'borderDash' => [5, 5],
|
||||||
|
'pointStyle' => false,
|
||||||
|
'hidden' => false,
|
||||||
|
'average_team_home' => $average_team_home,
|
||||||
|
'average_team_away' => $average_team_away,
|
||||||
|
];
|
||||||
|
$data['datasets'][] = [
|
||||||
|
'label' => 'Average League',
|
||||||
|
'events' => $events,
|
||||||
|
'data' => $data_league,
|
||||||
|
'tension' => 0.5,
|
||||||
|
'borderColor' => '#00bba7',
|
||||||
|
'backgroundColor' => '#00bba7',
|
||||||
|
'borderDash' => [5, 5],
|
||||||
|
'pointStyle' => false,
|
||||||
|
'hidden' => false,
|
||||||
|
'average_league_home' => $average_league_home,
|
||||||
|
'average_league_away' => $average_league_away,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -88,31 +88,49 @@ class StatsMedianAverage extends StatsOverviewWidget
|
|||||||
$value_away = 0;
|
$value_away = 0;
|
||||||
|
|
||||||
$max_boxes = 3;
|
$max_boxes = 3;
|
||||||
$average_team_h = 0;
|
$average_team_home = 0;
|
||||||
$average_team_a = 0;
|
$average_team_away = 0;
|
||||||
$average_league_h = 0;
|
$average_league_home = 0;
|
||||||
$average_league_a = 0;
|
$average_league_away = 0;
|
||||||
|
|
||||||
foreach ($data['datasets'] as $value) {
|
foreach ($data['datasets'] as $value) {
|
||||||
if ($value['label'] == "Average Team") {
|
if ($value['label'] == "Average Team") {
|
||||||
$average_team_h = $value['average_team_h'] ?? 0;
|
$average_team_home = $value['average_team_home'] ?? 0;
|
||||||
$average_team_a = $value['average_team_a'] ?? 0;
|
$average_team_away = $value['average_team_away'] ?? 0;
|
||||||
$max_boxes++;
|
$max_boxes++;
|
||||||
}
|
}
|
||||||
if ($value['label'] == "Average League") {
|
if ($value['label'] == "Average League") {
|
||||||
$average_league_h = $value['average_league_h'] ?? 0;
|
$average_league_home = $value['average_league_home'] ?? 0;
|
||||||
$average_league_a = $value['average_league_a'] ?? 0;
|
$average_league_away = $value['average_league_away'] ?? 0;
|
||||||
$max_boxes++;
|
$max_boxes++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$boxes = [];
|
$boxes = [];
|
||||||
$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)"]);
|
# BOX 1
|
||||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template('avhome', 'avaway', $home_team, $away_team))->description('Team ' . $team_position)->extraAttributes(['x-init' => "animate('avhome', $value_home); animate('avaway', $value_away)"]);
|
$boxes[] = Stat::make('Number', new HtmlString('<div id="number-of-events">' . $total_home . '</div>'))
|
||||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template('av_team_home', 'av_team_away', 'Home', 'Away', $average_team_h, $average_team_a))->description('Team Season')->extraAttributes(['x-init' => "animate('av_team_home', $average_team_h); animate('av_team_away', $average_team_a)"]);
|
->description('Events')
|
||||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template('av_league_home', 'av_league_away', 'Home', 'Away', $average_league_h, $average_league_a))->description('League Season')->extraAttributes(['x-init' => "animate('av_league_home', $average_league_h); animate('av_league_away', $average_league_a)"]);
|
->extraAttributes(['x-init' => "animate('number-of-events', $total_home, 0)"]);
|
||||||
// $boxes[] = Stat::make('Median ' . $statistic_type, self::template('mehome', 'meaway', $home_team, $away_team, $median_home, $median_away))->description($team_position)->extraAttributes(['x-init' => "animate('mehome', $median_home); animate('meaway', $median_away, 0)"]);
|
|
||||||
$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)"]);
|
# BOX 2
|
||||||
|
$boxes[] = Stat::make('Average ' . $statistic_type, self::template('avhome', 'avaway', $home_team, $away_team))
|
||||||
|
->description('Team ' . $team_position)
|
||||||
|
->extraAttributes(['x-init' => "animate('avhome', $value_home); animate('avaway', $value_away)"]);
|
||||||
|
|
||||||
|
# BOX 3
|
||||||
|
$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)"]);
|
||||||
|
|
||||||
|
# BOX 4
|
||||||
|
$boxes[] = Stat::make('Average ' . $statistic_type, self::template('av_league_home', 'av_league_away', 'Home', 'Away', $average_league_home, $average_league_away))
|
||||||
|
->description('League Season')
|
||||||
|
->extraAttributes(['x-init' => "animate('av_league_home', $average_league_home); animate('av_league_away', $average_league_away)"]);
|
||||||
|
|
||||||
|
# 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)"]);
|
||||||
|
|
||||||
$this->columns = [
|
$this->columns = [
|
||||||
'default' => 1,
|
'default' => 1,
|
||||||
|
|||||||
Reference in new issue
Block a user