wip average all bettype in boxes

This commit is contained in:
salam committed 2026-09-25 09:51:50 +02:00
1 parent 1a46e5d887
commit fe4fa6e9cf
16 files changed
+1010 -135

No files matched your search

@@ -6,18 +6,19 @@ use Illuminate\Support\Carbon;
class GetSeason
{
public static function load(array|null $season, string|null $seasonmode)
public static function load(?array $season, ?string $seasonmode)
{
if (!\is_array($season) || !\count($season)) {
if (! \is_array($season) || ! \count($season)) {
$date = Carbon::now();
$season = [];
if ($seasonmode == 'halfyear') {
if ((int) date('m') > 7)
$season[] = (string) $date->format('y') . '/' . $date->format('y') + 1;
else
$season[] = (string) $date->format('y') - 1 . '/' . $date->format('y');
if ((int) date('m') > 7) {
$season[] = (string) $date->format('y').'/'.$date->format('y') + 1;
} else {
$season[] = (string) $date->format('y') - 1 .'/'.$date->format('y');
}
} else {
$season[] = (string) $date->year;
}
@@ -25,4 +26,23 @@ class GetSeason
return $season;
}
public static function active(?string $seasonmode)
{
$date = Carbon::now();
$active_season = '';
if ($seasonmode == 'halfyear') {
if ((int) date('m') > 7) {
$active_season = (string) $date->format('y').'/'.$date->format('y') + 1;
} else {
$active_season = (string) $date->format('y') - 1 .'/'.$date->format('y');
}
} else {
$active_season = (string) $date->year;
}
return $active_season;
}
}
@@ -3,7 +3,6 @@
namespace App\Filament\Pages\Selections;
use App\Filament\Pages\Selections\Helper\GetSeason;
use App\Models\SofaScorePlayerCache;
use App\Models\SofaScorePlayerPerSeason;
use App\Models\StatistikoEvent;
@@ -13,11 +12,11 @@ class LoadPlayerSelection
{
$season = GetSeason::load($season, $seasonmode);
$hash = hash('crc32', $team_id.$team_position.$sofascore_category_id.serialize($season));
$cached_players = SofaScorePlayerCache::where('hash', $hash)->value('players');
if ($cached_players) {
return $cached_players;
}
// $hash = hash('crc32', $team_id.$team_position.$sofascore_category_id.serialize($season));
// $cached_players = SofaScorePlayerCache::where('hash', $hash)->value('players');
// if ($cached_players) {
// return $cached_players;
// }
$matches = StatistikoEvent::whereIn('season', $season)
->where(function ($query) use ($team_id, $team_position) {
@@ -92,25 +91,28 @@ class LoadPlayerSelection
$position = 'NO SPECIFIC POSITION';
}
$infostring = $events_played.' Ev';
if ($val['preferred_foot']) {
$infostring .= ' - '.$val['preferred_foot'];
}
if ($events_played) {
$infostring .= ' - '.round($minues_played / $events_played).'min';
}
$infostring = '';
if ($colorlevel > 1 && $events_played < $colorlevel) {
$result[$position][$player_id] = '<span class="text-red-600 dark:text-red-500 cursor-pointer"><b>'.$val['player_name'].'</b> '.$position.'<br>'.$infostring.'</span>';
$infostring = '<div class="w-full text-red-600 dark:text-red-500 cursor-pointer flex flex-row gap-3">';
} elseif ($events_played < $colorlevel * 2) {
$result[$position][$player_id] = '<span class="text-blue-600 dark:text-blue-500 cursor-pointer"><b>'.$val['player_name'].'</b> '.$position.'<br>'.$infostring.'</span>';
$infostring = '<div class="w-full text-blue-600 dark:text-blue-500 cursor-pointer flex flex-row gap-3">';
} else {
$result[$position][$player_id] = '<span class="text-green-600 dark:text-green-500 cursor-pointer"><b>'.$val['player_name'].'</b> '.$position.'<br>'.$infostring.'</span>';
$infostring = '<div class="w-full text-green-600 dark:text-green-500 cursor-pointer flex flex-row gap-3">';
}
$infostring .= '<div class="flex-1 font-bold">'.$val['player_name'].' '.$val['player_position'].'</div>';
$infostring .= '<div>'.$events_played.' Events,</div>';
$infostring .= '<div>'.$val['preferred_foot'].' foot,</div>';
if ($events_played) {
$infostring .= '<div>Av. on field '.round($minues_played / $events_played).'min</div>';
}
$infostring .= '</div>';
$result[$position][$player_id] = $infostring;
}
if ($result) {
SofaScorePlayerCache::updateOrCreate(['hash' => $hash], ['players' => $result]);
}
// if ($result) {
// SofaScorePlayerCache::updateOrCreate(['hash' => $hash], ['players' => $result]);
// }
return $result;
}
+97 -87
View File
@@ -22,9 +22,9 @@ use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
use Filament\Schemas\Components\Grid;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Components\Utilities\Set;
use Filament\Schemas\Schema;
// use Filament\Support\Enums\SlideOverPosition;
// use Filament\Support\Enums\Width;
use Filament\Schemas\Schema;
use Filament\Support\RawJs;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Contracts\View\View;
@@ -181,6 +181,14 @@ class Statistic extends BaseDashboard
$this->dispatch('reset-tab');
})
->placeholder('Select Event'),
Action::make('esc')
->hiddenLabel()
->visible(fn (Get $get) => $get('similar_past_matches') != 'none')
->tooltip('Clear all (esc)')
->icon('phosphor-x-circle')
->color('gray')
->keyBindings(['esc'])
->action('resetFilters'),
Select::make('team_id')
->live()
@@ -240,7 +248,7 @@ class Statistic extends BaseDashboard
Grid::make([
'default' => 1,
'sm' => 3,
'md' => 4,
'md' => 5,
])
->columnSpanFull()
->schema([
@@ -332,7 +340,9 @@ class Statistic extends BaseDashboard
->live()
->hiddenLabel()
->allowHtml()
->columnSpan(2)
->placeholder('Player')
->visible(fn (Get $get) => $get('team_id'))
->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
->prefixIconColor(fn (Get $get): string => $get('similar_past_matches') == 'none' ? 'success' : '')
->prefixIcon('icon-player')
@@ -371,9 +381,10 @@ class Statistic extends BaseDashboard
]),
]),
Grid::make([
'default' => 4,
'sm' => 4,
'default' => 7,
'sm' => 7,
])
->columnSpanFull()
->schema([
Radio::make('season_or_date')
->live()
@@ -381,10 +392,7 @@ class Statistic extends BaseDashboard
'class' => 'radio-statistic-group',
])
->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
->columnSpan([
'default' => 4,
'sm' => 4,
])
->columnSpan(2)
->inline()
->default('season')
->hiddenLabel()
@@ -392,86 +400,88 @@ class Statistic extends BaseDashboard
'season' => 'Season',
'date' => 'Date',
]),
/************************
* SEASON full time
************************/
Select::make('season')
->live()
->columnSpan(2)
->hiddenLabel()
->multiple()
->placeholder('Current Season')
->prefixIconColor('success')
->visible(fn (Get $get) => $get('seasonmode'))
->hidden(fn (Get $get) => $get('seasonmode') == 'halfyear' || $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
->prefixIcon('phosphor-calendar-star-fill')
->options([
'2026' => '2026',
'2025' => '2025',
'2024' => '2024',
])
->afterStateUpdated(function (callable $set, Get $get) {
$set('ss_player_id', null);
}),
/************************
* SEASON half time
************************/
Select::make('season')
->live()
->columnSpan(2)
->hiddenLabel()
->multiple()
->placeholder('Current Season')
->prefixIconColor('success')
->visible(fn (Get $get) => $get('seasonmode'))
->hidden(fn (Get $get) => $get('seasonmode') == 'fullyear' || $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
->prefixIcon('phosphor-calendar-star-fill')
->options([
'26/27' => '26/27',
'25/26' => '25/26',
'24/25' => '24/25',
])
->afterStateUpdated(function (callable $set) {
$set('ss_player_id', null);
}),
/************************
* DATE PICKER
************************/
DatePicker::make('start_date')
->live()
->hiddenLabel()
->hidden(fn (Get $get) => $get('season_or_date') == 'season')
->native(false)
->prefixIconColor(fn (Get $get): string => $get('start_date') ? 'success' : 'primary')
->prefixIcon('phosphor-calendar-fill')
->prefix('Start')
->suffixAction(
Action::make('clear_start')
->icon('phosphor-x')
->color('gray')
->action(fn (Set $set) => $set('start_date', null))
),
DatePicker::make('end_date')
->live()
->hiddenLabel()
->hidden(fn (Get $get) => $get('season_or_date') == 'season')
->native(false)
->prefixIconColor(fn (Get $get): string => $get('end_date') ? 'success' : 'primary')
->prefixIcon('phosphor-calendar-fill')
->prefix('End')
->suffixAction(
Action::make('clear_end')
->icon('phosphor-x')
->color('gray')
->action(fn (Set $set) => $set('end_date', null))
),
Action::make('esc')
->hiddenLabel()
->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
->tooltip('Clear all (esc)')
->icon('phosphor-x-circle')
->color('gray')
->keyBindings(['esc'])
->action('resetFilters'),
]),
/************************
* SEASON fulltime
************************/
Select::make('season')
->live()
->columns(2)
->hiddenLabel()
->multiple()
->placeholder('Current Season')
->prefixIconColor('success')
->hidden(fn (Get $get) => $get('seasonmode') == 'halfyear' || $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
->prefixIcon('phosphor-calendar-star-fill')
->options([
'2026' => '2026',
'2025' => '2025',
'2024' => '2024',
])
->afterStateUpdated(function (callable $set, Get $get) {
$set('ss_player_id', null);
}),
/************************
* SEASON halftime
************************/
Select::make('season')
->live()
->columns(2)
->hiddenLabel()
->multiple()
->placeholder('Current Season')
->prefixIconColor('success')
->hidden(fn (Get $get) => $get('seasonmode') == 'fullyear' || $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
->prefixIcon('phosphor-calendar-star-fill')
->options([
'26/27' => '26/27',
'25/26' => '25/26',
'24/25' => '24/25',
])
->afterStateUpdated(function (callable $set) {
$set('ss_player_id', null);
}),
/************************
* DATE PICKER
************************/
DatePicker::make('start_date')
->live()
->hiddenLabel()
->hidden(fn (Get $get) => $get('season_or_date') == 'season')
->native(false)
->prefixIconColor(fn (Get $get): string => $get('start_date') ? 'success' : 'primary')
->prefixIcon('phosphor-calendar-fill')
->prefix('Start')
->suffixAction(
Action::make('clear_start')
->icon('phosphor-x')
->color('gray')
->action(fn (Set $set) => $set('start_date', null))
),
DatePicker::make('end_date')
->live()
->hiddenLabel()
->hidden(fn (Get $get) => $get('season_or_date') == 'season')
->native(false)
->prefixIconColor(fn (Get $get): string => $get('end_date') ? 'success' : 'primary')
->prefixIcon('phosphor-calendar-fill')
->prefix('End')
->suffixAction(
Action::make('clear_end')
->icon('phosphor-x')
->color('gray')
->action(fn (Set $set) => $set('end_date', null))
),
Action::make('esc')
->hiddenLabel()
->tooltip('Clear all (esc)')
->icon('phosphor-x-circle')
->color('gray')
->keyBindings(['esc'])
->action('resetFilters'),
]);
}