filter playeer played
This commit is contained in:
1 parent
74e9285bac
commit
5081ec9e32
30 files changed
+4114
-1420
No files matched your search
@@ -3,6 +3,8 @@
|
||||
namespace App\Filament\Widgets\Data;
|
||||
|
||||
use App\Filament\Widgets\Data\LoadEvents\LoadEventsAverages;
|
||||
use App\Models\SofaScoreEvent;
|
||||
use App\Models\SofaScorePlayerPerSeason;
|
||||
use App\Models\StatisticFixtures;
|
||||
use App\Models\StatistikoDetail;
|
||||
use App\Models\StatistikoEvent;
|
||||
@@ -95,9 +97,25 @@ class LoadEvents
|
||||
*/
|
||||
$matches_played = [];
|
||||
$description = '';
|
||||
// dd($tm_player_id); 613873
|
||||
|
||||
if ($tm_player_id) {
|
||||
$matches_played = StatistikoPlayer::where('tm_player_id', (int) $tm_player_id)
|
||||
|
||||
$matches_season = StatistikoEvent::where(function ($query) use ($team_id, $team_position) {
|
||||
switch ($team_position) {
|
||||
case 'home':
|
||||
return $query->where('home_id', '=', $team_id);
|
||||
case 'away':
|
||||
return $query->where('away_id', '=', $team_id);
|
||||
default:
|
||||
return $query->where('home_id', '=', $team_id)
|
||||
->orWhere('away_id', '=', $team_id);
|
||||
}
|
||||
})->pluck('match_id')->toArray();
|
||||
|
||||
|
||||
$matches_played = StatistikoPlayer::query()
|
||||
->whereIn('match_id', $matches_season)
|
||||
->where('tm_player_id', '=', (int) $tm_player_id)
|
||||
->when($player_on_field, function ($query) use ($player_on_field) {
|
||||
// 'all' => 'All',
|
||||
// 'lineup' => 'Lineup',
|
||||
@@ -105,16 +123,18 @@ class LoadEvents
|
||||
// 'notplayed' => 'Not Played',
|
||||
switch ($player_on_field) {
|
||||
case 'all':
|
||||
return $query->where('match_id', '>', 0);
|
||||
return $query->where('minutes_played', '>', 0);
|
||||
case 'lineup':
|
||||
return $query->where('lineup', 'T');
|
||||
return $query->where('lineup', 'T')->where('minutes_played', '>', 0);
|
||||
case 'substituted':
|
||||
return $query->where('lineup', 'P');
|
||||
case 'notplayed':
|
||||
return $query->where('lineup', '=', '');
|
||||
return $query->where('lineup', 'P')->where('minutes_played', '>', 0);
|
||||
default:
|
||||
return $query->where('minutes_played', '>', 0);
|
||||
}
|
||||
})
|
||||
->pluck('match_id')->toArray();
|
||||
|
||||
|
||||
$description = ' with ' . StatistikoDetail::where('tm_player_id', (int) $tm_player_id)->value('name') . ' (' . \count($matches_played) . ')';
|
||||
|
||||
if (! $matches_played) {
|
||||
|
||||
Reference in new issue
Block a user