ImportPlayer add cars and penalty
This commit is contained in:
1 parent
d7d4ab9ea1
commit
314ab7885b
14 files changed
+308
-37
No files matched your search
@@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Statistics;
|
||||
|
||||
class StatisticEvents
|
||||
{
|
||||
public static function load($filter) {}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ class ImportPlayer
|
||||
{
|
||||
public static function run(string $filePath): void
|
||||
{
|
||||
$fieldnames = ['activeteam_id', 'playersubstitute_id', 'goals', 'assists', 'own_goals', 'shots_on_target', 'shots_off_target', 'shots_blocked', 'fouls', 'was_fouled', 'offsides', 'possessions_lost', 'total_tackles', 'touches', 'total_cross', 'cross_done', 'total_dribbles', 'dribbles_won', 'total_ground_duels', 'total_ground_duels_won', 'total_aerial_duels', 'total_duels_aerial_won', 'total_pass', 'pass', 'total_long_balls', 'long_balls', 'blocked_shots', 'clearances', 'dribbled_past', 'hit_woodwork', 'interceptions', 'key_pass', 'last_man_tackle', 'dispossessed', 'clearance_off_line', 'bcc', 'bcm', 'errors_lead_to_a_goal', 'errors_lead_to_a_shot', 'penalty_committed', 'penalty_miss', 'penalty_save', 'penalty_won', 'saves', 'saves_from_in_box', 'total_runs_out', 'runs_out', 'punches', 'good_high_claim', 'minutes_played', 'lineup', 'minute_event_during_the_match', 'type_event_during_the_match', 'description_event_during_the_match', 'subtype_event_during_the_match', 'player_position', 'playerrating_value'];
|
||||
$fieldnames = ['activeteam_id', 'playersubstitute_id', 'goals', 'assists', 'own_goals', 'shots_on_target', 'shots_off_target', 'shots_blocked', 'fouls', 'was_fouled', 'offsides', 'possessions_lost', 'total_tackles', 'touches', 'total_cross', 'cross_done', 'total_dribbles', 'dribbles_won', 'total_ground_duels', 'total_ground_duels_won', 'total_aerial_duels', 'total_duels_aerial_won', 'total_pass', 'pass', 'total_long_balls', 'long_balls', 'blocked_shots', 'clearances', 'dribbled_past', 'hit_woodwork', 'interceptions', 'key_pass', 'last_man_tackle', 'dispossessed', 'clearance_off_line', 'bcc', 'bcm', 'errors_lead_to_a_goal', 'errors_lead_to_a_shot', 'penalty_committed', 'penalty_miss', 'penalty_save', 'penalty_won', 'saves', 'saves_from_in_box', 'total_runs_out', 'runs_out', 'punches', 'good_high_claim', 'minutes_played', 'lineup', 'minute_event_during_the_match', 'type_event_during_the_match', 'description_event_during_the_match', 'subtype_event_during_the_match', 'card_yellow', 'card_yellowred', 'card_red', 'ingamepenalty_missed', 'penaltyshoutout_scored', 'penaltyshoutout_missed', 'player_position', 'playerrating_value'];
|
||||
|
||||
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
|
||||
->getRows()
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Actions\LoadStatisticFixturesLeaguesOptions;
|
||||
use App\Filament\Widgets\MedianAverageWidget;
|
||||
use App\Filament\Widgets\MedianAverage;
|
||||
use App\Filament\Widgets\MovingAverageChart;
|
||||
use App\Filament\Widgets\MovingAverageChartPlayer;
|
||||
use App\Filament\Widgets\PunctualChart;
|
||||
use App\Filament\Widgets\PunctualChartPlayer;
|
||||
use App\Models\Element;
|
||||
use App\Models\StatisticFixtures;
|
||||
use App\Models\StatistikoDetail;
|
||||
@@ -13,7 +15,6 @@ use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Slider;
|
||||
use Filament\Pages\Dashboard as BaseDashboard;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
@@ -75,6 +76,16 @@ class Statistic extends BaseDashboard
|
||||
->searchable()
|
||||
->live()
|
||||
->label('Team'),
|
||||
|
||||
Select::make('team_position')
|
||||
->prefixIcon('phosphor-map-pin')
|
||||
->default('all')
|
||||
->selectablePlaceholder(false)
|
||||
->options([
|
||||
'all' => 'All',
|
||||
'home' => 'Home',
|
||||
'away' => 'Away',
|
||||
]),
|
||||
DatePicker::make('start_date')
|
||||
->native(false)
|
||||
->prefixIcon('phosphor-calendar')
|
||||
@@ -93,7 +104,7 @@ class Statistic extends BaseDashboard
|
||||
->color('gray')
|
||||
->action(fn (Set $set) => $set('end_date', null))
|
||||
),
|
||||
])->columns(4)
|
||||
])->columns(5)
|
||||
->columnSpanFull(),
|
||||
Grid::make()
|
||||
->schema([
|
||||
@@ -106,14 +117,14 @@ class Statistic extends BaseDashboard
|
||||
return StatistikoDetail::where('txodds_id', $get('team_id'))->pluck('name', 'tm_player_id');
|
||||
})
|
||||
->live(),
|
||||
Select::make('team_position')
|
||||
->prefixIcon('phosphor-map-pin')
|
||||
Select::make('player_on_field')
|
||||
->prefixIcon('phosphor-watch')
|
||||
->default('all')
|
||||
->selectablePlaceholder(false)
|
||||
->options([
|
||||
'all' => 'All',
|
||||
'home' => 'Home',
|
||||
'away' => 'Away',
|
||||
'lineup' => 'Lineup',
|
||||
'substituted' => 'Substituted',
|
||||
]),
|
||||
Select::make('statistic_type')
|
||||
->prefixIcon('phosphor-cell-signal-full')
|
||||
@@ -178,9 +189,11 @@ class Statistic extends BaseDashboard
|
||||
protected function getFooterWidgets(): array
|
||||
{
|
||||
return [
|
||||
MedianAverageWidget::make(),
|
||||
MedianAverage::make(),
|
||||
PunctualChart::make(),
|
||||
MovingAverageChart::make(),
|
||||
PunctualChartPlayer::make(),
|
||||
// MovingAverageChartPlayer::make(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Statistics;
|
||||
namespace App\Filament\Widgets\DB;
|
||||
|
||||
use App\Models\StatisticFixtures;
|
||||
use App\Models\StatistikoEvent;
|
||||
use App\Models\StatistikoPlayer;
|
||||
|
||||
class LoadEvents
|
||||
{
|
||||
@@ -21,6 +22,8 @@ class LoadEvents
|
||||
|
||||
$team_id = (int) $filter['team_id'] ?? 0;
|
||||
|
||||
$tm_player_id = (int) $filter['tm_player_id'] ?? 0;
|
||||
|
||||
if (! $league_id) {
|
||||
return [];
|
||||
}
|
||||
@@ -58,6 +61,17 @@ class LoadEvents
|
||||
|
||||
$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
|
||||
*/
|
||||
@@ -65,7 +79,9 @@ class LoadEvents
|
||||
case 'home':
|
||||
$res = StatistikoEvent::where('league_id', $league_id)
|
||||
->where('home_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);
|
||||
@@ -76,7 +92,9 @@ class LoadEvents
|
||||
case 'away':
|
||||
$res = StatistikoEvent::where('league_id', $league_id)
|
||||
->where('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);
|
||||
@@ -89,7 +107,9 @@ class LoadEvents
|
||||
->where(function ($query) use ($team_id) {
|
||||
$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);
|
||||
@@ -106,7 +126,7 @@ class LoadEvents
|
||||
}
|
||||
|
||||
foreach ($res as $value) {
|
||||
$labels[] = $value['starttime']->format('d. M.y');
|
||||
$labels[] = $value['starttime']->format('d.M.y');
|
||||
|
||||
if ($team_position == 'home') {
|
||||
|
||||
+18
-2
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Statistics;
|
||||
namespace App\Filament\Widgets\DB;
|
||||
|
||||
use App\Models\StatisticFixtures;
|
||||
use App\Models\StatistikoEvent;
|
||||
use App\Models\StatistikoPlayer;
|
||||
|
||||
class LoadEventsAspGoal
|
||||
{
|
||||
@@ -67,12 +68,25 @@ class LoadEventsAspGoal
|
||||
$total_range = [$exp_total - $accuracy, $exp_total + $accuracy];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
$similar_past_matches = $filter['similar_past_matches'] ?? 0;
|
||||
|
||||
switch ($similar_past_matches) {
|
||||
case 'league':
|
||||
$res = StatistikoEvent::when($league_id, function ($query) use ($league_id) {
|
||||
return $query->where('league_id', $league_id);
|
||||
})->when($matches_played, function ($query) use ($matches_played) {
|
||||
return $query->whereIn('match_id', $matches_played);
|
||||
})->when($handicap_range, function ($query) use ($handicap_range) {
|
||||
return $query->whereBetween('exp_handicap', $handicap_range);
|
||||
})->when($total_range, function ($query) use ($total_range) {
|
||||
@@ -88,6 +102,8 @@ class LoadEventsAspGoal
|
||||
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) {
|
||||
@@ -132,7 +148,7 @@ class LoadEventsAspGoal
|
||||
}
|
||||
|
||||
foreach ($res as $value) {
|
||||
$labels[] = $value['starttime']->format('d. M.y');
|
||||
$labels[] = $value['starttime']->format('d.M.y');
|
||||
|
||||
// dd($filter);
|
||||
|
||||
Whitespace-only changes.
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets\DB;
|
||||
|
||||
use App\Models\StatistikoPlayer;
|
||||
|
||||
class LoadPunctualChartPlayer
|
||||
{
|
||||
public static function load($filter)
|
||||
{
|
||||
// dd($filter);
|
||||
|
||||
// "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;
|
||||
|
||||
$tm_player_id = (int) $filter['tm_player_id'] ?? 0;
|
||||
|
||||
if (! $league_id) {
|
||||
return [];
|
||||
}
|
||||
if (! $team_id) {
|
||||
return [];
|
||||
}
|
||||
if (! $tm_player_id) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$team_position = $filter['team_position'];
|
||||
|
||||
$player_on_field = $filter['player_on_field'];
|
||||
|
||||
$res = StatistikoPlayer::with('event')->where('tm_player_id', $tm_player_id)
|
||||
->when($team_position, function ($query) use ($team_id, $team_position) {
|
||||
/**
|
||||
* TEAM HOME/AWAY
|
||||
*/
|
||||
switch ($team_position) {
|
||||
case 'home':
|
||||
return $query->where('activeteam_id', $team_id);
|
||||
break;
|
||||
|
||||
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();
|
||||
|
||||
$statistic_type = $filter['statistic_type'] ?? 0;
|
||||
|
||||
// $fields = 'goals,fouls,offsides,shots_on_target,shots_off_target, subtype_event_during_the_match';
|
||||
|
||||
$labels = [];
|
||||
foreach ($res as $key => $value) {
|
||||
|
||||
if (isset($value->event->starttime)) {
|
||||
|
||||
$labels[] = $value->event->starttime->format('d.M.y');
|
||||
|
||||
switch ($statistic_type) {
|
||||
case 'gls':
|
||||
$val = (int) $value['goals'];
|
||||
break;
|
||||
case 'crn':
|
||||
$val = (int) 0;
|
||||
break;
|
||||
case 'fls':
|
||||
$val = (int) $value['fouls'];
|
||||
break;
|
||||
case 'ofs':
|
||||
$val = (int) $value['offsides'];
|
||||
break;
|
||||
case 'crd':
|
||||
$val = (int) $value['crd_h'];
|
||||
break;
|
||||
case 'snt':
|
||||
$val = (int) $value['shots_on_target'];
|
||||
break;
|
||||
case 'tsh':
|
||||
$val = (int) $value['shots_off_target'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$datasets[] = $val;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => ucfirst($team_position),
|
||||
'data' => $datasets,
|
||||
'fill' => true,
|
||||
'tension' => 0.5,
|
||||
'borderColor' => '#36A2EB',
|
||||
],
|
||||
],
|
||||
'labels' => $labels,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Statistics;
|
||||
namespace App\Filament\Widgets\DB;
|
||||
|
||||
class MoveingAverage
|
||||
{
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Statistics;
|
||||
namespace App\Filament\Widgets\DB;
|
||||
|
||||
class StatisticType
|
||||
{
|
||||
+3
-3
@@ -2,13 +2,13 @@
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Actions\Statistics\LoadEvents;
|
||||
use App\Actions\Statistics\LoadEventsAspGoal;
|
||||
use App\Filament\Widgets\DB\LoadEvents;
|
||||
use App\Filament\Widgets\DB\LoadEventsAspGoal;
|
||||
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
||||
use Filament\Widgets\StatsOverviewWidget;
|
||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||
|
||||
class MedianAverageWidget extends StatsOverviewWidget
|
||||
class MedianAverage extends StatsOverviewWidget
|
||||
{
|
||||
use InteractsWithPageFilters;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Actions\Statistics\LoadEvents;
|
||||
use App\Actions\Statistics\MoveingAverage;
|
||||
use App\Actions\Statistics\StatisticType;
|
||||
use App\Filament\Widgets\DB\LoadEvents;
|
||||
use App\Filament\Widgets\DB\MoveingAverage;
|
||||
use App\Filament\Widgets\DB\StatisticType;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
||||
|
||||
@@ -26,7 +26,7 @@ class MovingAverageChart extends ChartWidget
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return 'Moving Average';
|
||||
return 'Events Moving Average';
|
||||
}
|
||||
|
||||
protected function getData(): array
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Actions\Statistics\LoadEvents;
|
||||
use App\Actions\Statistics\StatisticType;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
||||
|
||||
class MovingAverageChartPlayer extends ChartWidget
|
||||
{
|
||||
use InteractsWithPageFilters;
|
||||
|
||||
protected ?string $pollingInterval = null;
|
||||
|
||||
public ?string $header;
|
||||
|
||||
protected ?array $options = [
|
||||
'plugins' => [
|
||||
'legend' => [
|
||||
'display' => false,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return 'Player Moving Average';
|
||||
}
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
$this->heading = StatisticType::get($this->filters);
|
||||
|
||||
$data = LoadEvents::load($this->filters);
|
||||
|
||||
if ($data) {
|
||||
// MoveingAveragePlayer::get($data);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getType(): string
|
||||
{
|
||||
return 'line';
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,8 @@
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
// use App\Actions\Statistics\StatisticEvents;
|
||||
use App\Actions\Statistics\LoadEvents;
|
||||
use App\Actions\Statistics\StatisticType;
|
||||
use App\Filament\Widgets\DB\LoadEvents;
|
||||
use App\Filament\Widgets\DB\StatisticType;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
||||
|
||||
@@ -26,7 +25,7 @@ class PunctualChart extends ChartWidget
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return 'Punctual';
|
||||
return 'Events Punctual';
|
||||
}
|
||||
|
||||
protected function getData(): array
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Filament\Widgets\DB\LoadPunctualChartPlayer;
|
||||
use App\Filament\Widgets\DB\StatisticType;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
||||
|
||||
class PunctualChartPlayer extends ChartWidget
|
||||
{
|
||||
use InteractsWithPageFilters;
|
||||
|
||||
protected ?string $pollingInterval = null;
|
||||
|
||||
public ?string $header;
|
||||
|
||||
protected ?array $options = [
|
||||
'plugins' => [
|
||||
'legend' => [
|
||||
'display' => false,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return 'Player Punctual';
|
||||
}
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
if ($this->filters['statistic_type'] == 'crn') {
|
||||
return [];
|
||||
}
|
||||
|
||||
$this->heading = StatisticType::get($this->filters);
|
||||
|
||||
$data = LoadPunctualChartPlayer::load($this->filters);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getType(): string
|
||||
{
|
||||
return 'line';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user