fix box 1
This commit is contained in:
1 parent
4ec3a86c9e
commit
c49f5e2364
7 files changed
+230
-194
No files matched your search
@@ -52,7 +52,6 @@ class LoadEvents
|
||||
|
||||
$team_position = '';
|
||||
|
||||
|
||||
$exp_handicap = $match->exp_away - $match->exp_home;
|
||||
|
||||
$exp_total = $match->exp_away + $match->exp_home;
|
||||
@@ -71,9 +70,10 @@ class LoadEvents
|
||||
/**
|
||||
* STATTISTIC DATA
|
||||
*/
|
||||
|
||||
$res = LoadEventsQuery::load($filter, $handicap_range, $total_range, $match);
|
||||
|
||||
// dd($res);
|
||||
|
||||
$dataset_home = [];
|
||||
$dataset_away = [];
|
||||
$dataset_exp_home = [];
|
||||
@@ -84,11 +84,11 @@ class LoadEvents
|
||||
$events = [];
|
||||
$results = ['w' => 0, 'd' => 0, 'l' => 0, 'w2' => 0, 'l2' => 0];
|
||||
|
||||
if (!$team_id || !\in_array($team_position, ['home', 'away'])) {
|
||||
if (! $team_id || ! \in_array($team_position, ['home', 'away'])) {
|
||||
$team_position = 'all';
|
||||
}
|
||||
|
||||
if (!isset($res['all']) || !isset($res[$team_position])) {
|
||||
if (! isset($res['all']) || ! isset($res[$team_position])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -102,7 +102,10 @@ class LoadEvents
|
||||
|
||||
$playing_date[] = $value['starttime']->format('Y-m-d H:i');
|
||||
|
||||
$results_per_event[] = $value['val_home'] . ' : ' . $value['val_away'];
|
||||
$results_per_event[] = $value['val_home'].' : '.$value['val_away'];
|
||||
|
||||
$val_home = (int) $value['val_home'];
|
||||
$val_away = (int) $value['val_away'];
|
||||
|
||||
if ($similar_past_matches != 'none') {
|
||||
switch ($value['result_code']) {
|
||||
@@ -119,12 +122,9 @@ class LoadEvents
|
||||
break;
|
||||
}
|
||||
|
||||
$val_home = (int) $value['val_home'];
|
||||
$val_away = (int) $value['val_away'];
|
||||
|
||||
if ($statistic_type == 'gls') {
|
||||
$dataset_exp_home[] = (float) round($value['exp_home'], 1);
|
||||
$dataset_exp_away[] = (float) round($value['exp_away'], 1);
|
||||
$dataset_exp_home[] = (float) round($value['exp_home'], 1);
|
||||
$dataset_exp_away[] = (float) round($value['exp_away'], 1);
|
||||
}
|
||||
} else {
|
||||
if ($team_position == 'home') {
|
||||
@@ -142,12 +142,9 @@ class LoadEvents
|
||||
break;
|
||||
}
|
||||
|
||||
$val_home = (int) $value['val_home'];
|
||||
$val_away = (int) $value['val_away'];
|
||||
|
||||
if ($statistic_type == 'gls') {
|
||||
$dataset_exp_home[] = (float) round($value['exp_home'], 1);
|
||||
$dataset_exp_away[] = (float) round($value['exp_away'], 1);
|
||||
$dataset_exp_home[] = (float) round($value['exp_home'], 1);
|
||||
$dataset_exp_away[] = (float) round($value['exp_away'], 1);
|
||||
}
|
||||
} elseif ($team_position == 'away') {
|
||||
|
||||
@@ -165,12 +162,9 @@ class LoadEvents
|
||||
break;
|
||||
}
|
||||
|
||||
$val_home = (int) $value['val_away'];
|
||||
$val_away = (int) $value['val_home'];
|
||||
|
||||
if ($statistic_type == 'gls') {
|
||||
$dataset_exp_home[] = (float) round($value['exp_away'], 1);
|
||||
$dataset_exp_away[] = (float) round($value['exp_home'], 1);
|
||||
$dataset_exp_home[] = (float) round($value['exp_away'], 1);
|
||||
$dataset_exp_away[] = (float) round($value['exp_home'], 1);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -200,17 +194,14 @@ class LoadEvents
|
||||
break;
|
||||
}
|
||||
|
||||
$val_home = (int) $value['val_away'];
|
||||
$val_away = (int) $value['val_home'];
|
||||
|
||||
if ($statistic_type == 'gls') {
|
||||
$dataset_exp_home[] = (float) round($value['exp_away'], 1);
|
||||
$dataset_exp_away[] = (float) round($value['exp_home'], 1);
|
||||
$dataset_exp_home[] = (float) round($value['exp_away'], 1);
|
||||
$dataset_exp_away[] = (float) round($value['exp_home'], 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($val_home) && isset($val_away)) {
|
||||
$events[] = $value['home'] . ' vs ' . $value['away'];
|
||||
$events[] = $value['home'].' vs '.$value['away'];
|
||||
$dataset_home[] = $val_home;
|
||||
$dataset_away[] = $val_away;
|
||||
}
|
||||
@@ -224,10 +215,10 @@ class LoadEvents
|
||||
$label2 = 'Against';
|
||||
}
|
||||
} else {
|
||||
$label1 = $match->home->ss_team_name . ' +';
|
||||
$label2 = $match->home->ss_team_name . ' -';
|
||||
$label3 = $match->away->ss_team_name . ' +';
|
||||
$label4 = $match->away->ss_team_name . ' -';
|
||||
$label1 = $match->home->ss_team_name.' +';
|
||||
$label2 = $match->home->ss_team_name.' -';
|
||||
$label3 = $match->away->ss_team_name.' +';
|
||||
$label4 = $match->away->ss_team_name.' -';
|
||||
$dataset_home2 = [];
|
||||
$dataset_away2 = [];
|
||||
|
||||
@@ -239,15 +230,15 @@ class LoadEvents
|
||||
if ($match->home_id == $value['home_id']) {
|
||||
$dataset_home[] = (int) $value['val_home'];
|
||||
$dataset_away[] = (int) $value['val_away'];
|
||||
} else if ($match->home_id == $value['away_id']) {
|
||||
} elseif ($match->home_id == $value['away_id']) {
|
||||
$dataset_home[] = (int) $value['val_away'];
|
||||
$dataset_away[] = (int) $value['val_home'];
|
||||
}
|
||||
// Home playing AWAY done and commited
|
||||
else if ($match->away_id == $value['home_id']) {
|
||||
elseif ($match->away_id == $value['home_id']) {
|
||||
$dataset_home2[] = (int) $value['val_home'];
|
||||
$dataset_away2[] = (int) $value['val_away'];
|
||||
} else if ($match->away_id == $value['away_id']) {
|
||||
} elseif ($match->away_id == $value['away_id']) {
|
||||
$dataset_home2[] = (int) $value['val_away'];
|
||||
$dataset_away2[] = (int) $value['val_home'];
|
||||
}
|
||||
@@ -263,7 +254,6 @@ class LoadEvents
|
||||
|
||||
// dd($events, count($dataset_home), count($dataset_away), count($dataset_home2), count($dataset_away2));
|
||||
|
||||
|
||||
self::shortenEnding($labels, $dataset_home, $dataset_away);
|
||||
|
||||
$data = [
|
||||
@@ -309,7 +299,7 @@ class LoadEvents
|
||||
];
|
||||
if ($team_id && $statistic_type == 'gls') {
|
||||
$data['datasets'][] = [
|
||||
'label' => 'Goals ' . $label1,
|
||||
'label' => 'Goals '.$label1,
|
||||
'events' => $events,
|
||||
'playing_date' => $playing_date,
|
||||
'results_per_event' => $results_per_event,
|
||||
@@ -321,7 +311,7 @@ class LoadEvents
|
||||
'hidden' => true,
|
||||
];
|
||||
$data['datasets'][] = [
|
||||
'label' => 'Goals ' . $label2,
|
||||
'label' => 'Goals '.$label2,
|
||||
'events' => $events,
|
||||
'playing_date' => $playing_date,
|
||||
'results_per_event' => $results_per_event,
|
||||
@@ -363,7 +353,6 @@ class LoadEvents
|
||||
|
||||
// dd($data);
|
||||
|
||||
|
||||
/**
|
||||
* LEAGUE AVERAGES
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@ use App\Models\StatistikoPlayer;
|
||||
|
||||
class LoadEventsQuery
|
||||
{
|
||||
public static function load(array $filter, array $handicap_range, array $total_range, object $match)
|
||||
public static function load(array $filter, array $handicap_range, array $total_range, object $match)
|
||||
{
|
||||
$league_id = (int) $filter['league_id'] ?? 0;
|
||||
$team_id = (int) $filter['team_id'] ?? 0;
|
||||
@@ -84,8 +84,6 @@ class LoadEventsQuery
|
||||
/**
|
||||
* STATTISTIC DATA
|
||||
*/
|
||||
|
||||
|
||||
// dd($team_id, $home_id, $away_id);
|
||||
$res = StatistikoEvent::with('home')->with('away')
|
||||
->where(function ($query) use ($league_id, $similar_past_matches) {
|
||||
@@ -122,13 +120,14 @@ class LoadEventsQuery
|
||||
return $query->whereDate('starttime', '<=', $end);
|
||||
})
|
||||
->when($season, function ($query) use ($season, $season_or_date) {
|
||||
if ($season_or_date == 'season')
|
||||
if ($season_or_date == 'season') {
|
||||
return $query->whereIn('season', $season);
|
||||
}
|
||||
})
|
||||
->orderBy('starttime', 'ASC')
|
||||
->get();
|
||||
|
||||
// dd($season, $res);
|
||||
// dd($season, $team_id, $home_id, $away_id, $res);
|
||||
|
||||
$arr = [];
|
||||
foreach ($res as $value) {
|
||||
@@ -181,10 +180,12 @@ class LoadEventsQuery
|
||||
}
|
||||
|
||||
$arr['all'][] = $tmp;
|
||||
if ($value->home_id == $team_id)
|
||||
if ($value->home_id == $team_id) {
|
||||
$arr['home'][] = $tmp;
|
||||
if ($value->away_id == $team_id)
|
||||
}
|
||||
if ($value->away_id == $team_id) {
|
||||
$arr['away'][] = $tmp;
|
||||
}
|
||||
}
|
||||
|
||||
return $arr;
|
||||
|
||||
@@ -11,102 +11,141 @@ class LoadExpectations
|
||||
$home_id = $match->home_id;
|
||||
$away_id = $match->away_id;
|
||||
|
||||
// dd($data, $match);
|
||||
|
||||
$config = StatistikoConfig::where('group', $statistic_type)->get();
|
||||
|
||||
$home_made_total = 1;
|
||||
$home_made_home = 1;
|
||||
$home_got_total = 1;
|
||||
$home_got_home = 1;
|
||||
$away_made_total = 1;
|
||||
$away_made_home = 1;
|
||||
$away_got_total = 1;
|
||||
$away_got_home = 1;
|
||||
$uba_home_made_total = 1;
|
||||
$uba_home_made_home = 1;
|
||||
$uba_home_got_total = 1;
|
||||
$uba_home_got_home = 1;
|
||||
$uba_away_made_total = 1;
|
||||
$uba_away_made_home = 1;
|
||||
$uba_away_got_total = 1;
|
||||
$uba_away_got_home = 1;
|
||||
|
||||
foreach ($config as $value) {
|
||||
$varname = str_replace($statistic_type . '_', '', $value->varname);
|
||||
$varname = str_replace($statistic_type.'_', '', $value->varname);
|
||||
switch ($varname) {
|
||||
case 'home_made_total':
|
||||
$home_made_total = (float) $value->value;
|
||||
$uba_home_made_total = (float) $value->value;
|
||||
break;
|
||||
case 'home_made_home':
|
||||
$home_made_home = (float) $value->value;
|
||||
$uba_home_made_home = (float) $value->value;
|
||||
break;
|
||||
case 'home_got_total':
|
||||
$home_got_total = (float) $value->value;
|
||||
$uba_home_got_total = (float) $value->value;
|
||||
break;
|
||||
case 'home_got_home':
|
||||
$home_got_home = (float) $value->value;
|
||||
$uba_home_got_home = (float) $value->value;
|
||||
break;
|
||||
case 'away_made_total':
|
||||
$away_made_total = (float) $value->value;
|
||||
$uba_away_made_total = (float) $value->value;
|
||||
break;
|
||||
case 'away_made_home':
|
||||
$away_made_home = (float) $value->value;
|
||||
$uba_away_made_home = (float) $value->value;
|
||||
break;
|
||||
case 'away_got_total':
|
||||
$away_got_total = (float) $value->value;
|
||||
$uba_away_got_total = (float) $value->value;
|
||||
break;
|
||||
case 'away_got_home':
|
||||
$away_got_home = (float) $value->value;
|
||||
$uba_away_got_home = (float) $value->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$h_made_t = [];
|
||||
$h_made_h = [];
|
||||
$h_got_t = [];
|
||||
$h_got_h = [];
|
||||
$home_made_total = [];
|
||||
$home_made_home = [];
|
||||
$home_got_total = [];
|
||||
$home_got_home = [];
|
||||
|
||||
$a_made_t = [];
|
||||
$a_made_a = [];
|
||||
$a_got_t = [];
|
||||
$a_got_a = [];
|
||||
$away_made_total = [];
|
||||
$away_made_away = [];
|
||||
$away_got_total = [];
|
||||
$away_got_away = [];
|
||||
|
||||
foreach ($data as $value) {
|
||||
// HOME
|
||||
if ($value['home_id'] == $home_id || $value['away_id'] == $home_id) {
|
||||
$h_made_t[] = $value['val_home'];
|
||||
$h_got_t[] = $value['val_away'];
|
||||
}
|
||||
if ($value['home_id'] == $home_id) {
|
||||
$h_made_h[] = $value['val_home'];
|
||||
$h_got_h[] = $value['val_away'];
|
||||
}
|
||||
// if ($value['home_id'] == $home_id || $value['away_id'] == $home_id) {
|
||||
// $home_made_total[] = $value['val_home'];
|
||||
// $home_got_total[] = $value['val_away'];
|
||||
// }
|
||||
// if ($value['home_id'] == $home_id) {
|
||||
// $home_made_home[] = $value['val_home'];
|
||||
// $home_got_home[] = $value['val_away'];
|
||||
// }
|
||||
|
||||
// AWAY
|
||||
if ($value['home_id'] == $away_id || $value['away_id'] == $away_id) {
|
||||
$a_made_t[] = $value['val_away'];
|
||||
$a_made_a[] = $value['val_home'];
|
||||
// if ($value['home_id'] == $away_id || $value['away_id'] == $away_id) {
|
||||
// $away_made_total[] = $value['val_away'];
|
||||
// $away_made_away[] = $value['val_home'];
|
||||
// }
|
||||
|
||||
// if ($value['away_id'] == $away_id) {
|
||||
// $away_made_away[] = $value['val_away'];
|
||||
// $away_got_away[] = $value['val_home'];
|
||||
// }
|
||||
|
||||
if ($value['home_id'] == $home_id) {
|
||||
$home_made_total[] = $value['val_home'];
|
||||
$home_made_home[] = $value['val_home'];
|
||||
$home_got_total[] = $value['val_away'];
|
||||
$home_got_home[] = $value['val_away'];
|
||||
} elseif ($value['away_id'] == $home_id) {
|
||||
$home_made_total[] = $value['val_away'];
|
||||
$home_got_total[] = $value['val_away'];
|
||||
} elseif ($value['home_id'] == $away_id) {
|
||||
$home_made_total[] = $value['val_away'];
|
||||
$home_got_total[] = $value['val_away'];
|
||||
} elseif ($value['away_id'] == $away_id) {
|
||||
$home_made_total[] = $value['val_home'];
|
||||
$home_made_home[] = $value['val_home'];
|
||||
$home_got_total[] = $value['val_away'];
|
||||
$home_got_home[] = $value['val_home'];
|
||||
}
|
||||
|
||||
if ($value['away_id'] == $away_id) {
|
||||
$a_made_a[] = $value['val_away'];
|
||||
$a_got_a[] = $value['val_home'];
|
||||
$away_made_total[] = $value['val_away'];
|
||||
$away_made_away[] = $value['val_away'];
|
||||
$away_got_total[] = $value['val_home'];
|
||||
$away_got_away[] = $value['val_home'];
|
||||
} elseif ($value['home_id'] == $away_id) {
|
||||
$away_made_total[] = $value['val_home'];
|
||||
$away_got_total[] = $value['val_home'];
|
||||
} elseif ($value['away_id'] == $home_id) {
|
||||
$away_made_total[] = $value['val_home'];
|
||||
$away_got_total[] = $value['val_home'];
|
||||
} elseif ($value['home_id'] == $home_id) {
|
||||
$away_made_total[] = $value['val_away'];
|
||||
$away_made_away[] = $value['val_away'];
|
||||
$away_got_total[] = $value['val_home'];
|
||||
$away_got_away[] = $value['val_away'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$summe_home = array_sum($h_made_t) * $home_made_total;
|
||||
$summe_home += array_sum($h_made_h) * $home_made_home;
|
||||
$summe_home += array_sum($h_got_t) * $home_got_total;
|
||||
$summe_home += array_sum($h_got_h) * $home_got_home;
|
||||
$count_home = \count($h_made_t);
|
||||
$count_home += \count($h_made_h);
|
||||
$count_home += \count($h_got_t);
|
||||
$count_home += \count($h_got_h);
|
||||
$summe_home = array_sum($home_made_total) * $uba_home_made_total;
|
||||
$summe_home += array_sum($home_made_home) * $uba_home_made_home;
|
||||
$summe_home += array_sum($home_got_total) * $uba_home_got_total;
|
||||
$summe_home += array_sum($home_got_home) * $uba_home_got_home;
|
||||
$count_home = \count($home_made_total);
|
||||
$count_home += \count($home_made_home);
|
||||
$count_home += \count($home_got_total);
|
||||
$count_home += \count($home_got_home);
|
||||
|
||||
$count_home = !$count_home ? 1 : $count_home;
|
||||
$count_home = ! $count_home ? 1 : $count_home;
|
||||
$aspettativa_home = round($summe_home / $count_home, 1);
|
||||
|
||||
$summe_away = array_sum($a_made_t) * $away_made_total;
|
||||
$summe_away += array_sum($a_made_a) * $away_made_home;
|
||||
$summe_away += array_sum($a_got_t) * $away_got_total;
|
||||
$summe_away += array_sum($a_got_a) * $away_got_home;
|
||||
$count_away = \count($a_made_t);
|
||||
$count_away += \count($a_made_a);
|
||||
$count_away += \count($a_got_t);
|
||||
$count_away += \count($a_got_a);
|
||||
$summe_away = array_sum($away_made_total) * $uba_away_made_total;
|
||||
$summe_away += array_sum($away_made_away) * $uba_away_made_home;
|
||||
$summe_away += array_sum($away_got_total) * $uba_away_got_total;
|
||||
$summe_away += array_sum($away_got_away) * $uba_away_got_home;
|
||||
$count_away = \count($away_made_total);
|
||||
$count_away += \count($away_made_away);
|
||||
$count_away += \count($away_got_total);
|
||||
$count_away += \count($away_got_away);
|
||||
|
||||
$count_away = !$count_away ? 1 : $count_away;
|
||||
$count_away = ! $count_away ? 1 : $count_away;
|
||||
$aspettativa_away = round($summe_away / $count_away, 1);
|
||||
|
||||
return ['home' => $aspettativa_home, 'away' => $aspettativa_away];
|
||||
|
||||
@@ -12,6 +12,7 @@ use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Livewire\Attributes\Reactive;
|
||||
|
||||
// use Illuminate\Support\Facades\Log;
|
||||
|
||||
class StatsMedianAverage extends StatsOverviewWidget
|
||||
@@ -45,10 +46,11 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
|
||||
switch ($season_or_date) {
|
||||
case 'season':
|
||||
if ($season)
|
||||
if ($season) {
|
||||
$date_events = implode(', ', $season);
|
||||
else
|
||||
} else {
|
||||
$date_events = 'Current Season';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$start = $this->filters['start_date'] ?? 0;
|
||||
@@ -56,16 +58,18 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
|
||||
$tmp = [];
|
||||
if ($start) {
|
||||
$tmp[] = 'From: ' . Carbon::createFromDate($start)->format('Y-m-d');
|
||||
$tmp[] = 'From: '.Carbon::createFromDate($start)->format('Y-m-d');
|
||||
}
|
||||
|
||||
if ($end)
|
||||
$tmp[] = 'To: ' . Carbon::createFromDate($end)->format('Y-m-d');
|
||||
if ($end) {
|
||||
$tmp[] = 'To: '.Carbon::createFromDate($end)->format('Y-m-d');
|
||||
}
|
||||
|
||||
if ($tmp)
|
||||
if ($tmp) {
|
||||
$date_events = implode('<br>', $tmp);
|
||||
else
|
||||
} else {
|
||||
$date_events = 'All Dates';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -77,7 +81,6 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
|
||||
$statistic_type = HelperStatisticType::get($this->filters);
|
||||
|
||||
|
||||
if (! isset($data['datasets'][0])) {
|
||||
$data['datasets'][0]['data'] = [];
|
||||
$data['datasets'][1]['data'] = [];
|
||||
@@ -108,7 +111,6 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
$lost = 0;
|
||||
}
|
||||
|
||||
|
||||
if ($total_home) {
|
||||
$value_home = number_format($summe_home / $total_home, 1);
|
||||
} else {
|
||||
@@ -120,7 +122,6 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
$value_away = 0;
|
||||
}
|
||||
|
||||
|
||||
$max_boxes = 3;
|
||||
$average_team_home = 0;
|
||||
$average_team_away = 0;
|
||||
@@ -150,15 +151,15 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
if ($similar_past_matches != 'none') {
|
||||
// BOX 2
|
||||
$boxes[] = Stat::make('Total', self::template_box2($total_home))
|
||||
->description(fn() => new HtmlString($date_events))
|
||||
->description(fn () => new HtmlString($date_events))
|
||||
->extraAttributes([
|
||||
'x-init' => "animate('number-of-events', $total_home);",
|
||||
'class' => 'box-info',
|
||||
]);
|
||||
|
||||
// BOX 3
|
||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template_box3('Home', 'Away', $value_home, $value_away))
|
||||
->description('Team ' . $team_position)
|
||||
$boxes[] = Stat::make('Average '.$statistic_type, self::template_box3('Home', 'Away', $value_home, $value_away))
|
||||
->description('Team '.$team_position)
|
||||
->extraAttributes([
|
||||
'x-init' => "animate('average_home', $value_home); animate('average_away', $value_away)",
|
||||
'class' => 'box-success',
|
||||
@@ -184,22 +185,22 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
|
||||
// BOX 2
|
||||
$boxes[] = Stat::make('Total', self::template_box2($total_home))
|
||||
->description(fn() => new HtmlString($date_events))
|
||||
->description(fn () => new HtmlString($date_events))
|
||||
->extraAttributes([
|
||||
'x-init' => "animate('number-of-events', $total_home);",
|
||||
'class' => 'box-info',
|
||||
]);
|
||||
|
||||
// BOX 3
|
||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template_box3($home_team, $away_team, $value_home, $value_away))
|
||||
->description('Team ' . $team_position)
|
||||
$boxes[] = Stat::make('Average '.$statistic_type, self::template_box3($home_team, $away_team, $value_home, $value_away))
|
||||
->description('Team '.$team_position)
|
||||
->extraAttributes([
|
||||
'x-init' => "animate('average_home', $value_home); animate('average_away', $value_away)",
|
||||
'class' => 'box-success',
|
||||
]);
|
||||
|
||||
// BOX 4
|
||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template_box4($home_team, $away_team, $average_team_home, $average_team_away))
|
||||
$boxes[] = Stat::make('Average '.$statistic_type, self::template_box4($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)",
|
||||
@@ -207,7 +208,7 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
]);
|
||||
|
||||
// BOX 5
|
||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template_box5('Home', 'Away', $average_league_home, $average_league_away))
|
||||
$boxes[] = Stat::make('Average '.$statistic_type, self::template_box5('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)",
|
||||
@@ -238,8 +239,8 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
protected function template_box1(float $expectations_home, float $expectations_away): HtmlString
|
||||
{
|
||||
return new HtmlString('<div class="grid grid-cols-2 justify-center font-bold text-2xl">
|
||||
<span class="text-center" id="expectations_home">' . $expectations_home . '</span>
|
||||
<span class="text-center" id="expectations_away">' . $expectations_away . '</span>
|
||||
<span class="text-center" id="expectations_home">'.$expectations_home.'</span>
|
||||
<span class="text-center" id="expectations_away">'.$expectations_away.'</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">Home</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">Away</span>
|
||||
</div>');
|
||||
@@ -249,7 +250,7 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
protected function template_box2(float $total_home): HtmlString
|
||||
{
|
||||
return new HtmlString('<div class="grid grid-cols-1 justify-center font-bold text-2xl">
|
||||
<span class="text-center" id="number-of-events">' . $total_home . '</span>
|
||||
<span class="text-center" id="number-of-events">'.$total_home.'</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">Events</span>
|
||||
</div>');
|
||||
}
|
||||
@@ -258,10 +259,10 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
protected function template_box3(string $home_team, string $away_team, float $value_home, float $value_away): HtmlString
|
||||
{
|
||||
return new HtmlString('<div class="grid grid-cols-2 justify-center font-bold text-2xl">
|
||||
<span class="text-center" id="average_home">' . $value_home . '</span>
|
||||
<span class="text-center" id="average_away">' . $value_away . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $home_team . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $away_team . '</span>
|
||||
<span class="text-center" id="average_home">'.$value_home.'</span>
|
||||
<span class="text-center" id="average_away">'.$value_away.'</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">'.$home_team.'</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">'.$away_team.'</span>
|
||||
</div>');
|
||||
}
|
||||
|
||||
@@ -269,10 +270,10 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
protected function template_box4(string $home_team, string $away_team, float $value_home, float $value_away): HtmlString
|
||||
{
|
||||
return new HtmlString('<div class="grid grid-cols-2 justify-center font-bold text-2xl">
|
||||
<span class="text-center" id="av_team_home">' . $value_home . '</span>
|
||||
<span class="text-center" id="av_team_away">' . $value_away . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $home_team . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $away_team . '</span>
|
||||
<span class="text-center" id="av_team_home">'.$value_home.'</span>
|
||||
<span class="text-center" id="av_team_away">'.$value_away.'</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">'.$home_team.'</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">'.$away_team.'</span>
|
||||
</div>');
|
||||
}
|
||||
|
||||
@@ -280,10 +281,10 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
protected function template_box5(string $home_team, string $away_team, float $value_home, float $value_away): HtmlString
|
||||
{
|
||||
return new HtmlString('<div class="grid grid-cols-2 justify-center font-bold text-2xl">
|
||||
<span class="text-center" id="av_league_home">' . $value_home . '</span>
|
||||
<span class="text-center" id="av_league_away">' . $value_away . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $home_team . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $away_team . '</span>
|
||||
<span class="text-center" id="av_league_home">'.$value_home.'</span>
|
||||
<span class="text-center" id="av_league_away">'.$value_away.'</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">'.$home_team.'</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">'.$away_team.'</span>
|
||||
</div>');
|
||||
}
|
||||
|
||||
@@ -291,26 +292,25 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
protected function templateOdds(array &$data, float $win, float $draw, float $lost): HtmlString
|
||||
{
|
||||
if ($data['similar_past_matches'] != 'none') {
|
||||
$name_win = '<b>1</b> (' . $data['results']['w'] . ')';
|
||||
$name_draw = '<b>X</b> (' . $data['results']['d'] . ')';
|
||||
$name_lost = '<b>2</b> (' . $data['results']['l'] . ')';
|
||||
$name_win = '<b>1</b> ('.$data['results']['w'].')';
|
||||
$name_draw = '<b>X</b> ('.$data['results']['d'].')';
|
||||
$name_lost = '<b>2</b> ('.$data['results']['l'].')';
|
||||
} else {
|
||||
$name_win = '<b>Win</b> (' . $data['results']['w'] . ')';
|
||||
$name_draw = '<b>Draw</b> (' . $data['results']['d'] . ')';
|
||||
$name_lost = '<b>Lost</b> (' . $data['results']['l'] . ')';
|
||||
$name_win = '<b>Win</b> ('.$data['results']['w'].')';
|
||||
$name_draw = '<b>Draw</b> ('.$data['results']['d'].')';
|
||||
$name_lost = '<b>Lost</b> ('.$data['results']['l'].')';
|
||||
}
|
||||
|
||||
return new HtmlString('<div class="grid grid-cols-3 justify-center">
|
||||
<span class="text-center font-bold text-xl" id="win">' . number_format($win, 2) . '</span>
|
||||
<span class="text-center font-bold text-xl" id="draw">' . number_format($draw, 2) . '</span>
|
||||
<span class="text-center font-bold text-xl" id="lost">' . number_format($lost, 2) . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $name_win . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $name_draw . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $name_lost . '</span>
|
||||
<span class="text-center font-bold text-xl" id="win">'.number_format($win, 2).'</span>
|
||||
<span class="text-center font-bold text-xl" id="draw">'.number_format($draw, 2).'</span>
|
||||
<span class="text-center font-bold text-xl" id="lost">'.number_format($lost, 2).'</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">'.$name_win.'</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">'.$name_draw.'</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">'.$name_lost.'</span>
|
||||
</div>');
|
||||
}
|
||||
|
||||
|
||||
protected function getMedian(array $arr)
|
||||
{
|
||||
sort($arr);
|
||||
|
||||
Reference in new issue
Block a user