player incl player_on_field
This commit is contained in:
1 parent
ad959b3c3b
commit
cbddd2fc46
1 file changed
+48
-2
@@ -2,9 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Filament\Widgets\Data;
|
namespace App\Filament\Widgets\Data;
|
||||||
|
|
||||||
use Illuminate\Support\Carbon;
|
|
||||||
use App\Models\StatistikoDetail;
|
use App\Models\StatistikoDetail;
|
||||||
|
use App\Models\StatistikoEvent;
|
||||||
use App\Models\StatistikoPlayer;
|
use App\Models\StatistikoPlayer;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
class LoadPlayer
|
class LoadPlayer
|
||||||
{
|
{
|
||||||
@@ -17,6 +18,7 @@ class LoadPlayer
|
|||||||
// if (self::$last_query) {
|
// if (self::$last_query) {
|
||||||
// return self::$last_query;
|
// return self::$last_query;
|
||||||
// }
|
// }
|
||||||
|
$team_position = $filter['team_position'];
|
||||||
|
|
||||||
$league_id = (int) $filter['league_id'] ?? 0;
|
$league_id = (int) $filter['league_id'] ?? 0;
|
||||||
|
|
||||||
@@ -24,6 +26,9 @@ class LoadPlayer
|
|||||||
|
|
||||||
$ss_player_id = (int) $filter['ss_player_id'] ?? 0;
|
$ss_player_id = (int) $filter['ss_player_id'] ?? 0;
|
||||||
|
|
||||||
|
$player_on_field = $filter['player_on_field'] ?? 'all';
|
||||||
|
|
||||||
|
// dd($player_on_field);
|
||||||
|
|
||||||
$statistic_type = $filter['statistic_type'] ?? 'gls';
|
$statistic_type = $filter['statistic_type'] ?? 'gls';
|
||||||
|
|
||||||
@@ -45,7 +50,48 @@ 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');
|
||||||
|
|
||||||
$res = StatistikoPlayer::with('event')->where('ss_player_id', (int) $ss_player_id)->get();
|
$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('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)
|
||||||
|
->when($matches_played, function ($query) use ($matches_played, $player_on_field) {
|
||||||
|
if ($player_on_field == 'notplayed') {
|
||||||
|
return $query->whereNotIn('match_id', $matches_played);
|
||||||
|
} else {
|
||||||
|
return $query->whereIn('match_id', $matches_played);
|
||||||
|
}
|
||||||
|
})->get();
|
||||||
|
|
||||||
$tmp = [];
|
$tmp = [];
|
||||||
foreach ($res as $value) {
|
foreach ($res as $value) {
|
||||||
|
|||||||
Reference in new issue
Block a user