smp show only 3 boxes wip
This commit is contained in:
1 parent
ff5d8bda1b
commit
83c78c4a46
1 file changed
+67
-55
@@ -35,12 +35,13 @@ class StatsMedianAverage extends StatsOverviewWidget
|
|||||||
protected function getStats(): array
|
protected function getStats(): array
|
||||||
{
|
{
|
||||||
$data = LoadEvents::load($this->filters, false);
|
$data = LoadEvents::load($this->filters, false);
|
||||||
|
|
||||||
$team_id = (int) $this->filters['team_id'] ?? 0;
|
$team_id = (int) $this->filters['team_id'] ?? 0;
|
||||||
|
|
||||||
$season = $this->filterss['season'] ?? 0;
|
$season = $this->filters['season'] ?? 0;
|
||||||
$season_or_date = $this->filters['season_or_date'];
|
$season_or_date = $this->filters['season_or_date'];
|
||||||
|
$similar_past_matches = $this->filters['similar_past_matches'];
|
||||||
$date_events = '';
|
$date_events = '';
|
||||||
|
|
||||||
switch ($season_or_date) {
|
switch ($season_or_date) {
|
||||||
case 'season':
|
case 'season':
|
||||||
if ($season)
|
if ($season)
|
||||||
@@ -77,9 +78,9 @@ class StatsMedianAverage extends StatsOverviewWidget
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$statistic_type = HelperStatisticType::get($this->filters);
|
$statistic_type = HelperStatisticType::get($this->filters);
|
||||||
|
|
||||||
|
|
||||||
if (! isset($data['datasets'][0])) {
|
if (! isset($data['datasets'][0])) {
|
||||||
$data['datasets'][0]['data'] = [];
|
$data['datasets'][0]['data'] = [];
|
||||||
$data['datasets'][1]['data'] = [];
|
$data['datasets'][1]['data'] = [];
|
||||||
@@ -100,19 +101,7 @@ class StatsMedianAverage extends StatsOverviewWidget
|
|||||||
$away_team = $data['away_team'];
|
$away_team = $data['away_team'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ($arr_home) {
|
if (isset($data['results'])) {
|
||||||
// $median_home = self::getMedian($arr_home);
|
|
||||||
// } else {
|
|
||||||
// $median_home = 0;
|
|
||||||
// }
|
|
||||||
// if ($arr_away) {
|
|
||||||
// $median_away = self::getMedian($arr_away);
|
|
||||||
// } else {
|
|
||||||
// $median_away = 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (isset($data['results']) && $team_id) {
|
|
||||||
// Log::debug($data['results']);
|
|
||||||
$win = $data['results']['w'] ? number_format(Round::odd($total_home / $data['results']['w']), 2) : 0;
|
$win = $data['results']['w'] ? number_format(Round::odd($total_home / $data['results']['w']), 2) : 0;
|
||||||
$draw = $data['results']['d'] ? number_format(Round::odd($total_home / $data['results']['d']), 2) : 0;
|
$draw = $data['results']['d'] ? number_format(Round::odd($total_home / $data['results']['d']), 2) : 0;
|
||||||
$lost = $data['results']['l'] ? number_format(Round::odd($total_home / $data['results']['l']), 2) : 0;
|
$lost = $data['results']['l'] ? number_format(Round::odd($total_home / $data['results']['l']), 2) : 0;
|
||||||
@@ -122,12 +111,12 @@ class StatsMedianAverage extends StatsOverviewWidget
|
|||||||
$lost = 0;
|
$lost = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($total_home && $team_id) {
|
if ($total_home) {
|
||||||
$value_home = number_format($summe_home / $total_home, 1);
|
$value_home = number_format($summe_home / $total_home, 1);
|
||||||
} else {
|
} else {
|
||||||
$value_home = 0;
|
$value_home = 0;
|
||||||
}
|
}
|
||||||
if ($total_away && $team_id) {
|
if ($total_away) {
|
||||||
$value_away = number_format($summe_away / $total_away, 1);
|
$value_away = number_format($summe_away / $total_away, 1);
|
||||||
} else {
|
} else {
|
||||||
$value_away = 0;
|
$value_away = 0;
|
||||||
@@ -159,19 +148,7 @@ class StatsMedianAverage extends StatsOverviewWidget
|
|||||||
|
|
||||||
$boxes = [];
|
$boxes = [];
|
||||||
|
|
||||||
// Log::info(__Line__ . ' ' . $expectations_home . ' - ' . $expectations_away);
|
if ($similar_past_matches != 'none') {
|
||||||
|
|
||||||
|
|
||||||
// BOX 1
|
|
||||||
$boxes[] = Stat::make($statistic_type, self::template_box1($expectations_home, $expectations_away))
|
|
||||||
->description('Expected Values')
|
|
||||||
->extraAttributes([
|
|
||||||
'x-init' => "console.log('expectations_home, expectations_away'); animate('expectations_home', $expectations_home); animate('expectations_away', $expectations_away)",
|
|
||||||
'class' => 'box-yellow',
|
|
||||||
]);
|
|
||||||
|
|
||||||
if ($team_id) {
|
|
||||||
|
|
||||||
// BOX 2
|
// BOX 2
|
||||||
$boxes[] = Stat::make('Total', self::template_box2($total_home))
|
$boxes[] = Stat::make('Total', self::template_box2($total_home))
|
||||||
->description(fn() => new HtmlString($date_events))
|
->description(fn() => new HtmlString($date_events))
|
||||||
@@ -181,29 +158,12 @@ class StatsMedianAverage extends StatsOverviewWidget
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// BOX 3
|
// BOX 3
|
||||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template_box3($home_team, $away_team, $value_home, $value_away))
|
$boxes[] = Stat::make('Average ' . $statistic_type, self::template_box3('Home', 'Away', $value_home, $value_away))
|
||||||
->description('Team ' . $team_position)
|
->description('Team ' . $team_position)
|
||||||
->extraAttributes([
|
->extraAttributes([
|
||||||
'x-init' => "animate('average_home', $value_home); animate('average_away', $value_away)",
|
'x-init' => "animate('average_home', $value_home); animate('average_away', $value_away)",
|
||||||
'class' => 'box-success',
|
'class' => 'box-success',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// BOX 4
|
|
||||||
$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)",
|
|
||||||
'class' => 'box-success',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// BOX 5
|
|
||||||
$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)",
|
|
||||||
'class' => 'box-success',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// BOX 6
|
// BOX 6
|
||||||
$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)
|
||||||
@@ -211,6 +171,58 @@ class StatsMedianAverage extends StatsOverviewWidget
|
|||||||
'x-init' => "animate('win', $win); animate('draw', $draw); animate('lost', $lost)",
|
'x-init' => "animate('win', $win); animate('draw', $draw); animate('lost', $lost)",
|
||||||
'class' => 'box-purple',
|
'class' => 'box-purple',
|
||||||
]);
|
]);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// BOX 1
|
||||||
|
$boxes[] = Stat::make($statistic_type, self::template_box1($expectations_home, $expectations_away))
|
||||||
|
->description('Expected Values')
|
||||||
|
->extraAttributes([
|
||||||
|
'x-init' => "console.log('expectations_home, expectations_away'); animate('expectations_home', $expectations_home); animate('expectations_away', $expectations_away)",
|
||||||
|
'class' => 'box-yellow',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($team_id) {
|
||||||
|
|
||||||
|
// BOX 2
|
||||||
|
$boxes[] = Stat::make('Total', self::template_box2($total_home))
|
||||||
|
->description(fn() => new HtmlString($date_events))
|
||||||
|
->extraAttributes([
|
||||||
|
'x-init' => "console.log('number-of-events'); 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)
|
||||||
|
->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))
|
||||||
|
->description('Team Season')
|
||||||
|
->extraAttributes([
|
||||||
|
'x-init' => "animate('av_team_home', $average_team_home); animate('av_team_away', $average_team_away)",
|
||||||
|
'class' => 'box-success',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// BOX 5
|
||||||
|
$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)",
|
||||||
|
'class' => 'box-success',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// BOX 6
|
||||||
|
$boxes[] = Stat::make('Odds', self::templateOdds($data, $win, $draw, $lost))
|
||||||
|
->description($team_position)
|
||||||
|
->extraAttributes([
|
||||||
|
'x-init' => "animate('win', $win); animate('draw', $draw); animate('lost', $lost)",
|
||||||
|
'class' => 'box-purple',
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->columns = [
|
$this->columns = [
|
||||||
@@ -280,13 +292,13 @@ class StatsMedianAverage extends StatsOverviewWidget
|
|||||||
protected function templateOdds(array &$data, float $win, float $draw, float $lost): HtmlString
|
protected function templateOdds(array &$data, float $win, float $draw, float $lost): HtmlString
|
||||||
{
|
{
|
||||||
if ($data['similar_past_matches'] != 'none') {
|
if ($data['similar_past_matches'] != 'none') {
|
||||||
$name_win = '1 (' . $data['results']['w'] . ')';
|
$name_win = '<b>1</b> (' . $data['results']['w'] . ')';
|
||||||
$name_draw = 'X (' . $data['results']['d'] . ')';
|
$name_draw = '<b>X</b> (' . $data['results']['d'] . ')';
|
||||||
$name_lost = '2 (' . $data['results']['l'] . ')';
|
$name_lost = '<b>2</b> (' . $data['results']['l'] . ')';
|
||||||
} else {
|
} else {
|
||||||
$name_win = 'Win (' . $data['results']['w'] . ')';
|
$name_win = '<b>Win</b> (' . $data['results']['w'] . ')';
|
||||||
$name_draw = 'Draw (' . $data['results']['d'] . ')';
|
$name_draw = '<b>Draw</b> (' . $data['results']['d'] . ')';
|
||||||
$name_lost = 'Lost (' . $data['results']['l'] . ')';
|
$name_lost = '<b>Lost</b> (' . $data['results']['l'] . ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HtmlString('<div class="grid grid-cols-3 justify-center">
|
return new HtmlString('<div class="grid grid-cols-3 justify-center">
|
||||||
|
|||||||
Reference in new issue
Block a user