From e0c1baf8499773d89d817ad18d3b4a0ffa6cdd4b Mon Sep 17 00:00:00 2001 From: salam Date: Sun, 11 Oct 2026 19:12:25 +0200 Subject: [PATCH] wip pp --- .../Pages/Selections/LoadPlayerSelection.php | 7 ++++--- app/Filament/Widgets/PlayerProps/BoxNames.php | 4 ++-- app/Filament/Widgets/PlayerPropsDrop.php | 18 ++++++++++++------ app/Livewire/Mapper/LoadGridPositions.php | 8 ++++---- app/Livewire/PlayerCalculator.php | 7 +++++-- app/Traits/UpdateHelper.php | 10 +++++----- 6 files changed, 32 insertions(+), 22 deletions(-) diff --git a/app/Filament/Pages/Selections/LoadPlayerSelection.php b/app/Filament/Pages/Selections/LoadPlayerSelection.php index c7adaab3..fa65579c 100644 --- a/app/Filament/Pages/Selections/LoadPlayerSelection.php +++ b/app/Filament/Pages/Selections/LoadPlayerSelection.php @@ -4,6 +4,7 @@ namespace App\Filament\Pages\Selections; use App\Filament\Pages\Selections\Helper\GetSeason; use App\Models\SofaScorePlayerPerSeason; +use App\Models\StatistikoDetail; use App\Models\StatistikoEvent; class LoadPlayerSelection @@ -35,12 +36,12 @@ class LoadPlayerSelection $positions_map = LoadPositions::load(); - $player = SofaScorePlayerPerSeason::with('details')->where('ss_team_id', $team_id)->whereIn('season', $season)->get(); + $team_player_ids = StatistikoDetail::where('ss_team_id', $team_id)->pluck('ss_player_id')->toArray(); - // dd($player); + $players = SofaScorePlayerPerSeason::with('details')->where('season', $season)->whereIn('ss_player_id', $team_player_ids)->get(); $arr = []; - foreach ($player as $val) { + foreach ($players as $val) { if ($val->details) { $player_id = $val->ss_player_id; if (! isset($arr[$player_id])) { diff --git a/app/Filament/Widgets/PlayerProps/BoxNames.php b/app/Filament/Widgets/PlayerProps/BoxNames.php index dbc29361..92d8e99d 100644 --- a/app/Filament/Widgets/PlayerProps/BoxNames.php +++ b/app/Filament/Widgets/PlayerProps/BoxNames.php @@ -8,7 +8,7 @@ class BoxNames { return [ 2 => 'DL', - 4 => 'MR', + 4 => 'ML', 6 => 'LW', 9 => 'DC', 10 => 'DM', @@ -26,7 +26,7 @@ class BoxNames 25 => 'MC', 26 => 'AM', 30 => 'DR', - 32 => 'ML', + 32 => 'MR', 34 => 'RW', ]; } diff --git a/app/Filament/Widgets/PlayerPropsDrop.php b/app/Filament/Widgets/PlayerPropsDrop.php index 2bf6b917..c141d706 100644 --- a/app/Filament/Widgets/PlayerPropsDrop.php +++ b/app/Filament/Widgets/PlayerPropsDrop.php @@ -13,6 +13,7 @@ use App\Models\SofaScorePlayerPosition; use App\Models\SofaScoreRosa; use App\Models\SsLineupMemory; use App\Models\StatisticFixtures; +use App\Models\StatistikoDetail; use Filament\Notifications\Notification; use Filament\Widgets\Widget; use Illuminate\Support\Collection; @@ -390,7 +391,9 @@ class PlayerPropsDrop extends Widget $team_home_away = 'away'; } - $player_totals = SofaScorePlayerPerSeason::with('details')->where('total_min', '>', 0)->where('season', 'total')->where('ss_team_id', $team_id)->get(); + $team_player_ids = StatistikoDetail::where('ss_team_id', $team_id)->pluck('ss_player_id')->toArray(); + + $player_totals = SofaScorePlayerPerSeason::with('details')->where('season', 'total')->whereIn('ss_player_id', $team_player_ids)->get(); $count_player = 0; $tmp = []; @@ -682,7 +685,9 @@ class PlayerPropsDrop extends Widget public function prepareLineUp() { - $players = SofaScorePlayerPerSeason::with('details')->where('total_min', '>', 0)->where('season', 'last_180_days')->where('ss_team_id', $this->team_id)->get(); + $team_player_ids = StatistikoDetail::where('ss_team_id', $this->team_id)->pluck('ss_player_id')->toArray(); + + $players = SofaScorePlayerPerSeason::with('details')->where('season', 'last_180_days')->whereIn('ss_player_id', $team_player_ids)->get(); $arr = collect(); foreach ($players as $value) { @@ -809,7 +814,8 @@ class PlayerPropsDrop extends Widget public function getPlayerForPosition(array &$lineup, array &$id_used, int $place, Collection $players) { - $log = false; + $log = 0; + $position = $this->activeBoxes[$place]; $hirarchy = PositionHirarchie::load(); @@ -830,7 +836,7 @@ class PlayerPropsDrop extends Widget $fitered = $players->where('pos', $position2)->whereNotIn('id', $id_used)->sortByDesc('min')->first(); if (isset($fitered['id'])) { - $lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position2]; + $lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position]; $id_used[] = $fitered['id']; if ($log) { Log::debug("B $place - $position $position2", $fitered); @@ -845,7 +851,7 @@ class PlayerPropsDrop extends Widget Log::debug("C $place - $position $position2 $position3", $fitered); } - $lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position3]; + $lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position]; $id_used[] = $fitered['id']; } elseif (isset($hirarchy[$position][2])) { $position4 = $hirarchy[$position][2]; @@ -856,7 +862,7 @@ class PlayerPropsDrop extends Widget Log::debug("D $place - $position $position2 $position3 $position4", $fitered); } - $lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position4]; + $lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position]; $id_used[] = $fitered['id']; } } diff --git a/app/Livewire/Mapper/LoadGridPositions.php b/app/Livewire/Mapper/LoadGridPositions.php index a6b32d6a..0f7386fe 100644 --- a/app/Livewire/Mapper/LoadGridPositions.php +++ b/app/Livewire/Mapper/LoadGridPositions.php @@ -26,11 +26,11 @@ class LoadGridPositions $arr[] = 'DM'; $arr[] = 0; - $arr[] = 'MR'; - $arr[] = 'MC'; - $arr[] = 'MC'; - $arr[] = 'MC'; $arr[] = 'ML'; + $arr[] = 'MC'; + $arr[] = 'MC'; + $arr[] = 'MC'; + $arr[] = 'MR'; $arr[] = 0; $arr[] = 'AM'; diff --git a/app/Livewire/PlayerCalculator.php b/app/Livewire/PlayerCalculator.php index 5ef9401c..1481e5ac 100644 --- a/app/Livewire/PlayerCalculator.php +++ b/app/Livewire/PlayerCalculator.php @@ -4,6 +4,7 @@ namespace App\Livewire; use App\Filament\Pages\Selections\LoadPositions; use App\Models\SofaScorePlayerPerSeason; +use App\Models\StatistikoDetail; use Livewire\Component; class PlayerCalculator extends Component @@ -12,10 +13,12 @@ class PlayerCalculator extends Component { $positions_map = LoadPositions::load(); - $player = SofaScorePlayerPerSeason::with('details')->where('season', 'total')->where('ss_team_id', $team_id)->get(); + $team_player_ids = StatistikoDetail::where('ss_team_id', $team_id)->pluck('ss_player_id')->toArray(); + + $players = SofaScorePlayerPerSeason::with('details')->where('season', 'total')->whereIn('ss_player_id', $team_player_ids)->get(); $result = []; - foreach ($player as $val) { + foreach ($players as $val) { if ($val->details != null && $val->details->is_active) { $tmp = []; diff --git a/app/Traits/UpdateHelper.php b/app/Traits/UpdateHelper.php index 6d95071e..deb3096c 100644 --- a/app/Traits/UpdateHelper.php +++ b/app/Traits/UpdateHelper.php @@ -130,7 +130,7 @@ trait UpdateHelper $ss_player_id = (int) $val->ss_player_id; $activeteam_id = (int) $val->activeteam_id; $minutes_played = (int) $val->minutes_played; - $ss_team_id = (int) $val->details->ss_team_id; + // $ss_team_id = (int) $val->details->ss_team_id; $season = $val->event->season; $home_id = (int) $val->event->home_id; $away_id = (int) $val->event->away_id; @@ -177,7 +177,7 @@ trait UpdateHelper $cards = $val->card_yellow + $val->card_yellowred; $collection[$season][$ss_player_id]['ss_player_id'] = $ss_player_id; - $collection[$season][$ss_player_id]['ss_team_id'] = $ss_team_id; + // $collection[$season][$ss_player_id]['ss_team_id'] = $ss_team_id; $collection[$season][$ss_player_id]['season'] = $season; $collection[$season][$ss_player_id]['total_events']++; $collection[$season][$ss_player_id]['total_min'] += $minutes_played; @@ -192,7 +192,7 @@ trait UpdateHelper $collection[$season][$ss_player_id]['total_shots'] += $val->shots_on_target + $val->shots_off_target + $val->shots_blocked; $collection['total'][$ss_player_id]['ss_player_id'] = $ss_player_id; - $collection['total'][$ss_player_id]['ss_team_id'] = $ss_team_id; + // $collection['total'][$ss_player_id]['ss_team_id'] = $ss_team_id; $collection['total'][$ss_player_id]['season'] = 'total'; $collection['total'][$ss_player_id]['total_events']++; $collection['total'][$ss_player_id]['total_min'] += $minutes_played; @@ -208,7 +208,7 @@ trait UpdateHelper if ($last_180_days) { $collection['last_180_days'][$ss_player_id]['ss_player_id'] = $ss_player_id; - $collection['last_180_days'][$ss_player_id]['ss_team_id'] = $ss_team_id; + // $collection['last_180_days'][$ss_player_id]['ss_team_id'] = $ss_team_id; $collection['last_180_days'][$ss_player_id]['season'] = 'last_180_days'; $collection['last_180_days'][$ss_player_id]['total_events']++; $collection['last_180_days'][$ss_player_id]['total_min'] += $minutes_played; @@ -237,7 +237,7 @@ trait UpdateHelper $collection_1d, uniqueBy: [ 'ss_player_id', - 'ss_team_id', + // 'ss_team_id', 'season', ], update: [