fix players with season
This commit is contained in:
1 parent
1949a06480
commit
9b8bbefa5e
2 files changed
+43
-35
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Widgets\Data;
|
||||
|
||||
use App\Filament\Pages\Selections\Helper\GetSeason;
|
||||
use App\Models\StatistikoDetail;
|
||||
use App\Models\StatistikoEvent;
|
||||
use App\Models\StatistikoPlayer;
|
||||
@@ -28,6 +29,11 @@ class LoadPlayer
|
||||
|
||||
$player_on_field = $filter['player_on_field'] ?? 'all';
|
||||
|
||||
|
||||
$season = $filter['season'];
|
||||
$seasonmode = $filter['seasonmode'];
|
||||
$season = GetSeason::load($season, $seasonmode);
|
||||
|
||||
// dd($player_on_field);
|
||||
|
||||
$statistic_type = $filter['statistic_type'] ?? 'gls';
|
||||
@@ -50,7 +56,8 @@ class LoadPlayer
|
||||
|
||||
$player_name = StatistikoDetail::where('ss_player_id', (int) $ss_player_id)->value('player_name');
|
||||
|
||||
$matches_season = StatistikoEvent::where(function ($query) use ($team_id, $team_position) {
|
||||
$matches_season = StatistikoEvent::whereIn('season', $season)
|
||||
->where(function ($query) use ($team_id, $team_position) {
|
||||
switch ($team_position) {
|
||||
case 'home':
|
||||
return $query->where('home_id', '=', $team_id);
|
||||
@@ -62,28 +69,28 @@ class LoadPlayer
|
||||
}
|
||||
})->pluck('match_id')->toArray();
|
||||
|
||||
// dd($matches_season);
|
||||
// dd($matches_season);
|
||||
|
||||
$matches_played = StatistikoPlayer::query()
|
||||
->whereIn('match_id', $matches_season)
|
||||
->where('ss_player_id', $ss_player_id)
|
||||
->when($player_on_field, function ($query) use ($player_on_field) {
|
||||
// 'all' => 'All',
|
||||
// 'lineup' => 'Lineup',
|
||||
// 'substituted' => 'Substituted',
|
||||
// 'notplayed' => 'Not Played',
|
||||
switch ($player_on_field) {
|
||||
case 'all':
|
||||
return $query->where('minutes_played', '>', 0);
|
||||
case 'lineup':
|
||||
return $query->where('lineup', 'T')->where('minutes_played', '>', 0);
|
||||
case 'substituted':
|
||||
return $query->where('lineup', 'P')->where('minutes_played', '>', 0);
|
||||
default:
|
||||
return $query->where('minutes_played', '>', 0);
|
||||
}
|
||||
})
|
||||
->pluck('match_id')->toArray();
|
||||
->whereIn('match_id', $matches_season)
|
||||
->where('ss_player_id', $ss_player_id)
|
||||
->when($player_on_field, function ($query) use ($player_on_field) {
|
||||
// 'all' => 'All',
|
||||
// 'lineup' => 'Lineup',
|
||||
// 'substituted' => 'Substituted',
|
||||
// 'notplayed' => 'Not Played',
|
||||
switch ($player_on_field) {
|
||||
case 'all':
|
||||
return $query->where('minutes_played', '>', 0);
|
||||
case 'lineup':
|
||||
return $query->where('lineup', 'T')->where('minutes_played', '>', 0);
|
||||
case 'substituted':
|
||||
return $query->where('lineup', 'P')->where('minutes_played', '>', 0);
|
||||
default:
|
||||
return $query->where('minutes_played', '>', 0);
|
||||
}
|
||||
})
|
||||
->pluck('match_id')->toArray();
|
||||
|
||||
$res = StatistikoPlayer::with('event')
|
||||
->where('ss_player_id', (int) $ss_player_id)
|
||||
@@ -144,8 +151,8 @@ class LoadPlayer
|
||||
}
|
||||
|
||||
$avverage = array_sum($dataset) / count($dataset);
|
||||
$dataset2 = array_fill(0,count($dataset), $avverage);
|
||||
|
||||
$dataset2 = array_fill(0, count($dataset), $avverage);
|
||||
|
||||
|
||||
|
||||
$data = [
|
||||
@@ -162,17 +169,17 @@ class LoadPlayer
|
||||
'player_name' => $player_name,
|
||||
];
|
||||
$data['datasets'][] = [
|
||||
'label' => 'Average',
|
||||
'data' => $dataset2,
|
||||
'tension' => 0.5,
|
||||
'borderColor' => '#ad46ff',
|
||||
'backgroundColor' => '#ad46ff',
|
||||
'borderDash' => [5, 5],
|
||||
'pointStyle' => false,
|
||||
'hidden' => false,
|
||||
'average_team_home' => [],
|
||||
'average_team_away' => [],
|
||||
];
|
||||
'label' => 'Average',
|
||||
'data' => $dataset2,
|
||||
'tension' => 0.5,
|
||||
'borderColor' => '#ad46ff',
|
||||
'backgroundColor' => '#ad46ff',
|
||||
'borderDash' => [5, 5],
|
||||
'pointStyle' => false,
|
||||
'hidden' => false,
|
||||
'average_team_home' => [],
|
||||
'average_team_away' => [],
|
||||
];
|
||||
|
||||
self::$last_query = $data;
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Filament\Widgets\Data;
|
||||
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\Filament\Pages\Selections\Helper\GetSeason;
|
||||
use App\Models\StatistikoDetail;
|
||||
use App\Models\StatistikoPlayer;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class LoadPlayerPerformance
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user