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;
|
||||
|
||||
Reference in new issue
Block a user