This commit is contained in:
salam committed 2026-05-22 16:52:24 +02:00
1 parent a1f1385e75
commit 33111fe604
1 file changed
+35 -26
+35 -26
View File
@@ -6,6 +6,8 @@ use App\Models\StatistikoPlayer;
class PlayerLoad
{
public static $last_query = [];
public static function load($filter)
{
// dd($filter);
@@ -49,34 +51,41 @@ class PlayerLoad
$player_on_field = $filter['player_on_field'];
$res = StatistikoPlayer::with('event')->where('tm_player_id', $tm_player_id)
->when($team_position, function ($query) use ($team_id, $team_position) {
/**
* TEAM HOME/AWAY
*/
switch ($team_position) {
case 'home':
return $query->where('activeteam_id', $team_id);
break;
if ($this->$last_query) {
$res = $this->$last_query;
} else {
case 'away':
return $query->where('activeteam_id', '!=', $team_id);
break;
}
})->when($player_on_field, function ($query) use ($player_on_field) {
/**
* LINEUP
*/
switch ($player_on_field) {
case 'lineup':
return $query->where('lineup', 'T');
break;
case 'substituted':
return $query->where('lineup', 'P');
break;
}
$res = StatistikoPlayer::with('event')->where('tm_player_id', $tm_player_id)
->when($team_position, function ($query) use ($team_id, $team_position) {
/**
* TEAM HOME/AWAY
*/
switch ($team_position) {
case 'home':
return $query->where('activeteam_id', $team_id);
break;
})->get();
case 'away':
return $query->where('activeteam_id', '!=', $team_id);
break;
}
})->when($player_on_field, function ($query) use ($player_on_field) {
/**
* LINEUP
*/
switch ($player_on_field) {
case 'lineup':
return $query->where('lineup', 'T');
break;
case 'substituted':
return $query->where('lineup', 'P');
break;
}
})->get();
$this->$last_query = $res;
}
$statistic_type = $filter['statistic_type'] ?? 0;