From 3fbfff888fadf8c7e72f97b6e622faf229bcdcef Mon Sep 17 00:00:00 2001 From: salam Date: Thu, 18 Jun 2026 17:57:22 +0200 Subject: [PATCH] wip --- app/Actions/Selections/LoadPlayer.php | 42 +++++++++++++++++++++++---- app/Filament/Pages/Statistic.php | 15 +++++----- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/app/Actions/Selections/LoadPlayer.php b/app/Actions/Selections/LoadPlayer.php index 52032365..b807e6f1 100644 --- a/app/Actions/Selections/LoadPlayer.php +++ b/app/Actions/Selections/LoadPlayer.php @@ -3,6 +3,7 @@ namespace App\Actions\Selections; use App\Models\StatistikoDetail; +use App\Models\StatistikoPlayer; class LoadPlayer { @@ -11,16 +12,47 @@ class LoadPlayer // $res = CompetitionGroup::with('country')->where('id', $league_id)->first(); // $season_mode = $res->country->season_mode; - $res = StatistikoDetail::where('txodds_id', $team_id)->get(); + $res_details = StatistikoDetail::where('txodds_id', $team_id)->get(); - if (! $res) { + if (! $res_details) { return []; } + $player_ids = []; + foreach ($res_details as $val) { + $player_ids[] = $val->tm_player_id; + } + $res_player = StatistikoPlayer::whereIn('tm_player_id', $player_ids) + ->where('minutes_played', '>', 0) + ->select('match_id','tm_player_id') + ->get(); + $counting = []; + foreach ($res_player as $val) { + $tm_player_id = $val->tm_player_id; + + if(!isset($counting[$tm_player_id])){ + $counting[$tm_player_id] = 1; + }else { + $counting[$tm_player_id]++; + } + } + $colorlevel = round(max($counting)/3); + $arr = []; - foreach ($res as $val) { - $arr[$val->position][$val->tm_player_id] = $val->name; + foreach ($res_details as $val) { + $tm_player_id = $val->tm_player_id; + $matches_played = isset($counting[$tm_player_id]) ? $counting[$tm_player_id] : 0; + if($matches_played < $colorlevel){ + $arr[$val->position][$val->tm_player_id] = ''.$val->name.' ('.$matches_played.')'; + } + else if($matches_played < $colorlevel*2){ + $arr[$val->position][$val->tm_player_id] = ''.$val->name.' ('.$matches_played.')'; + } + else { + $arr[$val->position][$val->tm_player_id] = ''.$val->name.' ('.$matches_played.')'; + } + } return $arr; } -} +} \ No newline at end of file diff --git a/app/Filament/Pages/Statistic.php b/app/Filament/Pages/Statistic.php index 77911ebd..5037197d 100644 --- a/app/Filament/Pages/Statistic.php +++ b/app/Filament/Pages/Statistic.php @@ -162,10 +162,10 @@ class Statistic extends BaseDashboard ->placeholder('Similar Past Matches') ->prefixIconColor('primary') ->suffix(fn(Get $get): string|HtmlString => $get('similar_past_matches') != 'none' ? new HtmlString('
± ' . $get('accuracy') . '
') : '') - ->columnSpan([ - 'default' => 1, - 'sm' => 2, - ]) + // ->columnSpan([ + // 'default' => 1, + // 'sm' => 2, + // ]) ->prefixAction( Action::make('iconInfo') ->icon('phosphor-question') @@ -180,9 +180,9 @@ class Statistic extends BaseDashboard $set('team_position', null); }) ->options([ - 'none' => 'Similar Past Matches: None', - 'league' => 'Similar Past Matches: League', - 'all' => 'Similar Past Matches: All Database', + 'none' => 'SPM: None', + 'league' => 'SPM: League', + 'all' => 'SPM: All Database', ]), Slider::make('accuracy') // ->label('Accuracy min: 0, max: 0.25, steps: 0.025') @@ -206,6 +206,7 @@ class Statistic extends BaseDashboard ->live(), Select::make('tm_player_id') ->hiddenLabel() + ->allowHtml() ->placeholder('Player') ->hidden(fn(Get $get) => $get('similar_past_matches') != 'none') ->prefixIconColor(fn(Get $get): string => $get('similar_past_matches') == 'none' ? 'primary' : '')