wip
This commit is contained in:
1 parent
a1f1385e75
commit
33111fe604
1 file changed
+35
-26
@@ -6,6 +6,8 @@ use App\Models\StatistikoPlayer;
|
|||||||
|
|
||||||
class PlayerLoad
|
class PlayerLoad
|
||||||
{
|
{
|
||||||
|
public static $last_query = [];
|
||||||
|
|
||||||
public static function load($filter)
|
public static function load($filter)
|
||||||
{
|
{
|
||||||
// dd($filter);
|
// dd($filter);
|
||||||
@@ -49,34 +51,41 @@ class PlayerLoad
|
|||||||
|
|
||||||
$player_on_field = $filter['player_on_field'];
|
$player_on_field = $filter['player_on_field'];
|
||||||
|
|
||||||
$res = StatistikoPlayer::with('event')->where('tm_player_id', $tm_player_id)
|
if ($this->$last_query) {
|
||||||
->when($team_position, function ($query) use ($team_id, $team_position) {
|
$res = $this->$last_query;
|
||||||
/**
|
} else {
|
||||||
* TEAM HOME/AWAY
|
|
||||||
*/
|
|
||||||
switch ($team_position) {
|
|
||||||
case 'home':
|
|
||||||
return $query->where('activeteam_id', $team_id);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'away':
|
$res = StatistikoPlayer::with('event')->where('tm_player_id', $tm_player_id)
|
||||||
return $query->where('activeteam_id', '!=', $team_id);
|
->when($team_position, function ($query) use ($team_id, $team_position) {
|
||||||
break;
|
/**
|
||||||
}
|
* TEAM HOME/AWAY
|
||||||
})->when($player_on_field, function ($query) use ($player_on_field) {
|
*/
|
||||||
/**
|
switch ($team_position) {
|
||||||
* LINEUP
|
case 'home':
|
||||||
*/
|
return $query->where('activeteam_id', $team_id);
|
||||||
switch ($player_on_field) {
|
break;
|
||||||
case 'lineup':
|
|
||||||
return $query->where('lineup', 'T');
|
|
||||||
break;
|
|
||||||
case 'substituted':
|
|
||||||
return $query->where('lineup', 'P');
|
|
||||||
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;
|
$statistic_type = $filter['statistic_type'] ?? 0;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user