From e19b5ab54b555ed76359b60f508996aec395ace9 Mon Sep 17 00:00:00 2001 From: salam Date: Tue, 15 Sep 2026 12:31:02 +0200 Subject: [PATCH] wip --- app/Filament/Widgets/PlayerPropsDrop.php | 71 ++++++++++--------- app/Livewire/PlayerCalculator.php | 7 +- app/Models/SofaScorePlayerPerSeason.php | 1 + app/Traits/UpdateHelper.php | 10 ++- ...te_sofa_score_player_per_seasons_table.php | 1 + 5 files changed, 50 insertions(+), 40 deletions(-) diff --git a/app/Filament/Widgets/PlayerPropsDrop.php b/app/Filament/Widgets/PlayerPropsDrop.php index c8a552e7..28a8feed 100644 --- a/app/Filament/Widgets/PlayerPropsDrop.php +++ b/app/Filament/Widgets/PlayerPropsDrop.php @@ -262,9 +262,9 @@ class PlayerPropsDrop extends Widget foreach ($this->calculationVariables as $row) { if ($copystring == '') { $keys = array_keys($row); - $copystring .= implode(';', $keys)."\n"; + $copystring .= implode(';', $keys) . "\n"; } - $copystring .= implode(';', $row)."\n"; + $copystring .= implode(';', $row) . "\n"; } $this->js("navigator.clipboard.writeText(`$copystring`)"); @@ -284,7 +284,7 @@ class PlayerPropsDrop extends Widget return; } $header = ['name', 'foot', 'events', 'average min', 'position', 'on field', 'gls', 'fls', 'ofs', 'snt', 'tsh', 'crd']; - $copystring = implode(';', $header)."\n"; + $copystring = implode(';', $header) . "\n"; foreach ($this->players as $row) { $tmp = []; $tmp[] = $row['name']; @@ -304,7 +304,7 @@ class PlayerPropsDrop extends Widget $tmp[] = $row['tsh']; $tmp[] = $row['crd']; - $copystring .= implode(';', $tmp)."\n"; + $copystring .= implode(';', $tmp) . "\n"; } $this->js("navigator.clipboard.writeText(`$copystring`)"); @@ -416,6 +416,11 @@ class PlayerPropsDrop extends Widget // Somma Minuti Giocati da Player (SMG) nel DB $tmp['somma_minuti'] = $val->total_min; + + $tmp['shots_on_target'] = $val->shots_on_target; + $tmp['shots_off_target'] = $val->shots_off_target; + $tmp['shots_blocked'] = $val->shots_blocked; + // il valore corrispondente al ruolo del Player (esempio un giocatore in Details ha ruolo = RW // quindi Aspettativa Statistica (AS) per RW = 0.219) // exp_goals @@ -430,68 +435,68 @@ class PlayerPropsDrop extends Widget $bettypes = ['goals', 'cards', 'fouls', 'offsides', 'total_shots', 'shots_on_target']; foreach ($bettypes as $bettype) { - $asp_statistica = (float) SofaScorePlayerPosition::where('ss_code', $position)->value('exp_'.$bettype); - $tmp['asp_statistica_'.$bettype] = $asp_statistica; + $asp_statistica = (float) SofaScorePlayerPosition::where('ss_code', $position)->value('exp_' . $bettype); + $tmp['asp_statistica_' . $bettype] = $asp_statistica; switch ($bettype) { case 'goals': if ($val->total_min < $this->y_value || $val->goals == 0) { - $tmp['asp_gioco_'.$bettype] = $asp_statistica; - $tmp['asp_teorica_'.$bettype] = $asp_statistica; + $tmp['asp_gioco_' . $bettype] = $asp_statistica; + $tmp['asp_teorica_' . $bettype] = $asp_statistica; } else { $asp_gioco = $val->goals / $val->total_min * 90; - $tmp['asp_gioco_'.$bettype] = $asp_gioco; - $tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); + $tmp['asp_gioco_' . $bettype] = $asp_gioco; + $tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); } break; case 'cards': if ($val->total_min < $this->y_value || $val->cards == 0) { - $tmp['asp_gioco_'.$bettype] = $asp_statistica; - $tmp['asp_teorica_'.$bettype] = $asp_statistica; + $tmp['asp_gioco_' . $bettype] = $asp_statistica; + $tmp['asp_teorica_' . $bettype] = $asp_statistica; } else { $asp_gioco = $val->cards / $val->total_min * 90; - $tmp['asp_gioco_'.$bettype] = $asp_gioco; - $tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); + $tmp['asp_gioco_' . $bettype] = $asp_gioco; + $tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); } break; case 'fouls': if ($val->total_min < $this->y_value || $val->fouls == 0) { - $tmp['asp_gioco_'.$bettype] = $asp_statistica; - $tmp['asp_teorica_'.$bettype] = $asp_statistica; + $tmp['asp_gioco_' . $bettype] = $asp_statistica; + $tmp['asp_teorica_' . $bettype] = $asp_statistica; } else { $asp_gioco = $val->fouls / $val->total_min * 90; - $tmp['asp_gioco_'.$bettype] = $asp_gioco; - $tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); + $tmp['asp_gioco_' . $bettype] = $asp_gioco; + $tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); } break; case 'offsides': if ($val->total_min < $this->y_value || $val->offsides == 0) { - $tmp['asp_gioco_'.$bettype] = $asp_statistica; - $tmp['asp_teorica_'.$bettype] = $asp_statistica; + $tmp['asp_gioco_' . $bettype] = $asp_statistica; + $tmp['asp_teorica_' . $bettype] = $asp_statistica; } else { $asp_gioco = $val->offsides / $val->total_min * 90; - $tmp['asp_gioco_'.$bettype] = $asp_gioco; - $tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); + $tmp['asp_gioco_' . $bettype] = $asp_gioco; + $tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); } break; case 'total_shots': if ($val->total_min < $this->y_value || $val->total_shots == 0) { - $tmp['asp_gioco_'.$bettype] = $asp_statistica; - $tmp['asp_teorica_'.$bettype] = $asp_statistica; + $tmp['asp_gioco_' . $bettype] = $asp_statistica; + $tmp['asp_teorica_' . $bettype] = $asp_statistica; } else { $asp_gioco = $val->total_shots / $val->total_min * 90; - $tmp['asp_gioco_'.$bettype] = $asp_gioco; - $tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); + $tmp['asp_gioco_' . $bettype] = $asp_gioco; + $tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); } break; case 'shots_on_target': if ($val->total_min < $this->y_value || $val->shots_on_target == 0) { - $tmp['asp_gioco_'.$bettype] = $asp_statistica; - $tmp['asp_teorica_'.$bettype] = $asp_statistica; + $tmp['asp_gioco_' . $bettype] = $asp_statistica; + $tmp['asp_teorica_' . $bettype] = $asp_statistica; } else { $asp_gioco = $val->shots_on_target / $val->total_min * 90; - $tmp['asp_gioco_'.$bettype] = $asp_gioco; - $tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); + $tmp['asp_gioco_' . $bettype] = $asp_gioco; + $tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); } break; } @@ -508,14 +513,14 @@ class PlayerPropsDrop extends Widget $bettypes = ['goals', 'cards', 'fouls', 'offsides', 'total_shots', 'shots_on_target']; foreach ($bettypes as $bettype) { - $total_bettype = array_sum(array_column($results, 'asp_teorica_'.$bettype)); + $total_bettype = array_sum(array_column($results, 'asp_teorica_' . $bettype)); foreach ($results as $key => $value) { // Aspettativa per Player: AP = AT * ATR / TOT AT - $results[$key]['asp_total_'.$bettype] = $total_bettype; + $results[$key]['asp_total_' . $bettype] = $total_bettype; // $results[$key]['asp_player_'.$bettype] = ((float) $value['asp_team'] * (float) $value['asp_teorica_'.$bettype]) / $total_bettype; // $results[$key]['asp_player_'.$bettype] = ($asp_team * $asp_team_riferimento) / $total_bettype; - $results[$key]['asp_player_'.$bettype] = ($value['asp_teorica_'.$bettype] * $asp_team_riferimento) / $total_bettype; + $results[$key]['asp_player_' . $bettype] = ($value['asp_teorica_' . $bettype] * $asp_team_riferimento) / $total_bettype; } } diff --git a/app/Livewire/PlayerCalculator.php b/app/Livewire/PlayerCalculator.php index 45b80b07..5d28de18 100644 --- a/app/Livewire/PlayerCalculator.php +++ b/app/Livewire/PlayerCalculator.php @@ -86,10 +86,9 @@ class PlayerCalculator extends Component // dd($result); - $pos = array_column($result, 'pos'); - $area = array_column($result, 'area'); - - array_multisort($area, SORT_ASC, $pos, SORT_ASC, $result); + // $pos = array_column($result, 'pos'); + // $area = array_column($result, 'area'); + // array_multisort($area, SORT_ASC, $pos, SORT_ASC, $result); return $result; } diff --git a/app/Models/SofaScorePlayerPerSeason.php b/app/Models/SofaScorePlayerPerSeason.php index 59f22f4f..2c398334 100644 --- a/app/Models/SofaScorePlayerPerSeason.php +++ b/app/Models/SofaScorePlayerPerSeason.php @@ -25,6 +25,7 @@ class SofaScorePlayerPerSeason extends Model 'offsides', 'shots_on_target', 'shots_off_target', + 'shots_blocked', 'total_shots', ]; diff --git a/app/Traits/UpdateHelper.php b/app/Traits/UpdateHelper.php index b6ba3d37..a042aa20 100644 --- a/app/Traits/UpdateHelper.php +++ b/app/Traits/UpdateHelper.php @@ -48,7 +48,7 @@ trait UpdateHelper try { $this->updatePlayers($playerCount); } catch (\Exception $e) { - $this->error(get_class($e).' '.Str::of($e->getMessage())->limit(100)->value()); + $this->error(get_class($e) . ' ' . Str::of($e->getMessage())->limit(100)->value()); } if ($this->debug) { @@ -97,8 +97,8 @@ trait UpdateHelper $formattedTime = match (true) { $executionTime >= 60 => sprintf('%dm %ds', floor($executionTime / 60), $executionTime % 60), - $executionTime >= 1 => round($executionTime, 2).'s', - default => round($executionTime * 1000).'ms', + $executionTime >= 1 => round($executionTime, 2) . 's', + default => round($executionTime * 1000) . 'ms', }; $this->newLine(); @@ -169,6 +169,7 @@ trait UpdateHelper $collection[$season][$ss_player_id]['offsides'] += $val->offsides; $collection[$season][$ss_player_id]['shots_on_target'] += $val->shots_on_target; $collection[$season][$ss_player_id]['shots_off_target'] += $val->shots_off_target; + $collection[$season][$ss_player_id]['shots_blocked'] += $val->shots_blocked; $collection[$season][$ss_player_id]['total_shots'] += $val->shots_off_target + $val->shots_off_target + $val->shots_blocked; $collection['total'][$ss_player_id]['ss_player_id'] = $ss_player_id; @@ -183,6 +184,7 @@ trait UpdateHelper $collection['total'][$ss_player_id]['offsides'] += $val->offsides; $collection['total'][$ss_player_id]['shots_on_target'] += $val->shots_on_target; $collection['total'][$ss_player_id]['shots_off_target'] += $val->shots_off_target; + $collection['total'][$ss_player_id]['shots_blocked'] += $val->shots_blocked; $collection['total'][$ss_player_id]['total_shots'] += $val->shots_off_target + $val->shots_off_target + $val->shots_blocked; } } @@ -215,6 +217,7 @@ trait UpdateHelper 'offsides', 'shots_on_target', 'shots_off_target', + 'shots_blocked', 'total_shots', 'cards', ] @@ -239,6 +242,7 @@ trait UpdateHelper $collection[$season][$ss_player_id]['offsides'] = 0; $collection[$season][$ss_player_id]['shots_on_target'] = 0; $collection[$season][$ss_player_id]['shots_off_target'] = 0; + $collection[$season][$ss_player_id]['shots_blocked'] = 0; $collection[$season][$ss_player_id]['total_shots'] = 0; $collection[$season][$ss_player_id]['cards'] = 0; } diff --git a/database/migrations/2026_06_27_091506_create_sofa_score_player_per_seasons_table.php b/database/migrations/2026_06_27_091506_create_sofa_score_player_per_seasons_table.php index bffb15d7..fbb49ba9 100644 --- a/database/migrations/2026_06_27_091506_create_sofa_score_player_per_seasons_table.php +++ b/database/migrations/2026_06_27_091506_create_sofa_score_player_per_seasons_table.php @@ -29,6 +29,7 @@ return new class extends Migration $table->integer('offsides')->default(0)->nullable(); $table->integer('shots_on_target')->default(0)->nullable(); $table->integer('shots_off_target')->default(0)->nullable(); + $table->integer('shots_blocked')->default(0)->nullable(); $table->integer('total_shots')->default(0)->nullable(); $table->unique(['ss_player_id', 'ss_team_id', 'season']); $table->timestamps();