diff --git a/app/Actions/Selections/LoadPlayer.php b/app/Actions/Selections/LoadPlayer.php index 8cb8218e..eb04c03a 100644 --- a/app/Actions/Selections/LoadPlayer.php +++ b/app/Actions/Selections/LoadPlayer.php @@ -40,21 +40,24 @@ class LoadPlayer if (! $counting) { return []; } - + $colorlevel = round(max($counting)/3); $arr = []; foreach ($res_details as $val) { + $tm_player_id = $val->tm_player_id; + $position = strtoupper($val->position); + $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.')'; + $arr[$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.')'; + $arr[$position][$val->tm_player_id] = ''.$val->name.' ('.$matches_played.')'; } else { - $arr[$val->position][$val->tm_player_id] = ''.$val->name.' ('.$matches_played.')'; + $arr[$position][$val->tm_player_id] = ''.$val->name.' ('.$matches_played.')'; } } diff --git a/app/Filament/Pages/Statistic.php b/app/Filament/Pages/Statistic.php index cf0d056e..49f09aa8 100644 --- a/app/Filament/Pages/Statistic.php +++ b/app/Filament/Pages/Statistic.php @@ -108,14 +108,13 @@ class Statistic extends BaseDashboard ->hidden(fn(Get $get) => $get('similar_past_matches') != 'none') ->options(function (Get $get) { if ($get('match_id')) { - $res = StatisticFixtures::where('id', $get('match_id'))->get(); + $res = StatisticFixtures::where('id', $get('match_id'))->first(); + $arr = []; - foreach ($res as $value) { - $arr[] = $value->home_id; - $arr[] = $value->away_id; - } + $arr[$res->home_id] = Element::query()->where('id', $res->home_id)->value('name'); + $arr[$res->away_id] = Element::query()->where('id', $res->away_id)->value('name'); - return Element::query()->whereIn('id', $arr)->pluck('name', 'id'); + return $arr; } }) ->afterStateUpdated(function (callable $set) {