This commit is contained in:
salam committed 2026-06-05 12:34:24 +02:00
1 parent d954a9fa5c
commit 4b4952bfec
16 files changed
+251 -340

No files matched your search

+1 -20
View File
@@ -50,24 +50,6 @@ class Statistic extends BaseDashboard
return '';
}
public function updatedFilter($value) // Or whatever your property name is
{
$this->dispatch('filterChanged', filterValue: $value);
}
// protected function getHeaderActions(): array
// {
// return [
// Action::make('collapseAll')
// ->label('Collapse All Charts')
// ->icon('heroicon-m-chevron-up')
// ->color('gray')
// ->action(function ($record, $livewire) {
// $livewire->dispatch('collapse-all-charts');
// }),
// ];
// }
public function filtersForm(Schema $schema): Schema
{
return $schema
@@ -94,7 +76,6 @@ class Statistic extends BaseDashboard
$set('match_id', null);
$set('team_id', null);
$set('tm_player_id', null);
$this->dispatch('filterChanged', filterValue: $state);
}),
Select::make('match_id')
->hiddenLabel()
@@ -198,7 +179,7 @@ class Statistic extends BaseDashboard
'ofs' => 'Offside',
'crd' => 'Cards',
'snt' => 'Shots On Target',
'tsh' => 'Total shots',
'tsh' => 'Total Shots',
]),
Select::make('similar_past_matches')
->hiddenLabel()
@@ -7,11 +7,11 @@ class HelperStatisticType
protected static array $types = [
'gls' => 'Goals',
'crn' => 'Corner',
'fls' => 'Fouls Commited',
'fls' => 'Fouls',
'ofs' => 'Offside',
'crd' => 'Cards',
'snt' => 'Shots On Target',
'tsh' => 'Total shots',
'snt' => 'S on T',
'tsh' => 'Shots',
];
public static function get($filter): string
@@ -228,6 +228,10 @@ class LoadPerformance
public static function shortenEnding(array &$labels, array &$homes, array &$aways)
{
if (! isset($homes['all'])) {
return;
}
$count_home = 0;
$count_away = 0;
for ($i = \count($homes['all']) - 1; $i > 0; $i--) {
+29 -61
View File
@@ -7,6 +7,7 @@ use App\Filament\Widgets\Data\LoadEvents;
use App\Utilities\Round;
use Filament\Widgets\StatsOverviewWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
use Illuminate\Support\HtmlString;
use Livewire\Attributes\Reactive;
class StatsMedianAverage extends StatsOverviewWidget
@@ -18,6 +19,8 @@ class StatsMedianAverage extends StatsOverviewWidget
#[Reactive]
public ?array $filters = [];
public ?int $count;
public function mount(array $filters)
{
$this->filters = $filters;
@@ -36,7 +39,7 @@ class StatsMedianAverage extends StatsOverviewWidget
'lg' => 6,
];
$statistic_type = ucfirst(HelperStatisticType::get($this->filters));
$statistic_type = HelperStatisticType::get($this->filters);
if (! isset($data['datasets'][0])) {
$data['datasets'][0]['data'] = [];
@@ -60,36 +63,12 @@ class StatsMedianAverage extends StatsOverviewWidget
if (! $total_home) {
return [
Stat::make('stat1', 'stat1')->view('filament.resources.events.widgets.statistic-regular', [
'titel' => 'Number of events',
'value' => '0',
]),
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,
]),
Stat::make('stat5', 'stat5')->view('filament.resources.events.widgets.statistic-regular', [
'titel' => 'Draw',
'value' => 0,
]),
Stat::make('stat6', 'stat6')->view('filament.resources.events.widgets.statistic-regular', [
'titel' => 'Lost',
'value' => 0,
]),
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),
];
}
@@ -119,37 +98,26 @@ class StatsMedianAverage extends StatsOverviewWidget
$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;
$value_home = number_format($summe_home / $total_home, 1);
$value_away = number_format($summe_away / $total_away, 1);
return [
Stat::make('stat1', 'stat1')->view('filament.resources.events.widgets.statistic-regular', [
'titel' => 'Number of events',
'value' => $total_home,
]),
Stat::make('stat2', 'stat2')->view('filament.resources.events.widgets.statistic-average', [
'titel' => 'Average '.$statistic_type,
'value1' => number_format($summe_home / $total_home, 1),
'value2' => number_format($summe_away / $total_away, 1),
'home' => $home_team,
'away' => $away_team,
]),
Stat::make('stat3', 'stat3')->view('filament.resources.events.widgets.statistic-average', [
'titel' => 'Median '.$statistic_type,
'value1' => $median_home,
'value2' => $median_away,
'home' => $home_team,
'away' => $away_team,
]),
Stat::make('stat4', 'stat4')->view('filament.resources.events.widgets.statistic-regular', [
'titel' => ($data['similar_past_matches'] != 'none') ? 'Win' : 'Win: '.$data['results']['w'],
'value' => $win,
]),
Stat::make('stat5', 'stat5')->view('filament.resources.events.widgets.statistic-regular', [
'titel' => ($data['similar_past_matches'] != 'none') ? 'Draw' : 'Draw: '.$data['results']['d'],
'value' => $draw,
]),
Stat::make('stat6', 'stat6')->view('filament.resources.events.widgets.statistic-regular', [
'titel' => ($data['similar_past_matches'] != 'none') ? 'Lost' : 'Lost: '.$data['results']['l'],
'value' => $lost,
]),
Stat::make('Number of events', new HtmlString('<div id="number-of-events">'.$total_home.'</div>'))->extraAttributes(['x-init' => "animate('number-of-events', $total_home)"]),
Stat::make('Average '.$statistic_type, self::template('avhome', 'avaway', $home_team, $away_team))->extraAttributes(['x-init' => "animate('avhome', $value_home); animate('avaway', $value_away)"]),
Stat::make('Median '.$statistic_type, self::template('mehome', 'meaway', $home_team, $away_team))->extraAttributes(['x-init' => "animate('mehome', $median_home); animate('meaway', $median_away)"]),
Stat::make($data['similar_past_matches'] != 'none' ? 'Win' : 'Win: '.$data['results']['w'], new HtmlString('<div id="number-of-win">'.$win.'</div>'))->extraAttributes(['x-init' => "animate('number-of-win', $win)"]),
Stat::make($data['similar_past_matches'] != 'none' ? 'Draw' : 'Draw: '.$data['results']['d'], new HtmlString('<div id="number-of-draw">'.$draw.'</div>'))->extraAttributes(['x-init' => "animate('number-of-draw', $draw)"]),
Stat::make($data['similar_past_matches'] != 'none' ? 'Lost' : 'Lost: '.$data['results']['l'], new HtmlString('<div id="number-of-lost">'.$lost.'</div>'))->extraAttributes(['x-init' => "animate('number-of-lost', $lost)"]),
];
}
protected function template(string $home_id, string $away_id, string $home_name, string $away_name): HtmlString
{
return new HtmlString('<div class="grid grid-cols-2 justify-center font-bold text-4xl">
<span class="text-center" id="'.$home_id.'"></span>
<span class="text-center" id="'.$away_id.'"></span>
<span class="text-center text-xs text-gray-500 dark:text-gray-400">'.$home_name.'</span>
<span class="text-center text-xs text-gray-500 dark:text-gray-400">'.$away_name.'</span>
</div>');
}
}
+2
View File
@@ -5,6 +5,7 @@ namespace App\Providers;
use App\Filament\Resources\Events\Pages\ListEvents;
use Carbon\Carbon;
use Filament\Support\Assets\Css;
use Filament\Support\Assets\Js;
use Filament\Support\Colors\Color;
use Filament\Support\Facades\FilamentAsset;
use Filament\Support\Facades\FilamentColor;
@@ -35,6 +36,7 @@ class AppServiceProvider extends ServiceProvider
FilamentAsset::register([
Css::make('font-stylesheet', __DIR__.'/../../resources/css/font.css'),
Js::make('number-animator', __DIR__.'/../../resources/js/number-animator.js'),
]);
FilamentView::registerRenderHook(