diff --git a/app/Filament/Widgets/ChartEvent.php b/app/Filament/Widgets/ChartEvent.php index ee465e96..fe8c993b 100644 --- a/app/Filament/Widgets/ChartEvent.php +++ b/app/Filament/Widgets/ChartEvent.php @@ -6,6 +6,7 @@ use App\Filament\Widgets\Data\HelperStatisticType; use App\Filament\Widgets\Data\LoadEvents; use Filament\Support\RawJs; use Filament\Widgets\ChartWidget; +use Illuminate\Support\HtmlString; use Livewire\Attributes\Reactive; class ChartEvent extends ChartWidget @@ -13,19 +14,32 @@ class ChartEvent extends ChartWidget #[Reactive] public ?array $filters = []; - protected ?string $heading = 'Events'; + public ?string $type = ''; protected ?string $pollingInterval = null; - protected bool $isCollapsible = true; + protected bool $isCollapsible = false; protected $f; + public function getHeading(): HtmlString + { + return new HtmlString(' + + + + Events + + '.$this->type.' + + '); + } + protected function getData(): array { $data = LoadEvents::load($this->filters); - $this->description = ucfirst(HelperStatisticType::get($this->filters)); + $this->type = ucfirst(HelperStatisticType::get($this->filters)); if (isset($data['description'])) { $this->description .= $data['description']; diff --git a/app/Filament/Widgets/ChartEventMoAv.php b/app/Filament/Widgets/ChartEventMoAv.php index 88ef0adf..63fd198a 100644 --- a/app/Filament/Widgets/ChartEventMoAv.php +++ b/app/Filament/Widgets/ChartEventMoAv.php @@ -7,6 +7,7 @@ use App\Filament\Widgets\Data\HelperStatisticType; use App\Filament\Widgets\Data\LoadEvents; use Filament\Support\RawJs; use Filament\Widgets\ChartWidget; +use Illuminate\Support\HtmlString; use Livewire\Attributes\Reactive; class ChartEventMoAv extends ChartWidget @@ -14,17 +15,30 @@ class ChartEventMoAv extends ChartWidget #[Reactive] public ?array $filters = []; - protected ?string $heading = 'Events'; + public ?string $type = ''; protected ?string $pollingInterval = null; - protected bool $isCollapsible = true; + protected bool $isCollapsible = false; + + public function getHeading(): HtmlString + { + return new HtmlString(' + + + + Events + + '.$this->type.' Moving Average + + '); + } protected function getData(): array { $data = LoadEvents::load($this->filters); - $this->description = ucfirst(HelperStatisticType::get($this->filters)).' Moving Average'; + $this->type = ucfirst(HelperStatisticType::get($this->filters)); if ($data) { diff --git a/app/Filament/Widgets/ChartEventPerf.php b/app/Filament/Widgets/ChartEventPerf.php index 1aa47c8b..1c795388 100644 --- a/app/Filament/Widgets/ChartEventPerf.php +++ b/app/Filament/Widgets/ChartEventPerf.php @@ -5,6 +5,7 @@ namespace App\Filament\Widgets; use App\Filament\Widgets\Data\LoadPerformance; use Filament\Support\RawJs; use Filament\Widgets\ChartWidget; +use Illuminate\Support\HtmlString; use Livewire\Attributes\Reactive; class ChartEventPerf extends ChartWidget @@ -12,14 +13,25 @@ class ChartEventPerf extends ChartWidget #[Reactive] public ?array $filters = []; - protected ?string $heading = 'Events'; - - protected ?string $description = 'Performance'; + public ?string $type = ''; protected ?string $pollingInterval = null; protected bool $isCollapsible = true; + public function getHeading(): HtmlString + { + return new HtmlString(' + + + + Events + + '.$this->type.' Performance + + '); + } + protected function getData(): array { return LoadPerformance::load($this->filters); diff --git a/app/Filament/Widgets/ChartEventPerfMoAv.php b/app/Filament/Widgets/ChartEventPerfMoAv.php index c5d01a99..000f39cb 100644 --- a/app/Filament/Widgets/ChartEventPerfMoAv.php +++ b/app/Filament/Widgets/ChartEventPerfMoAv.php @@ -6,6 +6,7 @@ use App\Filament\Widgets\Data\HelperMoveingAveragePerformens; use App\Filament\Widgets\Data\LoadPerformance; use Filament\Support\RawJs; use Filament\Widgets\ChartWidget; +use Illuminate\Support\HtmlString; use Livewire\Attributes\Reactive; class ChartEventPerfMoAv extends ChartWidget @@ -13,13 +14,24 @@ class ChartEventPerfMoAv extends ChartWidget #[Reactive] public ?array $filters = []; - protected ?string $heading = 'Events'; - - protected ?string $description = 'Performance Moving Average'; + public ?string $type = ''; protected ?string $pollingInterval = null; - protected bool $isCollapsible = true; + protected bool $isCollapsible = false; + + public function getHeading(): HtmlString + { + return new HtmlString(' + + + + Events + + '.$this->type.' Performance Moving Average + + '); + } protected function getData(): array { diff --git a/app/Filament/Widgets/ChartPlayer.php b/app/Filament/Widgets/ChartPlayer.php index 26e890e8..59626aab 100644 --- a/app/Filament/Widgets/ChartPlayer.php +++ b/app/Filament/Widgets/ChartPlayer.php @@ -6,6 +6,7 @@ use App\Filament\Widgets\Data\HelperStatisticType; use App\Filament\Widgets\Data\LoadPlayer; use Filament\Support\RawJs; use Filament\Widgets\ChartWidget; +use Illuminate\Support\HtmlString; use Livewire\Attributes\Reactive; class ChartPlayer extends ChartWidget @@ -13,23 +14,46 @@ class ChartPlayer extends ChartWidget #[Reactive] public ?array $filters = []; + public ?string $player = 'Player'; + + public ?string $type = ''; + protected ?string $pollingInterval = null; - protected bool $isCollapsible = true; + // protected bool $isCollapsible = true; - protected static ?bool $isCollapsed = true; - - protected ?string $heading = 'Player'; + public function getHeading(): HtmlString + { + return new HtmlString(' + + + + '.$this->player.' + + '.$this->type.' + + '); + } protected function getData(): array { $data = LoadPlayer::load($this->filters); if ($data) { - $this->description = ucfirst(HelperStatisticType::get($this->filters)); - if ($data['player_name']) { - $this->description .= ' '.$data['player_name']; - } + $this->player = $data['player_name'] ?? ''; + $this->type = ucfirst(HelperStatisticType::get($this->filters)); } return $data; diff --git a/app/Filament/Widgets/ChartPlayerMoAv.php b/app/Filament/Widgets/ChartPlayerMoAv.php index 98b8233b..88459de5 100644 --- a/app/Filament/Widgets/ChartPlayerMoAv.php +++ b/app/Filament/Widgets/ChartPlayerMoAv.php @@ -3,9 +3,11 @@ namespace App\Filament\Widgets; use App\Filament\Widgets\Data\HelperMoveingAverage; +use App\Filament\Widgets\Data\HelperStatisticType; use App\Filament\Widgets\Data\LoadPlayer; use Filament\Support\RawJs; use Filament\Widgets\ChartWidget; +use Illuminate\Support\HtmlString; use Livewire\Attributes\Reactive; class ChartPlayerMoAv extends ChartWidget @@ -13,18 +15,46 @@ class ChartPlayerMoAv extends ChartWidget #[Reactive] public ?array $filters = []; + public ?string $player = 'Player'; + + public ?string $type = ''; + protected ?string $pollingInterval = null; - protected bool $isCollapsible = true; + // protected bool $isCollapsible = true; - protected ?string $heading = 'Player'; + public function getHeading(): HtmlString + { + return new HtmlString(' + + + + '.$this->player.' + + '.$this->type.' + + '); + } protected function getData(): array { $data = LoadPlayer::load($this->filters); if ($data) { - $this->description = 'Moving Average '.$data['player_name']; + $this->player = $data['player_name'] ?? ''; + $this->type = ucfirst(HelperStatisticType::get($this->filters)); HelperMoveingAverage::get($data); } diff --git a/app/Filament/Widgets/ChartPlayerPerf.php b/app/Filament/Widgets/ChartPlayerPerf.php index 159a9b9b..5b276413 100644 --- a/app/Filament/Widgets/ChartPlayerPerf.php +++ b/app/Filament/Widgets/ChartPlayerPerf.php @@ -5,6 +5,7 @@ namespace App\Filament\Widgets; use App\Filament\Widgets\Data\LoadPlayerPerformance; use Filament\Support\RawJs; use Filament\Widgets\ChartWidget; +use Illuminate\Support\HtmlString; use Livewire\Attributes\Reactive; class ChartPlayerPerf extends ChartWidget @@ -12,16 +13,46 @@ class ChartPlayerPerf extends ChartWidget #[Reactive] public ?array $filters = []; - protected ?string $heading = 'Player'; + public ?string $player = 'Player'; - protected ?string $description = 'Performance'; + public ?string $type = ''; protected ?string $pollingInterval = null; - protected bool $isCollapsible = true; + protected bool $isCollapsible = false; + + public function getHeading(): HtmlString + { + return new HtmlString(' + + + + '.$this->player.' + + Performance + + '); + } protected function getData(): array { + $data = LoadPlayerPerformance::load($this->filters); + if ($data) { + $this->player = $data['player_name'] ?? ''; + } + return LoadPlayerPerformance::load($this->filters); } diff --git a/app/Filament/Widgets/ChartPlayerPerfMoAv.php b/app/Filament/Widgets/ChartPlayerPerfMoAv.php index 3ad045ed..5d419546 100644 --- a/app/Filament/Widgets/ChartPlayerPerfMoAv.php +++ b/app/Filament/Widgets/ChartPlayerPerfMoAv.php @@ -2,9 +2,11 @@ namespace App\Filament\Widgets; +use App\Filament\Widgets\Data\HelperMoveingAverage; use App\Filament\Widgets\Data\LoadPlayerPerformance; use Filament\Support\RawJs; use Filament\Widgets\ChartWidget; +use Illuminate\Support\HtmlString; use Livewire\Attributes\Reactive; class ChartPlayerPerfMoAv extends ChartWidget @@ -12,17 +14,50 @@ class ChartPlayerPerfMoAv extends ChartWidget #[Reactive] public ?array $filters = []; - protected ?string $heading = 'Player'; + public ?string $player = 'Player'; - protected ?string $description = 'Performance Moving Average'; + public ?string $type = ''; protected ?string $pollingInterval = null; - protected bool $isCollapsible = true; + protected bool $isCollapsible = false; + + public function getHeading(): HtmlString + { + return new HtmlString(' + + + + '.$this->player.' + + Performance Moving Average + + '); + } protected function getData(): array { - return LoadPlayerPerformance::load($this->filters); + $data = LoadPlayerPerformance::load($this->filters); + + if ($data) { + $this->player = $data['player_name'] ?? ''; + + HelperMoveingAverage::get($data); + } + + return $data; } protected function getType(): string diff --git a/app/Filament/Widgets/Data/LoadEvents.php b/app/Filament/Widgets/Data/LoadEvents.php index ef83f83d..e814c441 100644 --- a/app/Filament/Widgets/Data/LoadEvents.php +++ b/app/Filament/Widgets/Data/LoadEvents.php @@ -100,11 +100,11 @@ class LoadEvents }) ->pluck('match_id')->toArray(); - if (! $matches_played) { - return []; - } + $description = ' with '.StatistikoDetail::where('tm_player_id', (int) $tm_player_id)->value('name').' ('.\count($matches_played).')'; - $description = ' (with '.StatistikoDetail::where('tm_player_id', (int) $tm_player_id)->value('name').')'; + if (! $matches_played) { + $matches_played[] = -1; + } } /** diff --git a/app/Filament/Widgets/Data/LoadPlayerPerformance.php b/app/Filament/Widgets/Data/LoadPlayerPerformance.php index 8b75179e..a7617f31 100644 --- a/app/Filament/Widgets/Data/LoadPlayerPerformance.php +++ b/app/Filament/Widgets/Data/LoadPlayerPerformance.php @@ -2,6 +2,7 @@ namespace App\Filament\Widgets\Data; +use App\Models\StatistikoDetail; use App\Models\StatistikoPlayer; use Illuminate\Support\Carbon; @@ -35,6 +36,8 @@ class LoadPlayerPerformance return []; } + $player_name = StatistikoDetail::where('tm_player_id', (int) $tm_player_id)->value('name'); + if ($statistic_type == 'none') { $statistic_type = 'gls'; } @@ -52,9 +55,9 @@ class LoadPlayerPerformance $tmp = []; foreach ($matches_played as $value) { - $key = round($value->event->starttime->diffInDays(Carbon::now())); $val = $value->playerrating_value; - $tmp[$key] = $val; + $key = round($value->event->starttime->diffInDays(Carbon::now())); + $tmp["$key"] = $val; } ksort($tmp); @@ -77,6 +80,7 @@ class LoadPlayerPerformance ], ], 'labels' => $labels, + 'player_name' => $player_name, ]; self::$last_query = $data; diff --git a/app/Filament/Widgets/StatsMedianAverage.php b/app/Filament/Widgets/StatsMedianAverage.php index fa74b035..e1fafe82 100644 --- a/app/Filament/Widgets/StatsMedianAverage.php +++ b/app/Filament/Widgets/StatsMedianAverage.php @@ -30,19 +30,22 @@ class StatsMedianAverage extends StatsOverviewWidget // dd($data); $this->columns = [ - 'default' => 2, - 'sm' => 3, - 'xl' => ! isset($data['similar_past_matches']) || $data['similar_past_matches'] == 'none' ? 6 : 3, + 'default' => 1, + 'sm' => 2, + 'md' => 3, + 'md' => 6, ]; $statistic_type = ucfirst(HelperStatisticType::get($this->filters)); if (! isset($data['datasets'][0])) { - return []; + $data['datasets'][0]['data'] = []; + $data['datasets'][1]['data'] = []; + } else { + $arr_home = $data['datasets'][0]['data']; + $arr_away = $data['datasets'][1]['data']; } - $arr_home = $data['datasets'][0]['data']; - $arr_away = $data['datasets'][1]['data']; $total_home = count($arr_home); $total_away = count($arr_away); $summe_home = array_sum($arr_home); @@ -51,7 +54,42 @@ class StatsMedianAverage extends StatsOverviewWidget $away_team = $data['away_team']; if (! $total_home) { - return []; + return [ + Stat::make('stat1', 'stat1')->view('filament.resources.events.widgets.statistic-regular', [ + 'titel' => 'Number of events', + 'value' => '0', + 'hidden' => false, + ]), + Stat::make('stat2', 'stat2')->view('filament.resources.events.widgets.statistic-average', [ + 'titel' => 'Average '.$statistic_type, + 'value1' => 0, + 'value2' => 0, + 'home' => $home_team, + 'away' => $away_team, + ]), + Stat::make('stat3', 'stat3')->view('filament.resources.events.widgets.statistic-average', [ + 'titel' => 'Median '.$statistic_type, + 'value1' => 0, + 'value2' => 0, + 'home' => $home_team, + 'away' => $away_team, + ]), + Stat::make('stat4', 'stat4')->view('filament.resources.events.widgets.statistic-regular', [ + 'titel' => 'Win', + 'value' => 0, + 'hidden' => false, + ]), + Stat::make('stat5', 'stat5')->view('filament.resources.events.widgets.statistic-regular', [ + 'titel' => 'Draw', + 'value' => 0, + 'hidden' => false, + ]), + Stat::make('stat6', 'stat6')->view('filament.resources.events.widgets.statistic-regular', [ + 'titel' => 'Lost', + 'value' => 0, + 'hidden' => false, + ]), + ]; } // if (! $total_home || ! $total_away) { // return []; diff --git a/resources/views/filament/resources/events/widgets/statistic-average.blade.php b/resources/views/filament/resources/events/widgets/statistic-average.blade.php index 51b3d314..2b63f149 100644 --- a/resources/views/filament/resources/events/widgets/statistic-average.blade.php +++ b/resources/views/filament/resources/events/widgets/statistic-average.blade.php @@ -1,11 +1,12 @@ -