wip
This commit is contained in:
1 parent
3376eb6d2e
commit
ec60adb074
9 files changed
+194
-195
No files matched your search
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Filament\Widgets\Data\HelperStatisticType;
|
||||
use App\Filament\Widgets\Data\HelperTeamPosition;
|
||||
use App\Filament\Widgets\Data\LoadEvents;
|
||||
use App\Utilities\Round;
|
||||
use Filament\Widgets\StatsOverviewWidget;
|
||||
@@ -30,6 +31,8 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
{
|
||||
$data = LoadEvents::load($this->filters, false);
|
||||
|
||||
$team_position = HelperTeamPosition::get($this->filters);
|
||||
|
||||
if (!$data)
|
||||
return [];
|
||||
|
||||
@@ -71,17 +74,6 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
$home_team = $data['home_team'];
|
||||
$away_team = $data['away_team'];
|
||||
}
|
||||
// dd($arr_home);
|
||||
// if (! $total_home) {
|
||||
// return [
|
||||
// Stat::make('Number of events', 0),
|
||||
// Stat::make('Average ' . $statistic_type, self::template(0, 0, $home_team, $away_team)),
|
||||
// Stat::make('Median ' . $statistic_type, self::template(0, 0, $home_team, $away_team)),
|
||||
// Stat::make('Win', 0),
|
||||
// Stat::make('Draw', 0),
|
||||
// Stat::make('Lost', 0),
|
||||
// ];
|
||||
// }
|
||||
|
||||
if ($arr_home)
|
||||
$median_home = self::getMedian($arr_home);
|
||||
@@ -112,15 +104,15 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
$value_away = 0;
|
||||
|
||||
$boxes = [];
|
||||
$boxes[] = Stat::make('Events', new HtmlString('<div id="number-of-events">' . $total_home . '</div>'))->description('Number')->extraAttributes(['x-init' => "animate('number-of-events', $total_home, 0)"]);
|
||||
$boxes[] = Stat::make($statistic_type, self::template('avhome', 'avaway', $home_team, $away_team))->description('Average Team')->extraAttributes(['x-init' => "animate('avhome', $value_home); animate('avaway', $value_away, 0)"]);
|
||||
$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)"]);
|
||||
$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, 0)"]);
|
||||
foreach ($data['datasets'] as $value) {
|
||||
if ($value['label'] == "Average League") {
|
||||
$str = $value['data'][0] ?? 0;
|
||||
$boxes[] = Stat::make($statistic_type, new HtmlString('<div id="number-of-events">' . $str . '</div>'))->description('Average League')->extraAttributes(['x-init' => "animate('number-of-events', $total_home, 0)"]);
|
||||
$boxes[] = Stat::make('Average ' . $statistic_type, new HtmlString('<div id="number-of-events">' . $str . '</div>'))->description('League ' . $team_position)->extraAttributes(['x-init' => "animate('number-of-events', $total_home, 0)"]);
|
||||
}
|
||||
}
|
||||
$boxes[] = Stat::make($statistic_type, self::template('mehome', 'meaway', $home_team, $away_team))->description('Median')->extraAttributes(['x-init' => "animate('mehome', $median_home); animate('meaway', $median_away, 0)"]);
|
||||
$boxes[] = Stat::make('Median ' . $statistic_type, self::template('mehome', 'meaway', $home_team, $away_team))->description($team_position)->extraAttributes(['x-init' => "animate('mehome', $median_home); animate('meaway', $median_away, 0)"]);
|
||||
$boxes[] = Stat::make($data['similar_past_matches'] != 'none' ? '1' : 'Win: ' . $data['results']['w'], new HtmlString('<div id="number-of-win">' . $win . '</div>'))->extraAttributes(['x-init' => "animate('number-of-win', $win, 1)"]);
|
||||
$boxes[] = Stat::make($data['similar_past_matches'] != 'none' ? 'X' : 'Draw: ' . $data['results']['d'], new HtmlString('<div id="number-of-draw">' . $draw . '</div>'))->extraAttributes(['x-init' => "animate('number-of-draw', $draw, 1)"]);
|
||||
$boxes[] = Stat::make($data['similar_past_matches'] != 'none' ? '2' : 'Lost: ' . $data['results']['l'], new HtmlString('<div id="number-of-lost">' . $lost . '</div>'))->extraAttributes(['x-init' => "animate('number-of-lost', $lost, 1)"]);
|
||||
|
||||
Reference in new issue
Block a user