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