LoadEvents with description
This commit is contained in:
1 parent
4f63a4ef2c
commit
1f4fb9cf8a
6 files changed
+48
-144
No files matched your search
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Filament\Widgets\Data;
|
||||
|
||||
use App\Models\StatistikoDetail;
|
||||
use App\Models\StatistikoEvent;
|
||||
use App\Models\StatistikoPlayer;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class LoadEvents
|
||||
@@ -11,8 +13,6 @@ class LoadEvents
|
||||
|
||||
public static function load($filter)
|
||||
{
|
||||
// dd($filter);
|
||||
|
||||
if (self::$last_query) {
|
||||
return self::$last_query;
|
||||
}
|
||||
@@ -43,6 +43,17 @@ class LoadEvents
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* IF WITH PLAYER
|
||||
*/
|
||||
if ($tm_player_id) {
|
||||
$matches_played = StatistikoPlayer::where('tm_player_id', (int) $tm_player_id)->pluck('match_id')->toArray();
|
||||
|
||||
$description = ' (with '.StatistikoDetail::where('tm_player_id', (int) $tm_player_id)->value('name').')';
|
||||
|
||||
} else {
|
||||
$matches_played = 0;
|
||||
}
|
||||
/**
|
||||
* STATTISTIC DATA
|
||||
*/
|
||||
@@ -57,8 +68,9 @@ class LoadEvents
|
||||
return $query->where('home_id', '=', $team_id)
|
||||
->orWhere('away_id', '=', $team_id);
|
||||
}
|
||||
})
|
||||
->when($start, function ($query) use ($start) {
|
||||
})->when($matches_played, function ($query) use ($matches_played) {
|
||||
return $query->whereIn('match_id', $matches_played);
|
||||
})->when($start, function ($query) use ($start) {
|
||||
return $query->where('starttime', '>=', $start);
|
||||
})->when($end, function ($query) use ($end) {
|
||||
return $query->where('starttime', '<=', $end);
|
||||
@@ -202,6 +214,7 @@ class LoadEvents
|
||||
],
|
||||
],
|
||||
'labels' => $labels,
|
||||
'description' => $description ?? '',
|
||||
];
|
||||
|
||||
self::$last_query = $data;
|
||||
|
||||
@@ -16,25 +16,6 @@ class LoadPlayer
|
||||
return self::$last_query;
|
||||
}
|
||||
|
||||
// "team_position" => "all"
|
||||
// "statistic_type" => "gls"
|
||||
// "similar_past_matches" => "none"
|
||||
// "accuracy" => "0.5"
|
||||
// "player_on_field" => "all"
|
||||
// "league_id" => "26"
|
||||
// "team_id" => "571991"
|
||||
// "start_date" => null
|
||||
// "end_date" => null
|
||||
// "tm_player_id" => null
|
||||
|
||||
// 'gls' => 'Goals', // goals
|
||||
// 'crn' => 'Corner',
|
||||
// 'fls' => 'Fouls commited', // fouls
|
||||
// 'ofs' => 'Offside', // offsides
|
||||
// 'crd' => 'Cards',
|
||||
// 'snt' => 'Shot on target', // shots_on_target
|
||||
// 'tsh' => 'Total shots', // shots_off_target
|
||||
|
||||
$league_id = (int) $filter['league_id'] ?? 0;
|
||||
|
||||
$team_id = (int) $filter['team_id'] ?? 0;
|
||||
@@ -47,6 +28,8 @@ class LoadPlayer
|
||||
|
||||
$statistic_type = $filter['statistic_type'] ?? 0;
|
||||
|
||||
$accuracy = (float) $filter['accuracy'];
|
||||
|
||||
$similar_past_matches = $filter['similar_past_matches'] ?? 0;
|
||||
|
||||
$start = $filter['start_date'] ?? 0;
|
||||
@@ -86,6 +69,23 @@ class LoadPlayer
|
||||
return $query->where('starttime', '<=', $end);
|
||||
})->first();
|
||||
|
||||
if ($res == null) {
|
||||
|
||||
$handicap_range = 0;
|
||||
|
||||
$total_range = 0;
|
||||
|
||||
} else {
|
||||
|
||||
$exp_handicap = $res['exp_away'] - $res['exp_home'];
|
||||
|
||||
$exp_total = $res['exp_away'] + $res['exp_home'];
|
||||
|
||||
$handicap_range = [$exp_handicap - $accuracy, $exp_handicap + $accuracy];
|
||||
|
||||
$total_range = [$exp_total - $accuracy, $exp_total + $accuracy];
|
||||
}
|
||||
|
||||
$labels = [];
|
||||
$datasets = [];
|
||||
foreach ($res as $key => $value) {
|
||||
|
||||
Reference in new issue
Block a user