wip
This commit is contained in:
1 parent
332bdc9985
commit
3627a78989
2 files changed
+47
-45
No files matched your search
@@ -7,7 +7,7 @@ use App\Models\StatistikoEvent;
|
|||||||
|
|
||||||
class LoadEventsAverages
|
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;
|
$league_id = (int) $filter['league_id'] ?? 0;
|
||||||
|
|
||||||
@@ -46,7 +46,6 @@ class LoadEventsAverages
|
|||||||
// quindi la media di questi 120 dati)
|
// quindi la media di questi 120 dati)
|
||||||
|
|
||||||
foreach ($res as $value) {
|
foreach ($res as $value) {
|
||||||
|
|
||||||
switch ($statistic_type) {
|
switch ($statistic_type) {
|
||||||
case 'gls':
|
case 'gls':
|
||||||
$league_home[] = (int) $value['gls_h'];
|
$league_home[] = (int) $value['gls_h'];
|
||||||
@@ -78,135 +77,134 @@ class LoadEventsAverages
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($team_position == 'all' && ($team_id == $value['home_id'] or $team_id == $value['away_id'])) {
|
// dd($team_position, $team_id, $value);
|
||||||
|
|
||||||
|
if ((!$team_position || $team_position == 'all') && ($team_id == $value['home_id'] or $team_id == $value['away_id'])) {
|
||||||
switch ($statistic_type) {
|
switch ($statistic_type) {
|
||||||
case 'gls':
|
case 'gls':
|
||||||
if ($team_id == $value['home_id']) {
|
if ($team_id == $value['home_id']) {
|
||||||
$team_home[] = (int) $value['gls_h'];
|
$team_home[] = (int) $value['gls_h'];
|
||||||
$team_away[] =(int) $value['gls_a'];
|
$team_away[] = (int) $value['gls_a'];
|
||||||
} else {
|
} else {
|
||||||
$team_home[] = (int) $value['gls_a'];
|
$team_home[] = (int) $value['gls_a'];
|
||||||
$team_away[] =(int) $value['gls_h'];
|
$team_away[] = (int) $value['gls_h'];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'crn':
|
case 'crn':
|
||||||
if ($team_id == $value['home_id']) {
|
if ($team_id == $value['home_id']) {
|
||||||
$team_home[] = (int) $value['crn_h'];
|
$team_home[] = (int) $value['crn_h'];
|
||||||
$team_away[] =(int) $value['crn_a'];
|
$team_away[] = (int) $value['crn_a'];
|
||||||
} else {
|
} else {
|
||||||
$team_home[] = (int) $value['crn_a'];
|
$team_home[] = (int) $value['crn_a'];
|
||||||
$team_away[] =(int) $value['crn_h'];
|
$team_away[] = (int) $value['crn_h'];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'fls':
|
case 'fls':
|
||||||
if ($team_id == $value['home_id']) {
|
if ($team_id == $value['home_id']) {
|
||||||
$team_home[] = (int) $value['fls_h'];
|
$team_home[] = (int) $value['fls_h'];
|
||||||
$team_away[] =(int) $value['fls_a'];
|
$team_away[] = (int) $value['fls_a'];
|
||||||
} else {
|
} else {
|
||||||
$team_home[] = (int) $value['fls_a'];
|
$team_home[] = (int) $value['fls_a'];
|
||||||
$team_away[] =(int) $value['fls_h'];
|
$team_away[] = (int) $value['fls_h'];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'ofs':
|
case 'ofs':
|
||||||
if ($team_id == $value['home_id']) {
|
if ($team_id == $value['home_id']) {
|
||||||
$team_home[] = (int) $value['ofs_h'];
|
$team_home[] = (int) $value['ofs_h'];
|
||||||
$team_away[] =(int) $value['ofs_a'];
|
$team_away[] = (int) $value['ofs_a'];
|
||||||
} else {
|
} else {
|
||||||
$team_home[] = (int) $value['ofs_a'];
|
$team_home[] = (int) $value['ofs_a'];
|
||||||
$team_away[] =(int) $value['ofs_h'];
|
$team_away[] = (int) $value['ofs_h'];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'crd':
|
case 'crd':
|
||||||
if ($team_id == $value['home_id']) {
|
if ($team_id == $value['home_id']) {
|
||||||
$team_home[] = (int) $value['crd_h'];
|
$team_home[] = (int) $value['crd_h'];
|
||||||
$team_away[] =(int) $value['crd_a'];
|
$team_away[] = (int) $value['crd_a'];
|
||||||
} else {
|
} else {
|
||||||
$team_home[] = (int) $value['crd_a'];
|
$team_home[] = (int) $value['crd_a'];
|
||||||
$team_away[] =(int) $value['crd_h'];
|
$team_away[] = (int) $value['crd_h'];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'snt':
|
case 'snt':
|
||||||
if ($team_id == $value['home_id']) {
|
if ($team_id == $value['home_id']) {
|
||||||
$team_home[] = (int) $value['snt_h'];
|
$team_home[] = (int) $value['snt_h'];
|
||||||
$team_away[] =(int) $value['snt_a'];
|
$team_away[] = (int) $value['snt_a'];
|
||||||
} else {
|
} else {
|
||||||
$team_home[] = (int) $value['snt_a'];
|
$team_home[] = (int) $value['snt_a'];
|
||||||
$team_away[] =(int) $value['snt_h'];
|
$team_away[] = (int) $value['snt_h'];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'tsh':
|
case 'tsh':
|
||||||
if ($team_id == $value['home_id']) {
|
if ($team_id == $value['home_id']) {
|
||||||
$team_home[] = (int) $value['tsh_h'];
|
$team_home[] = (int) $value['tsh_h'];
|
||||||
$team_away[] =(int) $value['tsh_a'];
|
$team_away[] = (int) $value['tsh_a'];
|
||||||
} else {
|
} else {
|
||||||
$team_home[] = (int) $value['tsh_a'];
|
$team_home[] = (int) $value['tsh_a'];
|
||||||
$team_away[] =(int) $value['tsh_h'];
|
$team_away[] = (int) $value['tsh_h'];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if ($team_position == 'home' && $team_id == $value['home_id']) {
|
||||||
|
|
||||||
else if ($team_position == 'home' && $team_id == $value['home_id']) {
|
|
||||||
switch ($statistic_type) {
|
switch ($statistic_type) {
|
||||||
case 'gls':
|
case 'gls':
|
||||||
$team_home[] = (int) $value['gls_h'];
|
$team_home[] = (int) $value['gls_h'];
|
||||||
$team_away[] =(int) $value['gls_a'];
|
$team_away[] = (int) $value['gls_a'];
|
||||||
break;
|
break;
|
||||||
case 'crn':
|
case 'crn':
|
||||||
$team_home[] = (int) $value['crn_h'];
|
$team_home[] = (int) $value['crn_h'];
|
||||||
$team_away[] =(int) $value['crn_a'];
|
$team_away[] = (int) $value['crn_a'];
|
||||||
break;
|
break;
|
||||||
case 'fls':
|
case 'fls':
|
||||||
$team_home[] = (int) $value['fls_h'];
|
$team_home[] = (int) $value['fls_h'];
|
||||||
$team_away[] =(int) $value['fls_a'];
|
$team_away[] = (int) $value['fls_a'];
|
||||||
break;
|
break;
|
||||||
case 'ofs':
|
case 'ofs':
|
||||||
$team_home[] = (int) $value['ofs_h'];
|
$team_home[] = (int) $value['ofs_h'];
|
||||||
$team_away[] =(int) $value['ofs_a'];
|
$team_away[] = (int) $value['ofs_a'];
|
||||||
break;
|
break;
|
||||||
case 'crd':
|
case 'crd':
|
||||||
$team_home[] = (int) $value['crd_h'];
|
$team_home[] = (int) $value['crd_h'];
|
||||||
$team_away[] =(int) $value['crd_a'];
|
$team_away[] = (int) $value['crd_a'];
|
||||||
break;
|
break;
|
||||||
case 'snt':
|
case 'snt':
|
||||||
$team_home[] = (int) $value['snt_h'];
|
$team_home[] = (int) $value['snt_h'];
|
||||||
$team_away[] =(int) $value['snt_a'];
|
$team_away[] = (int) $value['snt_a'];
|
||||||
break;
|
break;
|
||||||
case 'tsh':
|
case 'tsh':
|
||||||
$team_home[] = (int) $value['tsh_h'];
|
$team_home[] = (int) $value['tsh_h'];
|
||||||
$team_away[] =(int) $value['tsh_a'];
|
$team_away[] = (int) $value['tsh_a'];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if ($team_position == 'away' && $team_id == $value['away_id']) {
|
||||||
else if ($team_position == 'away' && $team_id == $value['away_id']) {
|
|
||||||
switch ($statistic_type) {
|
switch ($statistic_type) {
|
||||||
case 'gls':
|
case 'gls':
|
||||||
$team_home[] = (int) $value['gls_a'];
|
$team_home[] = (int) $value['gls_a'];
|
||||||
$team_away[] =(int) $value['gls_h'];
|
$team_away[] = (int) $value['gls_h'];
|
||||||
break;
|
break;
|
||||||
case 'crn':
|
case 'crn':
|
||||||
$team_home[] = (int) $value['crn_a'];
|
$team_home[] = (int) $value['crn_a'];
|
||||||
$team_away[] =(int) $value['crn_h'];
|
$team_away[] = (int) $value['crn_h'];
|
||||||
break;
|
break;
|
||||||
case 'fls':
|
case 'fls':
|
||||||
$team_home[] = (int) $value['fls_a'];
|
$team_home[] = (int) $value['fls_a'];
|
||||||
$team_away[] =(int) $value['fls_h'];
|
$team_away[] = (int) $value['fls_h'];
|
||||||
break;
|
break;
|
||||||
case 'ofs':
|
case 'ofs':
|
||||||
$team_home[] = (int) $value['ofs_a'];
|
$team_home[] = (int) $value['ofs_a'];
|
||||||
$team_away[] =(int) $value['ofs_h'];
|
$team_away[] = (int) $value['ofs_h'];
|
||||||
break;
|
break;
|
||||||
case 'crd':
|
case 'crd':
|
||||||
$team_home[] = (int) $value['crd_a'];
|
$team_home[] = (int) $value['crd_a'];
|
||||||
$team_away[] =(int) $value['crd_h'];
|
$team_away[] = (int) $value['crd_h'];
|
||||||
break;
|
break;
|
||||||
case 'snt':
|
case 'snt':
|
||||||
$team_home[] = (int) $value['snt_a'];
|
$team_home[] = (int) $value['snt_a'];
|
||||||
$team_away[] =(int) $value['snt_h'];
|
$team_away[] = (int) $value['snt_h'];
|
||||||
break;
|
break;
|
||||||
case 'tsh':
|
case 'tsh':
|
||||||
$team_home[] = (int) $value['tsh_a'];
|
$team_home[] = (int) $value['tsh_a'];
|
||||||
$team_away[] =(int) $value['tsh_h'];
|
$team_away[] = (int) $value['tsh_h'];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,7 +217,9 @@ class LoadEventsAverages
|
|||||||
$average_league_home = 0;
|
$average_league_home = 0;
|
||||||
$average_league_away = 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);
|
$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_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);
|
$media_league = array_merge($league_away, $league_home);
|
||||||
|
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ class StatsMedianAverage extends StatsOverviewWidget
|
|||||||
$average_league_home = 0;
|
$average_league_home = 0;
|
||||||
$average_league_away = 0;
|
$average_league_away = 0;
|
||||||
|
|
||||||
|
// Log::debug($data);
|
||||||
|
|
||||||
foreach ($data['datasets'] as $value) {
|
foreach ($data['datasets'] as $value) {
|
||||||
if ($value['label'] == 'Average Team') {
|
if ($value['label'] == 'Average Team') {
|
||||||
$average_team_home = $value['average_team_home'] ?? 0;
|
$average_team_home = $value['average_team_home'] ?? 0;
|
||||||
@@ -121,16 +123,16 @@ class StatsMedianAverage extends StatsOverviewWidget
|
|||||||
$boxes = [];
|
$boxes = [];
|
||||||
// BOX 1
|
// BOX 1
|
||||||
$boxes[] = Stat::make('Number', new HtmlString('<div id="number-of-events">' . $total_home . '</div>'))
|
$boxes[] = Stat::make('Number', new HtmlString('<div id="number-of-events">' . $total_home . '</div>'))
|
||||||
->description('Events')
|
->description('Events');
|
||||||
->extraAttributes(['x-init' => "animate('number-of-events', $total_home, 0)"]);
|
// ->extraAttributes(['x-init' => "animate('number-of-events', $total_home, 0)"]);
|
||||||
|
|
||||||
// BOX 2
|
// 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))
|
$boxes[] = Stat::make('Average ' . $statistic_type, self::template('avhome', 'avaway', $home_team, $away_team, $value_home, $value_away))
|
||||||
->description('Team ' . $team_position);
|
->description('Team ' . $team_position);
|
||||||
// ->extraAttributes(['x-init' => "animate('avhome', $value_home); animate('avaway', $value_away)"]);
|
// ->extraAttributes(['x-init' => "animate('avhome', $value_home); animate('avaway', $value_away)"]);
|
||||||
|
|
||||||
// BOX 3
|
// 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))
|
$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');
|
->description('Team Season');
|
||||||
// ->extraAttributes(['x-init' => "animate('av_team_home', $average_team_home); animate('av_team_away', $average_team_away)"]);
|
// ->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
|
// BOX 5
|
||||||
$boxes[] = Stat::make('Odds', self::templateOdds($data, $win, $draw, $lost))
|
$boxes[] = Stat::make('Odds', self::templateOdds($data, $win, $draw, $lost))
|
||||||
->description($team_position)
|
->description($team_position);
|
||||||
->extraAttributes(['x-init' => "animate('mehome', $median_home); animate('meaway', $median_away, 0)"]);
|
// ->extraAttributes(['x-init' => "animate('mehome', $median_home); animate('meaway', $median_away, 0)"]);
|
||||||
|
|
||||||
$this->columns = [
|
$this->columns = [
|
||||||
'default' => 1,
|
'default' => 1,
|
||||||
'sm' => 2,
|
'sm' => 2,
|
||||||
'md' => 3,
|
'md' => 3,
|
||||||
'lg' => 4,
|
'lg' => 4,
|
||||||
'xl' => $max_boxes,
|
'xl' => 5,
|
||||||
];
|
];
|
||||||
|
|
||||||
return $boxes;
|
return $boxes;
|
||||||
|
|||||||
Reference in new issue
Block a user