diff --git a/app/Filament/Imports/Helper/ImportPlayer.php b/app/Filament/Imports/Helper/ImportPlayer.php index 96b58af3..7931984c 100644 --- a/app/Filament/Imports/Helper/ImportPlayer.php +++ b/app/Filament/Imports/Helper/ImportPlayer.php @@ -102,9 +102,6 @@ class ImportPlayer foreach ($fieldnames as $key => $name) { if ($key == 1) { $match_id = (int) $row[$key]; - // if (! $match_id) { - // return false; - // } } elseif ($key == 2) { $ss_player_id = (int) $row[$key]; } elseif ($key == 3) { diff --git a/app/Filament/Pages/PlayerProps.php b/app/Filament/Pages/PlayerProps.php index f7f4f560..f1897c21 100644 --- a/app/Filament/Pages/PlayerProps.php +++ b/app/Filament/Pages/PlayerProps.php @@ -420,7 +420,7 @@ class PlayerProps extends Page implements HasForms ->afterStateUpdated(function (callable $set, $state) { $set('ss_player_id', null); // cat all values in array to strings - $this->dispatch('season_selected-update', season_selected: array_map('strval', $state)); + $this->dispatch('season_selected-update', season_selected: $state); }); } diff --git a/app/Traits/PlayerProps/PlayerQuery.php b/app/Traits/PlayerProps/PlayerQuery.php index b6ad1f25..31c04c6f 100644 --- a/app/Traits/PlayerProps/PlayerQuery.php +++ b/app/Traits/PlayerProps/PlayerQuery.php @@ -3,7 +3,7 @@ namespace App\Traits\PlayerProps; use App\Models\StatistikoDetail; -use App\Models\StatistikoEvent; +use App\Models\StatistikoPlayer; use Illuminate\Support\Carbon; // use Illuminate\Support\Facades\Log; @@ -27,7 +27,6 @@ trait PlayerQuery $arr = []; $res = $this->getPlayers($part, $player_ids); foreach ($res as $val) { - $ss_player_id = (int) $val->ss_player_id; $activeteam_id = (int) $val->activeteam_id; $minutes_played = (int) $val->minutes_played; @@ -91,7 +90,6 @@ trait PlayerQuery $arr = []; $res = $this->getPlayers(1, $player_ids); foreach ($res as $val) { - $ss_player_id = (int) $val->ss_player_id; $activeteam_id = (int) $val->activeteam_id; $minutes_played = (int) $val->minutes_played; @@ -184,30 +182,41 @@ trait PlayerQuery $this->season_selected = $this->getCurrentSeason(); } + $sesson_int_string = []; + foreach ($this->season_selected as $value) { + if (strpos($value, '/') !== false) { + $sesson_int_string[] = (string) $value; + } else { + $sesson_int_string[] = (string) $value; + $sesson_int_string[] = (int) $value; + } + } + return match ($part) { - 1 => StatistikoEvent::with('details') + 1 => StatistikoPlayer::with('details') ->whereIn('ss_player_id', $player_ids) - ->when($this->season_selected, function ($query) { - return $query->whereIn('season', $this->season_selected); - })->pluck('match_id')->toArray(), - 2 => StatistikoEvent::with('details') + ->when($this->season_selected, function ($query) use ($sesson_int_string) { + return $query->whereIn('season', $sesson_int_string); + })->get(), + 2 => StatistikoPlayer::with('details') ->whereIn('ss_player_id', $player_ids) - ->when($this->season_selected, function ($query) { - return $query->whereNotIn('season', $this->season_selected); - })->pluck('match_id')->toArray(), + ->when($this->season_selected, function ($query) use ($sesson_int_string) { + return $query->whereNotIn('season', $sesson_int_string); + })->get(), }; + default: return match ($part) { - 1 => StatistikoEvent::with('details') + 1 => StatistikoPlayer::with('details') ->whereIn('ss_player_id', $player_ids) ->when($this->date_spliter, function ($query) { return $query->whereDate('starttime', '>', $this->date_spliter); - })->pluck('match_id')->toArray(), - 2 => StatistikoEvent::with('details') + })->get(), + 2 => StatistikoPlayer::with('details') ->whereIn('ss_player_id', $player_ids) ->when($this->season_selected, function ($query) { return $query->whereDate('starttime', '<=', $this->date_spliter); - })->pluck('match_id')->toArray() + })->get(), }; } }