This commit is contained in:
salam committed 2026-06-18 17:57:22 +02:00
1 parent 5cf6ec20dc
commit 3fbfff888f
2 files changed
+44 -11

No files matched your search

+36 -4
View File
@@ -3,6 +3,7 @@
namespace App\Actions\Selections; namespace App\Actions\Selections;
use App\Models\StatistikoDetail; use App\Models\StatistikoDetail;
use App\Models\StatistikoPlayer;
class LoadPlayer class LoadPlayer
{ {
@@ -11,15 +12,46 @@ class LoadPlayer
// $res = CompetitionGroup::with('country')->where('id', $league_id)->first(); // $res = CompetitionGroup::with('country')->where('id', $league_id)->first();
// $season_mode = $res->country->season_mode; // $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 []; 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 = []; $arr = [];
foreach ($res as $val) { foreach ($res_details as $val) {
$arr[$val->position][$val->tm_player_id] = $val->name; $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] = '<span class="text-gray-500">'.$val->name.' ('.$matches_played.')</span>';
}
else if($matches_played < $colorlevel*2){
$arr[$val->position][$val->tm_player_id] = '<span class="text-blue-500">'.$val->name.' ('.$matches_played.')</span>';
}
else {
$arr[$val->position][$val->tm_player_id] = '<span class="text-green-500">'.$val->name.' ('.$matches_played.')</span>';
}
} }
return $arr; return $arr;
} }
+8 -7
View File
@@ -162,10 +162,10 @@ class Statistic extends BaseDashboard
->placeholder('Similar Past Matches') ->placeholder('Similar Past Matches')
->prefixIconColor('primary') ->prefixIconColor('primary')
->suffix(fn(Get $get): string|HtmlString => $get('similar_past_matches') != 'none' ? new HtmlString('<div class="text-center w-24 font-bold rounded p-1 bg-blue-600 dark:bg-blue-700 text-white dark:text-gray-300">± ' . $get('accuracy') . '</div>') : '') ->suffix(fn(Get $get): string|HtmlString => $get('similar_past_matches') != 'none' ? new HtmlString('<div class="text-center w-24 font-bold rounded p-1 bg-blue-600 dark:bg-blue-700 text-white dark:text-gray-300">± ' . $get('accuracy') . '</div>') : '')
->columnSpan([ // ->columnSpan([
'default' => 1, // 'default' => 1,
'sm' => 2, // 'sm' => 2,
]) // ])
->prefixAction( ->prefixAction(
Action::make('iconInfo') Action::make('iconInfo')
->icon('phosphor-question') ->icon('phosphor-question')
@@ -180,9 +180,9 @@ class Statistic extends BaseDashboard
$set('team_position', null); $set('team_position', null);
}) })
->options([ ->options([
'none' => 'Similar Past Matches: None', 'none' => 'SPM: None',
'league' => 'Similar Past Matches: League', 'league' => 'SPM: League',
'all' => 'Similar Past Matches: All Database', 'all' => 'SPM: All Database',
]), ]),
Slider::make('accuracy') Slider::make('accuracy')
// ->label('Accuracy min: 0, max: 0.25, steps: 0.025') // ->label('Accuracy min: 0, max: 0.25, steps: 0.025')
@@ -206,6 +206,7 @@ class Statistic extends BaseDashboard
->live(), ->live(),
Select::make('tm_player_id') Select::make('tm_player_id')
->hiddenLabel() ->hiddenLabel()
->allowHtml()
->placeholder('Player') ->placeholder('Player')
->hidden(fn(Get $get) => $get('similar_past_matches') != 'none') ->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
->prefixIconColor(fn(Get $get): string => $get('similar_past_matches') == 'none' ? 'primary' : '') ->prefixIconColor(fn(Get $get): string => $get('similar_past_matches') == 'none' ? 'primary' : '')