wip player filter
This commit is contained in:
1 parent
12d29c7b3e
commit
74e9285bac
4 files changed
+30
-21
No files matched your search
@@ -4,14 +4,18 @@ namespace App\Actions\Selections;
|
|||||||
|
|
||||||
use App\Models\StatistikoDetail;
|
use App\Models\StatistikoDetail;
|
||||||
use App\Models\StatistikoPlayer;
|
use App\Models\StatistikoPlayer;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class LoadPlayer
|
class LoadPlayer
|
||||||
{
|
{
|
||||||
public static function load($team_id)
|
public static function load($get)
|
||||||
{
|
{
|
||||||
// $res = CompetitionGroup::with('country')->where('id', $league_id)->first();
|
// $res = CompetitionGroup::with('country')->where('id', $league_id)->first();
|
||||||
// $season_mode = $res->country->season_mode;
|
// $season_mode = $res->country->season_mode;
|
||||||
|
|
||||||
|
$team_id = $get('team_id');
|
||||||
|
$season = $get('season');
|
||||||
|
|
||||||
$res_details = StatistikoDetail::where('txodds_id', $team_id)->get();
|
$res_details = StatistikoDetail::where('txodds_id', $team_id)->get();
|
||||||
|
|
||||||
if (! $res_details) {
|
if (! $res_details) {
|
||||||
@@ -23,17 +27,19 @@ class LoadPlayer
|
|||||||
$player_ids[] = $val->tm_player_id;
|
$player_ids[] = $val->tm_player_id;
|
||||||
}
|
}
|
||||||
$res_player = StatistikoPlayer::whereIn('tm_player_id', $player_ids)
|
$res_player = StatistikoPlayer::whereIn('tm_player_id', $player_ids)
|
||||||
|
->with('event')
|
||||||
->where('minutes_played', '>', 0)
|
->where('minutes_played', '>', 0)
|
||||||
->select('match_id','tm_player_id')
|
->select('match_id','tm_player_id')
|
||||||
->get();
|
->get();
|
||||||
$counting = [];
|
$counting = [];
|
||||||
foreach ($res_player as $val) {
|
foreach ($res_player as $val) {
|
||||||
$tm_player_id = $val->tm_player_id;
|
if(in_array($val->event->season, $season)){
|
||||||
|
$tm_player_id = $val->tm_player_id;
|
||||||
if(!isset($counting[$tm_player_id])){
|
if(!isset($counting[$tm_player_id])){
|
||||||
$counting[$tm_player_id] = 1;
|
$counting[$tm_player_id] = 1;
|
||||||
}else {
|
}else {
|
||||||
$counting[$tm_player_id]++;
|
$counting[$tm_player_id]++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,4 +69,4 @@ class LoadPlayer
|
|||||||
}
|
}
|
||||||
return $arr;
|
return $arr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -232,7 +232,7 @@ class Statistic extends BaseDashboard
|
|||||||
->preload()
|
->preload()
|
||||||
->searchable()
|
->searchable()
|
||||||
->options(function (Get $get) {
|
->options(function (Get $get) {
|
||||||
return LoadPlayer::load($get('team_id'));
|
return LoadPlayer::load($get);
|
||||||
}),
|
}),
|
||||||
Select::make('player_on_field')
|
Select::make('player_on_field')
|
||||||
->live()
|
->live()
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Filament\Widgets\Data;
|
namespace App\Filament\Widgets\Data;
|
||||||
|
|
||||||
use App\Filament\Widgets\Data\LoadEvents\LoadEventsAverages;
|
use App\Filament\Widgets\Data\LoadEvents\LoadEventsAverages;
|
||||||
use App\Models\CompetitionGroup;
|
|
||||||
use App\Models\StatisticFixtures;
|
use App\Models\StatisticFixtures;
|
||||||
use App\Models\StatistikoDetail;
|
use App\Models\StatistikoDetail;
|
||||||
use App\Models\StatistikoEvent;
|
use App\Models\StatistikoEvent;
|
||||||
@@ -12,16 +11,8 @@ use Illuminate\Support\Carbon;
|
|||||||
|
|
||||||
class LoadEvents
|
class LoadEvents
|
||||||
{
|
{
|
||||||
public static $last_query = [];
|
|
||||||
|
|
||||||
public static function load(array $filter, bool $hasdots)
|
public static function load(array $filter, bool $hasdots)
|
||||||
{
|
{
|
||||||
// dd($filter);
|
|
||||||
|
|
||||||
// if (self::$last_query) {
|
|
||||||
// return self::$last_query;
|
|
||||||
// }
|
|
||||||
|
|
||||||
$league_id = (int) $filter['league_id'] ?? 0;
|
$league_id = (int) $filter['league_id'] ?? 0;
|
||||||
|
|
||||||
$match_id = (int) $filter['match_id'] ?? 0;
|
$match_id = (int) $filter['match_id'] ?? 0;
|
||||||
@@ -42,7 +33,7 @@ class LoadEvents
|
|||||||
|
|
||||||
$team_position = $filter['team_position'];
|
$team_position = $filter['team_position'];
|
||||||
|
|
||||||
$player_on_field = $filter['player_on_field'];
|
$player_on_field = $filter['player_on_field'] ?? 'all';
|
||||||
|
|
||||||
$accuracy = (float) $filter['accuracy'] ?? 0.5;
|
$accuracy = (float) $filter['accuracy'] ?? 0.5;
|
||||||
|
|
||||||
@@ -108,11 +99,19 @@ class LoadEvents
|
|||||||
if ($tm_player_id) {
|
if ($tm_player_id) {
|
||||||
$matches_played = StatistikoPlayer::where('tm_player_id', (int) $tm_player_id)
|
$matches_played = StatistikoPlayer::where('tm_player_id', (int) $tm_player_id)
|
||||||
->when($player_on_field, function ($query) use ($player_on_field) {
|
->when($player_on_field, function ($query) use ($player_on_field) {
|
||||||
|
// 'all' => 'All',
|
||||||
|
// 'lineup' => 'Lineup',
|
||||||
|
// 'substituted' => 'Substituted',
|
||||||
|
// 'notplayed' => 'Not Played',
|
||||||
switch ($player_on_field) {
|
switch ($player_on_field) {
|
||||||
|
case 'all':
|
||||||
|
return $query->where('match_id', '>', 0);
|
||||||
case 'lineup':
|
case 'lineup':
|
||||||
return $query->where('lineup', 'T');
|
return $query->where('lineup', 'T');
|
||||||
case 'substituted':
|
case 'substituted':
|
||||||
return $query->where('lineup', 'P');
|
return $query->where('lineup', 'P');
|
||||||
|
case 'notplayed':
|
||||||
|
return $query->where('lineup', '=', '');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->pluck('match_id')->toArray();
|
->pluck('match_id')->toArray();
|
||||||
@@ -519,8 +518,6 @@ class LoadEvents
|
|||||||
LoadEventsAverages::load($data, $filter, $labels, $events);
|
LoadEventsAverages::load($data, $filter, $labels, $events);
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$last_query = $data;
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,17 @@ use App\Filament\Widgets\Data\HelperStatisticType;
|
|||||||
use App\Filament\Widgets\Data\HelperTeamPosition;
|
use App\Filament\Widgets\Data\HelperTeamPosition;
|
||||||
use App\Filament\Widgets\Data\LoadEvents;
|
use App\Filament\Widgets\Data\LoadEvents;
|
||||||
use App\Utilities\Round;
|
use App\Utilities\Round;
|
||||||
|
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
||||||
use Filament\Widgets\StatsOverviewWidget;
|
use Filament\Widgets\StatsOverviewWidget;
|
||||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\HtmlString;
|
use Illuminate\Support\HtmlString;
|
||||||
use Livewire\Attributes\Reactive;
|
use Livewire\Attributes\Reactive;
|
||||||
|
|
||||||
class StatsMedianAverage extends StatsOverviewWidget
|
class StatsMedianAverage extends StatsOverviewWidget
|
||||||
{
|
{
|
||||||
|
use InteractsWithPageFilters;
|
||||||
|
|
||||||
protected ?string $pollingInterval = null;
|
protected ?string $pollingInterval = null;
|
||||||
|
|
||||||
protected int|array|null $columns = null;
|
protected int|array|null $columns = null;
|
||||||
@@ -31,6 +35,8 @@ class StatsMedianAverage extends StatsOverviewWidget
|
|||||||
{
|
{
|
||||||
$data = LoadEvents::load($this->filters, false);
|
$data = LoadEvents::load($this->filters, false);
|
||||||
|
|
||||||
|
// Log::debug($this->filters, $data);
|
||||||
|
|
||||||
$team_position = HelperTeamPosition::get($this->filters);
|
$team_position = HelperTeamPosition::get($this->filters);
|
||||||
|
|
||||||
if (!$data)
|
if (!$data)
|
||||||
|
|||||||
Reference in new issue
Block a user