statistico players wip

This commit is contained in:
salam committed 2026-05-22 16:42:20 +02:00
1 parent 314ab7885b
commit 5010e7ac02
12 files changed
+75 -54

No files matched your search

+34 -9
View File
@@ -3,11 +3,11 @@
namespace App\Filament\Pages;
use App\Actions\LoadStatisticFixturesLeaguesOptions;
use App\Filament\Widgets\MedianAverage;
use App\Filament\Widgets\MovingAverageChart;
use App\Filament\Widgets\ChartMovingAverageEvent;
use App\Filament\Widgets\ChartPunctualEvent;
use App\Filament\Widgets\MovingAverageChartPlayer;
use App\Filament\Widgets\PunctualChart;
use App\Filament\Widgets\PunctualChartPlayer;
use App\Filament\Widgets\StatsMedianAverage;
use App\Models\Element;
use App\Models\StatisticFixtures;
use App\Models\StatistikoDetail;
@@ -32,6 +32,11 @@ class Statistic extends BaseDashboard
protected static ?string $title = 'Statistic';
protected int|string|array $columnSpan = [
'md' => 2,
'xl' => 3,
];
public function getHeading(): string|Htmlable|null
{
return '';
@@ -41,7 +46,12 @@ class Statistic extends BaseDashboard
{
return $schema
->components([
Grid::make()
Grid::make([
'default' => 2,
'sm' => 2,
'md' => 3,
'lg' => 4,
])
->schema([
Select::make('league_id')
->prefixIcon('phosphor-trophy')
@@ -106,7 +116,12 @@ class Statistic extends BaseDashboard
),
])->columns(5)
->columnSpanFull(),
Grid::make()
Grid::make([
'default' => 2,
'sm' => 2,
'md' => 3,
'lg' => 4,
])
->schema([
Select::make('tm_player_id')
->label('Player')
@@ -186,14 +201,24 @@ class Statistic extends BaseDashboard
]);
}
public function getFooterWidgetsColumns(): int|array
{
return [
'default' => 1,
'sm' => 2,
'lg' => 3,
'xl' => 4,
];
}
protected function getFooterWidgets(): array
{
return [
MedianAverage::make(),
PunctualChart::make(),
MovingAverageChart::make(),
StatsMedianAverage::make(),
ChartPunctualEvent::make(),
ChartMovingAverageEvent::make(),
PunctualChartPlayer::make(),
// MovingAverageChartPlayer::make(),
MovingAverageChartPlayer::make(),
];
}
@@ -2,13 +2,13 @@
namespace App\Filament\Widgets;
use App\Filament\Widgets\DB\LoadEvents;
use App\Filament\Widgets\DB\MoveingAverage;
use App\Filament\Widgets\DB\StatisticType;
use App\Filament\Widgets\Data\EventsLoad;
use App\Filament\Widgets\Data\HelperMoveingAverage;
use App\Filament\Widgets\Data\HelperStatisticType;
use Filament\Widgets\ChartWidget;
use Filament\Widgets\Concerns\InteractsWithPageFilters;
class MovingAverageChart extends ChartWidget
class ChartMovingAverageEvent extends ChartWidget
{
use InteractsWithPageFilters;
@@ -31,12 +31,12 @@ class MovingAverageChart extends ChartWidget
protected function getData(): array
{
$this->heading = StatisticType::get($this->filters);
$this->heading = HelperStatisticType::get($this->filters);
$data = LoadEvents::load($this->filters);
$data = EventsLoad::load($this->filters);
if ($data) {
MoveingAverage::get($data);
HelperMoveingAverage::get($data);
}
return $data;
@@ -2,12 +2,12 @@
namespace App\Filament\Widgets;
use App\Filament\Widgets\DB\LoadEvents;
use App\Filament\Widgets\DB\StatisticType;
use App\Filament\Widgets\Data\EventsLoad;
use App\Filament\Widgets\Data\HelperStatisticType;
use Filament\Widgets\ChartWidget;
use Filament\Widgets\Concerns\InteractsWithPageFilters;
class PunctualChart extends ChartWidget
class ChartPunctualEvent extends ChartWidget
{
use InteractsWithPageFilters;
@@ -30,9 +30,9 @@ class PunctualChart extends ChartWidget
protected function getData(): array
{
$this->heading = StatisticType::get($this->filters);
$this->heading = HelperStatisticType::get($this->filters);
$data = LoadEvents::load($this->filters);
$data = EventsLoad::load($this->filters);
return $data;
}
Whitespace-only changes.
@@ -1,12 +1,12 @@
<?php
namespace App\Filament\Widgets\DB;
namespace App\Filament\Widgets\Data;
use App\Models\StatisticFixtures;
use App\Models\StatistikoEvent;
use App\Models\StatistikoPlayer;
class LoadEvents
class EventsLoad
{
public static $last_query = [];
@@ -14,10 +14,6 @@ class LoadEvents
{
// dd($filter);
if (self::$last_query) {
return self::$last_query;
}
$league_id = (int) $filter['league_id'] ?? 0;
$team_id = (int) $filter['team_id'] ?? 0;
@@ -120,7 +116,6 @@ class LoadEvents
$datasets = [];
$labels = [];
$statistic_type = $filter['statistic_type'];
if (! $statistic_type || $statistic_type == 'none') {
$statistic_type = 'gls';
}
@@ -232,7 +227,6 @@ class LoadEvents
break;
}
}
$datasets[] = $val;
}
@@ -249,8 +243,6 @@ class LoadEvents
'labels' => $labels,
];
self::$last_query = $data;
return $data;
}
}
@@ -1,12 +1,12 @@
<?php
namespace App\Filament\Widgets\DB;
namespace App\Filament\Widgets\Data;
use App\Models\StatisticFixtures;
use App\Models\StatistikoEvent;
use App\Models\StatistikoPlayer;
class LoadEventsAspGoal
class EventsLoadAspGoal
{
public static function load($filter)
{
@@ -1,8 +1,8 @@
<?php
namespace App\Filament\Widgets\DB;
namespace App\Filament\Widgets\Data;
class MoveingAverage
class HelperMoveingAverage
{
public static function get(&$data)
{
@@ -1,8 +1,8 @@
<?php
namespace App\Filament\Widgets\DB;
namespace App\Filament\Widgets\Data;
class StatisticType
class HelperStatisticType
{
protected static array $types = [
'gls' => 'Goals',
@@ -1,10 +1,10 @@
<?php
namespace App\Filament\Widgets\DB;
namespace App\Filament\Widgets\Data;
use App\Models\StatistikoPlayer;
class LoadPunctualChartPlayer
class PlayerLoad
{
public static function load($filter)
{
@@ -83,8 +83,11 @@ class LoadPunctualChartPlayer
// $fields = 'goals,fouls,offsides,shots_on_target,shots_off_target, subtype_event_during_the_match';
$labels = [];
$datasets = [];
foreach ($res as $key => $value) {
$val = 0;
if (isset($value->event->starttime)) {
$labels[] = $value->event->starttime->format('d.M.y');
@@ -103,7 +106,7 @@ class LoadPunctualChartPlayer
$val = (int) $value['offsides'];
break;
case 'crd':
$val = (int) $value['crd_h'];
$val = (int) $value['card_yellow'] + $value['card_red'] + $value['card_yellowred'];
break;
case 'snt':
$val = (int) $value['shots_on_target'];
@@ -2,8 +2,9 @@
namespace App\Filament\Widgets;
use App\Actions\Statistics\LoadEvents;
use App\Actions\Statistics\StatisticType;
use App\Filament\Widgets\Data\HelperMoveingAverage;
use App\Filament\Widgets\Data\HelperStatisticType;
use App\Filament\Widgets\Data\PlayerLoad;
use Filament\Widgets\ChartWidget;
use Filament\Widgets\Concerns\InteractsWithPageFilters;
@@ -30,12 +31,12 @@ class MovingAverageChartPlayer extends ChartWidget
protected function getData(): array
{
$this->heading = StatisticType::get($this->filters);
$this->heading = HelperStatisticType::get($this->filters);
$data = LoadEvents::load($this->filters);
$data = PlayerLoad::load($this->filters);
if ($data) {
// MoveingAveragePlayer::get($data);
HelperMoveingAverage::get($data);
}
return $data;
+4 -4
View File
@@ -2,8 +2,8 @@
namespace App\Filament\Widgets;
use App\Filament\Widgets\DB\LoadPunctualChartPlayer;
use App\Filament\Widgets\DB\StatisticType;
use App\Filament\Widgets\Data\HelperStatisticType;
use App\Filament\Widgets\Data\PlayerLoad;
use Filament\Widgets\ChartWidget;
use Filament\Widgets\Concerns\InteractsWithPageFilters;
@@ -34,9 +34,9 @@ class PunctualChartPlayer extends ChartWidget
return [];
}
$this->heading = StatisticType::get($this->filters);
$this->heading = HelperStatisticType::get($this->filters);
$data = LoadPunctualChartPlayer::load($this->filters);
$data = PlayerLoad::load($this->filters);
return $data;
}
@@ -2,13 +2,13 @@
namespace App\Filament\Widgets;
use App\Filament\Widgets\DB\LoadEvents;
use App\Filament\Widgets\DB\LoadEventsAspGoal;
use App\Filament\Widgets\Data\EventsLoad;
use App\Filament\Widgets\Data\EventsLoadAspGoal;
use Filament\Widgets\Concerns\InteractsWithPageFilters;
use Filament\Widgets\StatsOverviewWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
class MedianAverage extends StatsOverviewWidget
class StatsMedianAverage extends StatsOverviewWidget
{
use InteractsWithPageFilters;
@@ -17,9 +17,9 @@ class MedianAverage extends StatsOverviewWidget
$filters = $this->filters;
if ($filters['similar_past_matches'] == 'none') {
$data = LoadEvents::load($filters);
$data = EventsLoad::load($filters);
} else {
$data = LoadEventsAspGoal::load($filters);
$data = EventsLoadAspGoal::load($filters);
}
if (! isset($data['datasets'][0])) {