wip
This commit is contained in:
1 parent
2734b06350
commit
fbaadcd248
9 files changed
+213
-219
No files matched your search
@@ -4,9 +4,9 @@ namespace App\Filament\Pages;
|
|||||||
|
|
||||||
use App\Actions\LoadStatisticFixturesLeaguesOptions;
|
use App\Actions\LoadStatisticFixturesLeaguesOptions;
|
||||||
use App\Filament\Widgets\ChartMovingAverageEvent;
|
use App\Filament\Widgets\ChartMovingAverageEvent;
|
||||||
|
use App\Filament\Widgets\ChartMovingAveragePlayer;
|
||||||
use App\Filament\Widgets\ChartPunctualEvent;
|
use App\Filament\Widgets\ChartPunctualEvent;
|
||||||
use App\Filament\Widgets\MovingAverageChartPlayer;
|
use App\Filament\Widgets\ChartPunctualPlayer;
|
||||||
use App\Filament\Widgets\PunctualChartPlayer;
|
|
||||||
use App\Filament\Widgets\StatsMedianAverage;
|
use App\Filament\Widgets\StatsMedianAverage;
|
||||||
use App\Models\Element;
|
use App\Models\Element;
|
||||||
use App\Models\StatisticFixtures;
|
use App\Models\StatisticFixtures;
|
||||||
@@ -99,6 +99,7 @@ class Statistic extends BaseDashboard
|
|||||||
DatePicker::make('start_date')
|
DatePicker::make('start_date')
|
||||||
->native(false)
|
->native(false)
|
||||||
->prefixIcon('phosphor-calendar')
|
->prefixIcon('phosphor-calendar')
|
||||||
|
->live()
|
||||||
->suffixAction(
|
->suffixAction(
|
||||||
Action::make('clear_start')
|
Action::make('clear_start')
|
||||||
->icon('phosphor-x')
|
->icon('phosphor-x')
|
||||||
@@ -108,6 +109,7 @@ class Statistic extends BaseDashboard
|
|||||||
DatePicker::make('end_date')
|
DatePicker::make('end_date')
|
||||||
->native(false)
|
->native(false)
|
||||||
->prefixIcon('phosphor-calendar')
|
->prefixIcon('phosphor-calendar')
|
||||||
|
->live()
|
||||||
->suffixAction(
|
->suffixAction(
|
||||||
Action::make('clear_end')
|
Action::make('clear_end')
|
||||||
->icon('phosphor-x')
|
->icon('phosphor-x')
|
||||||
@@ -131,6 +133,7 @@ class Statistic extends BaseDashboard
|
|||||||
->action(function (callable $set) {
|
->action(function (callable $set) {
|
||||||
$set('tm_player_id', null);
|
$set('tm_player_id', null);
|
||||||
})
|
})
|
||||||
|
->color('gray')
|
||||||
->icon('phosphor-x'),
|
->icon('phosphor-x'),
|
||||||
)
|
)
|
||||||
->preload()
|
->preload()
|
||||||
@@ -140,6 +143,7 @@ class Statistic extends BaseDashboard
|
|||||||
})
|
})
|
||||||
->live(),
|
->live(),
|
||||||
Select::make('player_on_field')
|
Select::make('player_on_field')
|
||||||
|
->label('Time on field')
|
||||||
->prefixIcon('phosphor-watch')
|
->prefixIcon('phosphor-watch')
|
||||||
->default('all')
|
->default('all')
|
||||||
->selectablePlaceholder(false)
|
->selectablePlaceholder(false)
|
||||||
@@ -224,8 +228,8 @@ class Statistic extends BaseDashboard
|
|||||||
StatsMedianAverage::make(),
|
StatsMedianAverage::make(),
|
||||||
ChartPunctualEvent::make(),
|
ChartPunctualEvent::make(),
|
||||||
ChartMovingAverageEvent::make(),
|
ChartMovingAverageEvent::make(),
|
||||||
PunctualChartPlayer::make(),
|
// ChartPunctualPlayer::make(),
|
||||||
MovingAverageChartPlayer::make(),
|
// ChartMovingAveragePlayer::make(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Filament\Widgets;
|
namespace App\Filament\Widgets;
|
||||||
|
|
||||||
use App\Filament\Widgets\Data\EventsLoad;
|
|
||||||
use App\Filament\Widgets\Data\HelperMoveingAverage;
|
use App\Filament\Widgets\Data\HelperMoveingAverage;
|
||||||
use App\Filament\Widgets\Data\HelperStatisticType;
|
use App\Filament\Widgets\Data\HelperStatisticType;
|
||||||
|
use App\Filament\Widgets\Data\LoadEvents;
|
||||||
use Filament\Widgets\ChartWidget;
|
use Filament\Widgets\ChartWidget;
|
||||||
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ class ChartMovingAverageEvent extends ChartWidget
|
|||||||
{
|
{
|
||||||
$this->heading = HelperStatisticType::get($this->filters);
|
$this->heading = HelperStatisticType::get($this->filters);
|
||||||
|
|
||||||
$data = EventsLoad::load($this->filters);
|
$data = LoadEvents::load($this->filters);
|
||||||
|
|
||||||
if ($data) {
|
if ($data) {
|
||||||
HelperMoveingAverage::get($data);
|
HelperMoveingAverage::get($data);
|
||||||
|
|||||||
+7
-3
@@ -4,11 +4,11 @@ namespace App\Filament\Widgets;
|
|||||||
|
|
||||||
use App\Filament\Widgets\Data\HelperMoveingAverage;
|
use App\Filament\Widgets\Data\HelperMoveingAverage;
|
||||||
use App\Filament\Widgets\Data\HelperStatisticType;
|
use App\Filament\Widgets\Data\HelperStatisticType;
|
||||||
use App\Filament\Widgets\Data\PlayerLoad;
|
use App\Filament\Widgets\Data\LoadPlayer;
|
||||||
use Filament\Widgets\ChartWidget;
|
use Filament\Widgets\ChartWidget;
|
||||||
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
||||||
|
|
||||||
class MovingAverageChartPlayer extends ChartWidget
|
class ChartMovingAveragePlayer extends ChartWidget
|
||||||
{
|
{
|
||||||
use InteractsWithPageFilters;
|
use InteractsWithPageFilters;
|
||||||
|
|
||||||
@@ -31,9 +31,13 @@ class MovingAverageChartPlayer extends ChartWidget
|
|||||||
|
|
||||||
protected function getData(): array
|
protected function getData(): array
|
||||||
{
|
{
|
||||||
|
if ($this->filters['statistic_type'] == 'crn') {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
$this->heading = HelperStatisticType::get($this->filters);
|
$this->heading = HelperStatisticType::get($this->filters);
|
||||||
|
|
||||||
$data = PlayerLoad::load($this->filters);
|
$data = LoadPlayer::load($this->filters);
|
||||||
|
|
||||||
if ($data) {
|
if ($data) {
|
||||||
HelperMoveingAverage::get($data);
|
HelperMoveingAverage::get($data);
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Filament\Widgets;
|
namespace App\Filament\Widgets;
|
||||||
|
|
||||||
use App\Filament\Widgets\Data\EventsLoad;
|
|
||||||
use App\Filament\Widgets\Data\HelperStatisticType;
|
use App\Filament\Widgets\Data\HelperStatisticType;
|
||||||
|
use App\Filament\Widgets\Data\LoadEvents;
|
||||||
use Filament\Widgets\ChartWidget;
|
use Filament\Widgets\ChartWidget;
|
||||||
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ class ChartPunctualEvent extends ChartWidget
|
|||||||
{
|
{
|
||||||
$this->heading = HelperStatisticType::get($this->filters);
|
$this->heading = HelperStatisticType::get($this->filters);
|
||||||
|
|
||||||
$data = EventsLoad::load($this->filters);
|
$data = LoadEvents::load($this->filters);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -3,11 +3,11 @@
|
|||||||
namespace App\Filament\Widgets;
|
namespace App\Filament\Widgets;
|
||||||
|
|
||||||
use App\Filament\Widgets\Data\HelperStatisticType;
|
use App\Filament\Widgets\Data\HelperStatisticType;
|
||||||
use App\Filament\Widgets\Data\PlayerLoad;
|
use App\Filament\Widgets\Data\LoadPlayer;
|
||||||
use Filament\Widgets\ChartWidget;
|
use Filament\Widgets\ChartWidget;
|
||||||
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
||||||
|
|
||||||
class PunctualChartPlayer extends ChartWidget
|
class ChartPunctualPlayer extends ChartWidget
|
||||||
{
|
{
|
||||||
use InteractsWithPageFilters;
|
use InteractsWithPageFilters;
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ class PunctualChartPlayer extends ChartWidget
|
|||||||
|
|
||||||
$this->heading = HelperStatisticType::get($this->filters);
|
$this->heading = HelperStatisticType::get($this->filters);
|
||||||
|
|
||||||
$data = PlayerLoad::load($this->filters);
|
$data = LoadPlayer::load($this->filters);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
@@ -2,15 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Filament\Widgets\Data;
|
namespace App\Filament\Widgets\Data;
|
||||||
|
|
||||||
use App\Models\StatisticFixtures;
|
|
||||||
use App\Models\StatistikoEvent;
|
use App\Models\StatistikoEvent;
|
||||||
use App\Models\StatistikoPlayer;
|
use App\Models\StatistikoPlayer;
|
||||||
|
|
||||||
class EventsLoadAspGoal
|
class LoadEventsAspGoal
|
||||||
{
|
{
|
||||||
public static function load($filter)
|
public static function load($filter)
|
||||||
{
|
{
|
||||||
// dd($filter);
|
dd($filter);
|
||||||
|
|
||||||
$league_id = (int) $filter['league_id'] ?? 0;
|
$league_id = (int) $filter['league_id'] ?? 0;
|
||||||
|
|
||||||
@@ -23,27 +22,41 @@ class EventsLoadAspGoal
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WITH PLAYER
|
||||||
|
*/
|
||||||
|
$tm_player_id = $filter['tm_player_id'];
|
||||||
|
|
||||||
|
if ($tm_player_id) {
|
||||||
|
$matches_played = StatistikoPlayer::where('tm_player_id', (int) $tm_player_id)->pluck('match_id')->toArray();
|
||||||
|
} else {
|
||||||
|
$matches_played = false;
|
||||||
|
}
|
||||||
|
|
||||||
$team_position = $filter['team_position'];
|
$team_position = $filter['team_position'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ACCURACY DATA
|
* STATTISTIC DATA
|
||||||
*/
|
*/
|
||||||
switch ($filter['team_position']) {
|
$res = StatistikoEvent::where('league_id', $league_id)
|
||||||
case 'home':
|
->where(function ($query) use ($team_id, $team_position) {
|
||||||
$res = StatisticFixtures::where('league_id', $league_id)->where('home_id', $team_id)->first();
|
switch ($team_position) {
|
||||||
break;
|
case 'home':
|
||||||
|
return $query->where('home_id', '=', $team_id);
|
||||||
case 'away':
|
case 'away':
|
||||||
$res = StatisticFixtures::where('league_id', $league_id)->where('away_id', $team_id)->first();
|
return $query->where('away_id', '=', $team_id);
|
||||||
break;
|
default:
|
||||||
|
return $query->where('home_id', '=', $team_id)
|
||||||
default:
|
->orWhere('away_id', '=', $team_id);
|
||||||
$res = StatisticFixtures::where('league_id', $league_id)
|
}
|
||||||
->where(function ($query) use ($team_id) {
|
})
|
||||||
$query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
|
->when($matches_played, function ($query) use ($matches_played) {
|
||||||
})->first();
|
return $query->whereIn('match_id', $matches_played);
|
||||||
break;
|
})->when($start, function ($query) use ($start) {
|
||||||
}
|
return $query->where('starttime', '>=', $start);
|
||||||
|
})->when($end, function ($query) use ($end) {
|
||||||
|
return $query->where('starttime', '<=', $end);
|
||||||
|
})->first();
|
||||||
|
|
||||||
$start = $filter['start_date'] ?? 0;
|
$start = $filter['start_date'] ?? 0;
|
||||||
|
|
||||||
@@ -81,63 +94,84 @@ class EventsLoadAspGoal
|
|||||||
|
|
||||||
$similar_past_matches = $filter['similar_past_matches'] ?? 0;
|
$similar_past_matches = $filter['similar_past_matches'] ?? 0;
|
||||||
|
|
||||||
switch ($similar_past_matches) {
|
$res = StatistikoEvent::when($league_id, function ($query) use ($league_id, $similar_past_matches) {
|
||||||
case 'league':
|
switch ($similar_past_matches) {
|
||||||
$res = StatistikoEvent::when($league_id, function ($query) use ($league_id) {
|
case 'league':
|
||||||
return $query->where('league_id', $league_id);
|
return $query->where('league_id', $league_id);
|
||||||
})->when($matches_played, function ($query) use ($matches_played) {
|
default:
|
||||||
return $query->whereIn('match_id', $matches_played);
|
|
||||||
})->when($handicap_range, function ($query) use ($handicap_range) {
|
|
||||||
return $query->whereBetween('exp_handicap', $handicap_range);
|
return $query->whereBetween('exp_handicap', $handicap_range);
|
||||||
})->when($total_range, function ($query) use ($total_range) {
|
}
|
||||||
return $query->whereBetween('exp_total', $total_range);
|
|
||||||
})->when($start, function ($query) use ($start) {
|
|
||||||
return $query->where('starttime', '>=', $start);
|
|
||||||
})->when($end, function ($query) use ($end) {
|
|
||||||
return $query->where('starttime', '<=', $end);
|
|
||||||
})
|
|
||||||
->get();
|
|
||||||
|
|
||||||
break;
|
})->when($matches_played, function ($query) use ($matches_played) {
|
||||||
case 'all':
|
return $query->whereIn('match_id', $matches_played);
|
||||||
$res = StatistikoEvent::when($handicap_range, function ($query) use ($handicap_range) {
|
})->when($handicap_range, function ($query) use ($handicap_range) {
|
||||||
return $query->whereBetween('exp_handicap', $handicap_range);
|
return $query->whereBetween('exp_handicap', $handicap_range);
|
||||||
})->when($matches_played, function ($query) use ($matches_played) {
|
})->when($total_range, function ($query) use ($total_range) {
|
||||||
return $query->whereIn('match_id', $matches_played);
|
return $query->whereBetween('exp_total', $total_range);
|
||||||
})->when($total_range, function ($query) use ($total_range) {
|
})->when($start, function ($query) use ($start) {
|
||||||
return $query->whereBetween('exp_total', $total_range);
|
return $query->where('starttime', '>=', $start);
|
||||||
})->when($start, function ($query) use ($start) {
|
})->when($end, function ($query) use ($end) {
|
||||||
return $query->where('starttime', '>=', $start);
|
return $query->where('starttime', '<=', $end);
|
||||||
})->when($end, function ($query) use ($end) {
|
})
|
||||||
return $query->where('starttime', '<=', $end);
|
->get();
|
||||||
})
|
|
||||||
->get();
|
|
||||||
|
|
||||||
break;
|
// switch ($similar_past_matches) {
|
||||||
// case 'none':
|
// case 'league':
|
||||||
// $res = StatistikoEvent::when($league_id, function ($query) use ($league_id) {
|
// $res = StatistikoEvent::when($league_id, function ($query) use ($league_id) {
|
||||||
// return $query->where('league_id', $league_id);
|
// return $query->where('league_id', $league_id);
|
||||||
// })->when($team_id, function ($query) use ($team_id, $team_position) {
|
// })->when($matches_played, function ($query) use ($matches_played) {
|
||||||
// switch ($team_position) {
|
// return $query->whereIn('match_id', $matches_played);
|
||||||
// case 'home':
|
// })->when($handicap_range, function ($query) use ($handicap_range) {
|
||||||
// return $query->where('home_id', $team_id);
|
// return $query->whereBetween('exp_handicap', $handicap_range);
|
||||||
// break;
|
// })->when($total_range, function ($query) use ($total_range) {
|
||||||
// case 'away':
|
// return $query->whereBetween('exp_total', $total_range);
|
||||||
// return $query->where('away_id', $team_id);
|
// })->when($start, function ($query) use ($start) {
|
||||||
// break;
|
// return $query->where('starttime', '>=', $start);
|
||||||
// default:
|
// })->when($end, function ($query) use ($end) {
|
||||||
// return $query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
|
// return $query->where('starttime', '<=', $end);
|
||||||
// break;
|
// })
|
||||||
// }
|
// ->get();
|
||||||
// })->when($start, function ($query) use ($start) {
|
|
||||||
// return $query->where('starttime', '>=', $start);
|
|
||||||
// })->when($end, function ($query) use ($end) {
|
|
||||||
// return $query->where('starttime', '<=', $end);
|
|
||||||
// })
|
|
||||||
// ->get();
|
|
||||||
|
|
||||||
// break;
|
// break;
|
||||||
}
|
// case 'all':
|
||||||
|
// $res = StatistikoEvent::when($handicap_range, function ($query) use ($handicap_range) {
|
||||||
|
// return $query->whereBetween('exp_handicap', $handicap_range);
|
||||||
|
// })->when($matches_played, function ($query) use ($matches_played) {
|
||||||
|
// return $query->whereIn('match_id', $matches_played);
|
||||||
|
// })->when($total_range, function ($query) use ($total_range) {
|
||||||
|
// return $query->whereBetween('exp_total', $total_range);
|
||||||
|
// })->when($start, function ($query) use ($start) {
|
||||||
|
// return $query->where('starttime', '>=', $start);
|
||||||
|
// })->when($end, function ($query) use ($end) {
|
||||||
|
// return $query->where('starttime', '<=', $end);
|
||||||
|
// })
|
||||||
|
// ->get();
|
||||||
|
|
||||||
|
// break;
|
||||||
|
// // case 'none':
|
||||||
|
// // $res = StatistikoEvent::when($league_id, function ($query) use ($league_id) {
|
||||||
|
// // return $query->where('league_id', $league_id);
|
||||||
|
// // })->when($team_id, function ($query) use ($team_id, $team_position) {
|
||||||
|
// // switch ($team_position) {
|
||||||
|
// // case 'home':
|
||||||
|
// // return $query->where('home_id', $team_id);
|
||||||
|
// // break;
|
||||||
|
// // case 'away':
|
||||||
|
// // return $query->where('away_id', $team_id);
|
||||||
|
// // break;
|
||||||
|
// // default:
|
||||||
|
// // return $query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
|
||||||
|
// // break;
|
||||||
|
// // }
|
||||||
|
// // })->when($start, function ($query) use ($start) {
|
||||||
|
// // return $query->where('starttime', '>=', $start);
|
||||||
|
// // })->when($end, function ($query) use ($end) {
|
||||||
|
// // return $query->where('starttime', '<=', $end);
|
||||||
|
// // })
|
||||||
|
// // ->get();
|
||||||
|
|
||||||
|
// // break;
|
||||||
|
// }
|
||||||
|
|
||||||
$datasets = [];
|
$datasets = [];
|
||||||
$labels = [];
|
$labels = [];
|
||||||
|
|||||||
+39
-81
@@ -2,11 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Filament\Widgets\Data;
|
namespace App\Filament\Widgets\Data;
|
||||||
|
|
||||||
use App\Models\StatisticFixtures;
|
|
||||||
use App\Models\StatistikoEvent;
|
use App\Models\StatistikoEvent;
|
||||||
use App\Models\StatistikoPlayer;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class EventsLoad
|
class LoadEvents
|
||||||
{
|
{
|
||||||
public static $last_query = [];
|
public static $last_query = [];
|
||||||
|
|
||||||
@@ -14,12 +13,24 @@ class EventsLoad
|
|||||||
{
|
{
|
||||||
// dd($filter);
|
// dd($filter);
|
||||||
|
|
||||||
|
if (self::$last_query) {
|
||||||
|
return self::$last_query;
|
||||||
|
}
|
||||||
|
|
||||||
$league_id = (int) $filter['league_id'] ?? 0;
|
$league_id = (int) $filter['league_id'] ?? 0;
|
||||||
|
|
||||||
$team_id = (int) $filter['team_id'] ?? 0;
|
$team_id = (int) $filter['team_id'] ?? 0;
|
||||||
|
|
||||||
$tm_player_id = (int) $filter['tm_player_id'] ?? 0;
|
$tm_player_id = (int) $filter['tm_player_id'] ?? 0;
|
||||||
|
|
||||||
|
$start = $filter['start_date'] ?? 0;
|
||||||
|
|
||||||
|
$end = $filter['end_date'] ?? 0;
|
||||||
|
|
||||||
|
$similar_past_matches = $filter['similar_past_matches'] ?? 0;
|
||||||
|
|
||||||
|
$statistic_type = $filter['statistic_type'] ?? 0;
|
||||||
|
|
||||||
if (! $league_id) {
|
if (! $league_id) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -29,89 +40,34 @@ class EventsLoad
|
|||||||
|
|
||||||
$team_position = $filter['team_position'];
|
$team_position = $filter['team_position'];
|
||||||
|
|
||||||
/**
|
|
||||||
* ACCURACY DATA
|
|
||||||
*/
|
|
||||||
switch ($filter['team_position']) {
|
|
||||||
case 'home':
|
|
||||||
$res = StatisticFixtures::where('league_id', $league_id)->where('home_id', $team_id)->first();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'away':
|
|
||||||
$res = StatisticFixtures::where('league_id', $league_id)->where('away_id', $team_id)->first();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
$res = StatisticFixtures::where('league_id', $league_id)
|
|
||||||
->where(function ($query) use ($team_id) {
|
|
||||||
$query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
|
|
||||||
})->first();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$start = $filter['start_date'] ?? 0;
|
|
||||||
|
|
||||||
$end = $filter['end_date'] ?? 0;
|
|
||||||
|
|
||||||
$similar_past_matches = $filter['similar_past_matches'] ?? 0;
|
|
||||||
|
|
||||||
$statistic_type = $filter['statistic_type'] ?? 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* WITH PLAYER
|
|
||||||
*/
|
|
||||||
$tm_player_id = $filter['tm_player_id'];
|
|
||||||
|
|
||||||
if ($tm_player_id) {
|
|
||||||
$matches_played = StatistikoPlayer::where('tm_player_id', (int) $tm_player_id)->pluck('match_id')->toArray();
|
|
||||||
} else {
|
|
||||||
$matches_played = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* STATTISTIC DATA
|
* STATTISTIC DATA
|
||||||
*/
|
*/
|
||||||
switch ($filter['team_position']) {
|
$res = StatistikoEvent::where('league_id', $league_id)
|
||||||
case 'home':
|
->where(function ($query) use ($team_id, $team_position) {
|
||||||
$res = StatistikoEvent::where('league_id', $league_id)
|
switch ($team_position) {
|
||||||
->where('home_id', '=', $team_id)
|
case 'home':
|
||||||
->when($matches_played, function ($query) use ($matches_played) {
|
return $query->where('home_id', '=', $team_id);
|
||||||
return $query->whereIn('match_id', $matches_played);
|
case 'away':
|
||||||
})->when($start, function ($query) use ($start) {
|
return $query->where('away_id', '=', $team_id);
|
||||||
return $query->where('starttime', '>=', $start);
|
default:
|
||||||
})->when($end, function ($query) use ($end) {
|
return $query->where('home_id', '=', $team_id)
|
||||||
return $query->where('starttime', '<=', $end);
|
->orWhere('away_id', '=', $team_id);
|
||||||
})
|
}
|
||||||
->get();
|
})
|
||||||
break;
|
->when($start, function ($query) use ($start) {
|
||||||
|
return $query->where('starttime', '>=', $start);
|
||||||
|
})->when($end, function ($query) use ($end) {
|
||||||
|
return $query->where('starttime', '<=', $end);
|
||||||
|
})
|
||||||
|
->orderBy('starttime')
|
||||||
|
->get();
|
||||||
|
|
||||||
case 'away':
|
// dd($res);
|
||||||
$res = StatistikoEvent::where('league_id', $league_id)
|
|
||||||
->where('away_id', '=', $team_id)
|
|
||||||
->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);
|
|
||||||
})
|
|
||||||
->get();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
$total = count($res);
|
||||||
$res = StatistikoEvent::where('league_id', $league_id)
|
// Log::info($res);
|
||||||
->where(function ($query) use ($team_id) {
|
// Log::info($total);
|
||||||
$query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
|
|
||||||
})
|
|
||||||
->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);
|
|
||||||
})->get();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$datasets = [];
|
$datasets = [];
|
||||||
$labels = [];
|
$labels = [];
|
||||||
@@ -243,6 +199,8 @@ class EventsLoad
|
|||||||
'labels' => $labels,
|
'labels' => $labels,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
self::$last_query = $data;
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+42
-45
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Filament\Widgets\Data;
|
namespace App\Filament\Widgets\Data;
|
||||||
|
|
||||||
use App\Models\StatistikoPlayer;
|
use App\Models\StatistikoEvent;
|
||||||
|
|
||||||
class PlayerLoad
|
class LoadPlayer
|
||||||
{
|
{
|
||||||
public static $last_query = [];
|
public static $last_query = [];
|
||||||
|
|
||||||
@@ -12,6 +12,10 @@ class PlayerLoad
|
|||||||
{
|
{
|
||||||
// dd($filter);
|
// dd($filter);
|
||||||
|
|
||||||
|
if (self::$last_query) {
|
||||||
|
return self::$last_query;
|
||||||
|
}
|
||||||
|
|
||||||
// "team_position" => "all"
|
// "team_position" => "all"
|
||||||
// "statistic_type" => "gls"
|
// "statistic_type" => "gls"
|
||||||
// "similar_past_matches" => "none"
|
// "similar_past_matches" => "none"
|
||||||
@@ -37,6 +41,18 @@ class PlayerLoad
|
|||||||
|
|
||||||
$tm_player_id = (int) $filter['tm_player_id'] ?? 0;
|
$tm_player_id = (int) $filter['tm_player_id'] ?? 0;
|
||||||
|
|
||||||
|
$team_position = $filter['team_position'];
|
||||||
|
|
||||||
|
$player_on_field = $filter['player_on_field'];
|
||||||
|
|
||||||
|
$statistic_type = $filter['statistic_type'] ?? 0;
|
||||||
|
|
||||||
|
$similar_past_matches = $filter['similar_past_matches'] ?? 0;
|
||||||
|
|
||||||
|
$start = $filter['start_date'] ?? 0;
|
||||||
|
|
||||||
|
$end = $filter['end_date'] ?? 0;
|
||||||
|
|
||||||
if (! $league_id) {
|
if (! $league_id) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -47,49 +63,28 @@ class PlayerLoad
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$team_position = $filter['team_position'];
|
/**
|
||||||
|
* STATTISTIC DATA
|
||||||
$player_on_field = $filter['player_on_field'];
|
*/
|
||||||
|
$res = StatistikoEvent::where('league_id', $league_id)
|
||||||
if (self::$last_query) {
|
->where(function ($query) use ($team_id, $team_position) {
|
||||||
$res = self::$last_query;
|
switch ($team_position) {
|
||||||
} else {
|
case 'home':
|
||||||
|
return $query->where('home_id', '=', $team_id);
|
||||||
$res = StatistikoPlayer::with('event')->where('tm_player_id', $tm_player_id)
|
case 'away':
|
||||||
->when($team_position, function ($query) use ($team_id, $team_position) {
|
return $query->where('away_id', '=', $team_id);
|
||||||
/**
|
default:
|
||||||
* TEAM HOME/AWAY
|
return $query->where('home_id', '=', $team_id)
|
||||||
*/
|
->orWhere('away_id', '=', $team_id);
|
||||||
switch ($team_position) {
|
}
|
||||||
case 'home':
|
})
|
||||||
return $query->where('activeteam_id', $team_id);
|
->when($matches_played, function ($query) use ($matches_played) {
|
||||||
break;
|
return $query->whereIn('match_id', $matches_played);
|
||||||
|
})->when($start, function ($query) use ($start) {
|
||||||
case 'away':
|
return $query->where('starttime', '>=', $start);
|
||||||
return $query->where('activeteam_id', '!=', $team_id);
|
})->when($end, function ($query) use ($end) {
|
||||||
break;
|
return $query->where('starttime', '<=', $end);
|
||||||
}
|
})->first();
|
||||||
})->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();
|
|
||||||
|
|
||||||
self::$last_query = $res;
|
|
||||||
}
|
|
||||||
|
|
||||||
$statistic_type = $filter['statistic_type'] ?? 0;
|
|
||||||
|
|
||||||
// $fields = 'goals,fouls,offsides,shots_on_target,shots_off_target, subtype_event_during_the_match';
|
|
||||||
|
|
||||||
$labels = [];
|
$labels = [];
|
||||||
$datasets = [];
|
$datasets = [];
|
||||||
@@ -142,6 +137,8 @@ class PlayerLoad
|
|||||||
'labels' => $labels,
|
'labels' => $labels,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
self::$last_query = $data;
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Filament\Widgets;
|
namespace App\Filament\Widgets;
|
||||||
|
|
||||||
use App\Filament\Widgets\Data\EventsLoad;
|
use App\Filament\Widgets\Data\LoadEvents;
|
||||||
use App\Filament\Widgets\Data\EventsLoadAspGoal;
|
|
||||||
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
||||||
use Filament\Widgets\StatsOverviewWidget;
|
use Filament\Widgets\StatsOverviewWidget;
|
||||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||||
@@ -12,15 +11,13 @@ class StatsMedianAverage extends StatsOverviewWidget
|
|||||||
{
|
{
|
||||||
use InteractsWithPageFilters;
|
use InteractsWithPageFilters;
|
||||||
|
|
||||||
|
protected ?string $pollingInterval = null;
|
||||||
|
|
||||||
protected function getStats(): array
|
protected function getStats(): array
|
||||||
{
|
{
|
||||||
$filters = $this->filters;
|
$filters = $this->filters;
|
||||||
|
|
||||||
if ($filters['similar_past_matches'] == 'none') {
|
$data = LoadEvents::load($filters);
|
||||||
$data = EventsLoad::load($filters);
|
|
||||||
} else {
|
|
||||||
$data = EventsLoadAspGoal::load($filters);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! isset($data['datasets'][0])) {
|
if (! isset($data['datasets'][0])) {
|
||||||
return [];
|
return [];
|
||||||
|
|||||||
Reference in new issue
Block a user