diff --git a/app/Actions/PlayerPerSeason.php b/app/Actions/PlayerPerSeason.php
deleted file mode 100644
index fda96fd3..00000000
--- a/app/Actions/PlayerPerSeason.php
+++ /dev/null
@@ -1,113 +0,0 @@
-where('is_active', 1)->select('ss_player_id', 'ss_team_id')->get();
-
- foreach ($res as $val) {
-
- $collection = [];
-
- $res2 = StatistikoPlayer::with('event')->where('ss_player_id', $val->ss_player_id)->get();
-
- foreach ($res2 as $val2) {
-
- if (isset($val2->event->season)) {
- if (! isset($collection['total'])) {
- $collection['total']['events_played_home'] = 0;
- $collection['total']['events_played_away'] = 0;
- $collection['total']['minutes_played_home'] = 0;
- $collection['total']['minutes_played_away'] = 0;
- $collection['total']['goals'] = 0;
- $collection['total']['fouls'] = 0;
- $collection['total']['offsides'] = 0;
- $collection['total']['shots_on_target'] = 0;
- $collection['total']['shots_off_target'] = 0;
- $collection['total']['cards'] = 0;
- }
- if (! isset($collection[$val2->event->season])) {
- $collection[$val2->event->season]['events_played_home'] = 0;
- $collection[$val2->event->season]['events_played_away'] = 0;
- $collection[$val2->event->season]['minutes_played_home'] = 0;
- $collection[$val2->event->season]['minutes_played_away'] = 0;
- $collection[$val2->event->season]['goals'] = 0;
- $collection[$val2->event->season]['fouls'] = 0;
- $collection[$val2->event->season]['cards'] = 0;
- $collection[$val2->event->season]['offsides'] = 0;
- $collection[$val2->event->season]['shots_on_target'] = 0;
- $collection[$val2->event->season]['shots_off_target'] = 0;
- }
-
- if ((int) $val2->minutes_played > 0) {
- if ($val2->activeteam_id == $val2->event->home_id) {
- $collection[$val2->event->season]['events_played_home'] += 1;
- $collection[$val2->event->season]['minutes_played_home'] += $val2->minutes_played;
- $collection['total']['events_played_home'] += 1;
- $collection['total']['minutes_played_home'] += $val2->minutes_played;
- } elseif ($val2->activeteam_id == $val2->event->away_id) {
-
- $collection[$val2->event->season]['events_played_away'] += 1;
- $collection[$val2->event->season]['minutes_played_away'] += $val2->minutes_played;
- $collection['total']['minutes_played_away'] += 1;
- $collection['total']['minutes_played_away'] += $val2->minutes_played;
- }
-
- $cards = $val2->card_yellow + $val2->card_yellowred + $val2->card_red;
-
- $collection[$val2->event->season]['goals'] += $val2->goals;
- $collection[$val2->event->season]['fouls'] += $val2->fouls;
- $collection[$val2->event->season]['cards'] += $cards;
- $collection[$val2->event->season]['offsides'] += $val2->offsides;
- $collection[$val2->event->season]['shots_on_target'] += $val2->shots_on_target;
- $collection[$val2->event->season]['shots_off_target'] += $val2->shots_off_target;
-
- $collection['total']['goals'] += $val2->goals;
- $collection['total']['fouls'] += $val2->fouls;
- $collection['total']['cards'] += $cards;
- $collection['total']['offsides'] += $val2->offsides;
- $collection['total']['shots_on_target'] += $val2->shots_on_target;
- $collection['total']['shots_off_target'] += $val2->shots_off_target;
- }
- }
- }
-
- foreach ($collection as $season => $row) {
- if ($val->ss_team_id && $val->ss_player_id) {
-
- SofaScorePlayerPerSeason::updateOrCreate(
- [
- 'ss_player_id' => $val->ss_player_id,
- 'ss_team_id' => $val->ss_team_id,
- 'season' => $season,
- ],
- [
- 'events_played_home' => $row['events_played_home'],
- 'events_played_away' => $row['events_played_away'],
- 'minutes_played_home' => $row['minutes_played_home'],
- 'minutes_played_away' => $row['minutes_played_away'],
- 'goals' => $row['goals'],
- 'fouls' => $row['fouls'],
- 'cards' => $row['cards'],
- 'offsides' => $row['offsides'],
- 'shots_on_target' => $row['shots_on_target'],
- 'shots_off_target' => $row['shots_off_target'],
- ]
- );
- }
- }
- }
- }
-}
diff --git a/app/Console/Commands/Upd.php b/app/Console/Commands/Upd.php
index ae05eaf6..bbcb6361 100644
--- a/app/Console/Commands/Upd.php
+++ b/app/Console/Commands/Upd.php
@@ -11,7 +11,7 @@ class Upd extends Command
protected $signature = 'update:player {--d}';
- protected $description = 'update sofa_score_player_per_seasons';
+ protected $description = 'update ss_player_seasons';
public function handleUpdate(int $playerCount): void
{
diff --git a/app/Livewire/BoardDispatcher.php b/app/Livewire/BoardDispatcher.php
index 9622fbff..41f24880 100644
--- a/app/Livewire/BoardDispatcher.php
+++ b/app/Livewire/BoardDispatcher.php
@@ -25,7 +25,6 @@ use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Enums\FiltersLayout;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
-use Illuminate\Support\Facades\Log;
use Illuminate\Support\HtmlString;
use Livewire\Attributes\On;
use Livewire\Component;
@@ -40,6 +39,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
public array $sourceRecords = [];
public array $filters = [];
+
public int $player_on_field_counter = 0;
// slider
@@ -58,7 +58,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
public bool $rangeXDisabled = true;
- public string $ss_team_name = '';
+ public string $team_name = '';
public array $lineupsMap = [
'3313' => [9, 16, 23, 11, 18, 25, 19, 6, 34, 21],
@@ -176,7 +176,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
{
$this->filters = $filters;
- $this->ss_team_name = SofaScoreRosa::where('ss_team_id', $filters['team_id'])->value('ss_team_name');
+ $this->team_name = SofaScoreRosa::where('ss_team_id', $filters['team_id'])->value('ss_team_name');
$this->sourceRecords = PlayerCalculator::load($filters);
@@ -205,7 +205,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
Crd
Foot
Evt
- Ømin
+ Min Ø
');
}
@@ -245,26 +245,19 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
->modalWidth(Width::ExtraLarge)
->modalSubmitAction(false)
->modalCancelAction(false)
- ->modalContent(fn() => view('filament.modals.position-abbreviation')),
+ ->modalContent(fn () => view('filament.modals.position-abbreviation')),
Action::make('reset')
->hiddenLabel()
->size(Size::Small)
->tooltip('Remove all players from field')
->icon('phosphor-arrows-clockwise')
- ->action(fn() => $this->clearResultTable()),
- // Action::make('calculate')
- // ->hiddenLabel()
- // ->tooltip('Calculate expected values')
- // ->size(Size::Small)
- // ->icon('phosphor-calculator')
- // ->disabled($this->calculationDisabled)
- // ->action(fn () => $this->calculateAspg()),
+ ->action(fn () => $this->clearResultTable()),
Action::make('copy')
->tooltip('Copy results for pasting into a spread sheet')
->hiddenLabel()
->size(Size::Small)
->icon('phosphor-copy')
- ->action(fn() => $this->copyResult()),
+ ->action(fn () => $this->copyResult()),
])
/**
* WICHTIG: Da Filament v5 zwingend eine Query braucht, nutzen wir ein
@@ -277,11 +270,11 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
->columns([
ViewColumn::make('drag_card')
->columnSpanFull()
- ->label(fn() => $this->getHeadingTable())
+ ->label(fn () => $this->getHeadingTable())
->view('filament.tables.columns.drag-card'),
])
->filters([
- SelectFilter::make('position_area')
+ SelectFilter::make('area')
->columnSpanFull()
->native(false)
->options([
@@ -293,7 +286,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
'midfield' => 'Midfield',
'defence' => 'Defence',
'goalkeeper' => 'Goalkeeper',
- ])->modifyFormFieldUsing(fn(Select $component) => $component->allowHtml())
+ ])->modifyFormFieldUsing(fn (Select $component) => $component->allowHtml())
->query(function ($query) {
return $query;
})->indicateUsing(function (array $data): array {
@@ -304,9 +297,9 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
->deferFilters(false)
->records(function () {
$collection = collect($this->sourceRecords);
- $selectedPosition = $this->tableFilters['position_area']['value'] ?? null;
+ $selectedPosition = $this->tableFilters['area']['value'] ?? null;
if (! empty($selectedPosition)) {
- $collection = $collection->where('position_area', $selectedPosition);
+ $collection = $collection->where('area', $selectedPosition);
}
return $collection;
@@ -338,7 +331,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
}
$this->boxes[$boxNumber] = $record;
$this->sourceRecords[$k]['active'] = 1;
- $this->sourceRecords[$k]['position'] = $this->activeBoxes[$boxNumber];
+ $this->sourceRecords[$k]['pos'] = $this->activeBoxes[$boxNumber];
$this->player_on_field_counter++;
}
@@ -372,7 +365,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
foreach ($this->sourceRecords as $k => $record) {
if ($record['id'] == (int) $player_id) {
$this->boxes[$boxNumber] = [];
- $this->sourceRecords[$k]['position'] = '';
+ $this->sourceRecords[$k]['pos'] = '';
$this->sourceRecords[$k]['active'] = 0;
$this->player_on_field_counter--;
@@ -396,7 +389,6 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
$this->boxes[$i] = [];
}
foreach ($this->sourceRecords as $k => $record) {
- $this->sourceRecords[$k]['position'] = '';
$this->sourceRecords[$k]['active'] = 0;
$this->sourceRecords[$k]['gls'] = '';
$this->sourceRecords[$k]['fls'] = '';
@@ -411,45 +403,47 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
public function copyResult()
{
- if ($this->player_on_field_counter < 10)
+ if ($this->player_on_field_counter < 10) {
return;
- // "id" => 787607
- // "name" => "Keno"
- // "preferred_foot" => "Right"
- // "player_position" => "LW"
- // "position_area" => "attack"
- // "player_color" => "warning"
- // "timed_color" => "danger"
- // "events_played" => 7
- // "everage_minutes" => 11
- // "position" => "DC"
- // "active" => 1
+ }
+ // "id" => 1218016
+ // "name" => "Walter Nuñez"
+ // "pos" => "LW"
+ // "foot" => "Right"
+ // "tot_evt" => 2
+ // "tot_min" => 102
+ // "ave_min" => 51
// "gls" => 0
- // "fls" => 0
+ // "fls" => 3
// "ofs" => 0
+ // "crd" => 0
// "snt" => 0
// "tsh" => 0
- // "crd" => 0
+ // "color_evt" => "success"
+ // "area" => "attack"
+ // "color_pos" => "warning"
$header = ['name', 'foot', 'events', 'average min', 'position', 'on field', 'gls', 'fls', 'ofs', 'snt', 'tsh', 'crd'];
- $copystring = implode("\t", $header) . "\n";
+ $copystring = implode("\t", $header)."\n";
foreach ($this->sourceRecords as $row) {
$tmp = [];
$tmp[] = $row['name'];
- $tmp[] = $row['preferred_foot'];
- $tmp[] = $row['events_played'];
- $tmp[] = $row['everage_minutes'];
- if ($row['position'])
- $tmp[] = $row['position'];
- else
- $tmp[] = $row['player_position'];
+ $tmp[] = $row['foot'];
+ $tmp[] = $row['tot_evt'];
+ $tmp[] = $row['ave_min'];
+ if ($row['pos']) {
+ $tmp[] = $row['pos'];
+ } else {
+ $tmp[] = $row['pos_ori'];
+ }
$tmp[] = $row['active'];
$tmp[] = $row['gls'];
$tmp[] = $row['fls'];
$tmp[] = $row['ofs'];
+ $tmp[] = $row['snt'];
$tmp[] = $row['tsh'];
$tmp[] = $row['crd'];
- $copystring .= implode("\t", $tmp) . "\n";
+ $copystring .= implode("\t", $tmp)."\n";
}
$this->js("navigator.clipboard.writeText(`$copystring`)");
}
@@ -465,6 +459,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
$this->sourceRecords[$k]['tsh'] = '';
$this->sourceRecords[$k]['crd'] = '';
}
+
return;
}
// Calcolare Aspettativa Team per GOALS
@@ -479,28 +474,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
$asp_team = $res->exp_away;
}
- // "atr" => 2.8868026211843
- // "id" => 44691
- // "name" => "Maicon"
- // "on_field" => 0
- // "position" => "DC"
- // "sgf" => 1044
- // "smg" => 1044
- // "adg" => 90
- // "as_goals" => 0.044
- // "at_goals" => 67.511
- // "as_cards" => 0.195
- // "at_cards" => 67.54875
- // "as_fouls" => 0.959
- // "at_fouls" => 67.73975
- // "as_offsides" => 0.036
- // "at_offsides" => 67.509
- // "as_total_shots" => 0.525
- // "at_total_shots" => 67.63125
- // "as_shots_on_target" => 0.263
- // "at_shots_on_target" => 67.56575
-
- $player = StatistikoDetail::where('ss_team_id', (int) $team_id)->where('position', '!=', 'GK')->where('is_active', 1)->get();
+ $player = StatistikoDetail::where('ss_team_id', (int) $team_id)->where('pos', '!=', 'GK')->where('is_active', 1)->get();
// Aspettativa Team di Riferimento
// (ATR) = Aspettativa Team * Numero di Giocatori di Team in Rosters (esclusi i portieri) / 10.
@@ -531,7 +505,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
} else {
$tmp['active'] = 0;
}
- $tmp['position'] = $position;
+ $tmp['pos'] = $position;
// Aspettativa di Gioco (AdG) = Somma Goals fatti da Player nel DB / Somma Minuti Giocati da Player (SMG) nel DB * 90.
// Se la SMG è < Y per quel Player prenderemo in considerazione solo l'Aspettativa Statistica (AS).
@@ -555,18 +529,18 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
$bettypes = ['goals', 'cards', 'fouls', 'offsides', 'total_shots', 'shots_on_target'];
foreach ($bettypes as $bettype) {
- $asp_statistica = (float) SofaScorePlayerPosition::where('ss_code', $position)->value('exp_' . $bettype);
- $tmp['asp_statistica_' . $bettype] = $asp_statistica;
+ $asp_statistica = (float) SofaScorePlayerPosition::where('ss_code', $position)->value('exp_'.$bettype);
+ $tmp['asp_statistica_'.$bettype] = $asp_statistica;
if ($somma_minuti < $this->y_value) {
// Se la SMG è < Y per quel Player prenderemo in considerazione solo l'Aspettativa Statistica (AS).
- $tmp['asp_teorica_' . $bettype] = $asp_statistica;
+ $tmp['asp_teorica_'.$bettype] = $asp_statistica;
} else {
// Aspettativa Teorica (AT) Goals = (X * AdG + AS) / (1 + X)
// dove X è un valore che dovrebbe essere parametrizzabile da una interfaccia.
// Il valore iniziale lo fissiamo a X = 3
// (AT)
- $tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
+ $tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
}
}
@@ -580,11 +554,11 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
$bettypes = ['goals', 'cards', 'fouls', 'offsides', 'total_shots', 'shots_on_target'];
foreach ($bettypes as $bettype) {
- $total_bettype = array_sum(array_column($results, 'asp_teorica_' . $bettype));
+ $total_bettype = array_sum(array_column($results, 'asp_teorica_'.$bettype));
foreach ($results as $key => $value) {
// Aspettativa per Player: AP = AT * ATR / TOT AT
- $results[$key]['asp_total_' . $bettype] = $total_bettype;
- $results[$key]['asp_player_' . $bettype] = ((float) $value['asp_team'] * (float) $value['asp_teorica_' . $bettype]) / $total_bettype;
+ $results[$key]['asp_total_'.$bettype] = $total_bettype;
+ $results[$key]['asp_player_'.$bettype] = ((float) $value['asp_team'] * (float) $value['asp_teorica_'.$bettype]) / $total_bettype;
}
}
@@ -592,23 +566,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
// update frontend
foreach ($this->sourceRecords as $k => $record) {
- // "id" => 787607
- // "name" => "Keno"
- // "preferred_foot" => "Right"
- // "player_position" => "LW"
- // "position_area" => "attack"
- // "player_color" => "warning"
- // "timed_color" => "danger"
- // "events_played" => 7
- // "everage_minutes" => 11
- // "position" => "DC"
- // "active" => 1
- // "gls" => 0
- // "fls" => 0
- // "ofs" => 0
- // "snt" => 0
- // "tsh" => 0
- // "crd" => 0
+
foreach ($results as $key => $result) {
// "id" => 44691
// "name" => "Maicon"
@@ -656,7 +614,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
// see if player is in field and if yes get new position
foreach ($this->sourceRecords as $record) {
if ($record['id'] == $ss_player_id) {
- return $record['position'];
+ return $record['pos'];
}
}
diff --git a/app/Livewire/PlayerCalculator.php b/app/Livewire/PlayerCalculator.php
index a27bee8a..447f9341 100644
--- a/app/Livewire/PlayerCalculator.php
+++ b/app/Livewire/PlayerCalculator.php
@@ -2,10 +2,8 @@
namespace App\Livewire;
-use App\Filament\Pages\Selections\Helper\GetSeason;
use App\Filament\Pages\Selections\LoadPositions;
use App\Models\SofaScorePlayerPerSeason;
-use App\Models\StatistikoEvent;
use Filament\Widgets\Concerns\InteractsWithPageFilters;
use Livewire\Component;
@@ -22,129 +20,64 @@ class PlayerCalculator extends Component
public static function load(array $filters)
{
- $team_position = $filters['team_position'];
- $season = $filters['season'];
- $seasonmode = $filters['seasonmode'];
$team_id = (int) $filters['team_id'];
- $season = GetSeason::load($season, $seasonmode);
-
- $matches = StatistikoEvent::whereIn('season', $season)
- ->where(function ($query) use ($team_id, $team_position) {
- switch ($team_position) {
- case 'home':
- return $query->where('home_id', $team_id);
- case 'away':
- return $query->where('away_id', $team_id);
- default:
- return $query->where('home_id', $team_id)
- ->orWhere('away_id', $team_id);
- }
- })->pluck('match_id');
$positions_map = LoadPositions::load();
- $player = SofaScorePlayerPerSeason::with('details')->where('ss_team_id', $team_id)->whereIn('season', $season)->get();
-
- $arr = [];
- foreach ($player as $val) {
- if ($val->details && $val->details->is_active) {
- $player_id = $val->ss_player_id;
- if (! isset($arr[$player_id])) {
- $arr[$player_id]['player_name'] = $val->details->player_name;
- $arr[$player_id]['events_played_home'] = $val->events_played_home;
- $arr[$player_id]['events_played_away'] = $val->events_played_away;
- $arr[$player_id]['minutes_played_home'] = $val->minutes_played_home;
- $arr[$player_id]['minutes_played_away'] = $val->minutes_played_away;
- $arr[$player_id]['preferred_foot'] = $val->details->preferred_foot ?? '';
- $arr[$player_id]['player_position'] = $val->details->position ?? '';
- $arr[$player_id]['color_level'] = round($matches->count() / 3);
- } else {
- $arr[$player_id]['events_played_home'] += $val->events_played_home;
- $arr[$player_id]['events_played_away'] += $val->events_played_away;
- $arr[$player_id]['minutes_played_home'] += $val->minutes_played_home;
- $arr[$player_id]['minutes_played_away'] += $val->minutes_played_away;
- }
- }
- }
+ $player = SofaScorePlayerPerSeason::with('details')->where('season', '=', 'total')->where('ss_team_id', '=', $team_id)->get();
$result = [];
- foreach ($arr as $player_id => $val) {
+ foreach ($player as $val) {
+ $tmp = [];
+ $tmp['id'] = $val->ss_player_id;
+ $tmp['name'] = $val->details->player_name;
+ $tmp['pos_ori'] = $val->details->position;
+ $tmp['pos'] = '';
+ $tmp['foot'] = $val->details->preferred_foot;
+ $tmp['tot_evt'] = $val->total_events;
+ $tmp['tot_min'] = $val->total_min;
+ $tmp['ave_min'] = $val->average_min;
+ $tmp['gls'] = $val->goals;
+ $tmp['fls'] = $val->fouls;
+ $tmp['ofs'] = $val->offsides;
+ $tmp['crd'] = $val->cards;
+ $tmp['snt'] = $val->shots_on_target;
+ $tmp['tsh'] = $val->shots_off_target;
- switch ($team_position) {
- case 'home':
- $events_played = $val['events_played_home'];
- $minues_played = $val['minutes_played_home'];
- break;
- case 'away':
- $events_played = $val['events_played_away'];
- $minues_played = $val['minutes_played_away'];
- break;
- default:
- $events_played = $val['events_played_home'] + $val['events_played_away'];
- $minues_played = $val['minutes_played_home'] + $val['minutes_played_home'];
- break;
- }
-
- $colorlevel = round($matches->count() / 3);
-
- if (in_array($val['player_position'], $positions_map['MIDFIELD'])) {
- $player_position = $val['player_position'];
- $position_area = 'midfield';
- $player_color = 'info';
- } elseif (in_array($val['player_position'], $positions_map['DEFENCE'])) {
- $player_position = $val['player_position'];
- $position_area = 'defence';
- $player_color = 'success';
- } elseif (in_array($val['player_position'], $positions_map['ATTACK'])) {
- $player_position = $val['player_position'];
- $position_area = 'attack';
- $player_color = 'warning';
- } elseif (in_array($val['player_position'], $positions_map['GOALKEEPER'])) {
- $player_position = $val['player_position'];
- $position_area = 'goalkeeper';
- $player_color = 'gray';
- } else {
- $player_position = 'NO SPECIFIC POSITION';
- $position_area = 'non';
- $player_color = 'danger';
- }
-
- $everage_minutes = 0;
- $timed_color = '';
- if ($events_played) {
- $everage_minutes = round($minues_played / $events_played);
- if ($colorlevel > 1 && $events_played < $colorlevel) {
- $timed_color = 'danger';
- } elseif ($events_played < $colorlevel * 2) {
- $timed_color = 'info';
+ $level = round($val->total_events / 3);
+ if ($val->total_events) {
+ if ($level > 1 && $val->total_events < $level) {
+ $tmp['color_evt'] = 'danger';
+ } elseif ($val->total_events < $level * 2) {
+ $tmp['color_evt'] = 'info';
} else {
- $timed_color = 'success';
+ $tmp['color_evt'] = 'success';
}
}
- $result[] = [
- 'id' => $player_id,
- 'name' => $val['player_name'],
- 'preferred_foot' => $val['preferred_foot'],
- 'player_position' => $player_position,
- 'position_area' => $position_area,
- 'player_color' => $player_color,
- 'timed_color' => $timed_color,
- 'events_played' => $events_played,
- 'everage_minutes' => $everage_minutes,
- 'position' => '',
- 'active' => 0,
- 'gls' => 0,
- 'fls' => 0,
- 'ofs' => 0,
- 'snt' => 0,
- 'tsh' => 0,
- 'crd' => 0,
- ];
+ if (in_array($val->details->position, $positions_map['MIDFIELD'])) {
+ $tmp['area'] = 'midfield';
+ $tmp['color_pos'] = 'info';
+ } elseif (in_array($val->details->position, $positions_map['DEFENCE'])) {
+ $tmp['area'] = 'defence';
+ $tmp['color_pos'] = 'success';
+ } elseif (in_array($val->details->position, $positions_map['ATTACK'])) {
+ $tmp['area'] = 'attack';
+ $tmp['color_pos'] = 'warning';
+ } elseif (in_array($val->details->position, $positions_map['GOALKEEPER'])) {
+ $tmp['area'] = 'goalkeeper';
+ $tmp['color_pos'] = 'gray';
+ } else {
+ $tmp['area'] = 'defence';
+ $tmp['color_pos'] = 'success';
+ }
+
+ $result[] = $tmp;
}
- $pos = array_column($result, 'player_position');
- $area = array_column($result, 'position_area');
+ $pos = array_column($result, 'pos');
+ $area = array_column($result, 'area');
+
array_multisort($area, SORT_ASC, $pos, SORT_ASC, $result);
return $result;
diff --git a/app/Models/SofaScorePlayerPerSeason.php b/app/Models/SofaScorePlayerPerSeason.php
index 1ac0678a..f1fed7f7 100644
--- a/app/Models/SofaScorePlayerPerSeason.php
+++ b/app/Models/SofaScorePlayerPerSeason.php
@@ -6,6 +6,8 @@ use Illuminate\Database\Eloquent\Model;
class SofaScorePlayerPerSeason extends Model
{
+ protected $table = 'ss_player_seasons';
+
protected $fillable = [
'ss_player_id',
'ss_team_id',
diff --git a/app/Traits/UpdateHelper.php b/app/Traits/UpdateHelper.php
index 97ccba29..7d22f262 100644
--- a/app/Traits/UpdateHelper.php
+++ b/app/Traits/UpdateHelper.php
@@ -80,7 +80,7 @@ trait UpdateHelper
};
}
- protected function startBenchmark(string $table = 'sofa_score_player_per_seasons'): void
+ protected function startBenchmark(string $table = 'ss_player_seasons'): void
{
$this->startRowCount = DB::table($table)->count();
$this->benchmarkStartTime = microtime(true);
@@ -89,7 +89,7 @@ trait UpdateHelper
$this->startQueries = DB::select("SHOW SESSION STATUS LIKE 'Questions'")[0]->Value;
}
- protected function endBenchmark(string $table = 'sofa_score_player_per_seasons'): void
+ protected function endBenchmark(string $table = 'ss_player_seasons'): void
{
$executionTime = microtime(true) - $this->benchmarkStartTime;
$memoryUsage = round((memory_get_usage() - $this->benchmarkStartMemory) / 1024 / 1024, 2);
@@ -195,14 +195,15 @@ trait UpdateHelper
$collection_1d[] = $row;
}
}
+
SofaScorePlayerPerSeason::upsert(
$collection_1d,
- [
+ uniqueBy: [
'ss_player_id',
'ss_team_id',
'season',
],
- [
+ update: [
'total_events',
'total_min',
'average_min',
diff --git a/database/migrations/2026_06_27_091506_create_sofa_score_player_per_seasons_table.php b/database/migrations/2026_06_27_091506_create_sofa_score_player_per_seasons_table.php
index d7e0a259..98de4172 100644
--- a/database/migrations/2026_06_27_091506_create_sofa_score_player_per_seasons_table.php
+++ b/database/migrations/2026_06_27_091506_create_sofa_score_player_per_seasons_table.php
@@ -11,11 +11,11 @@ return new class extends Migration
*/
public function up(): void
{
- Schema::create('sofa_score_player_per_seasons', function (Blueprint $table) {
+ Schema::create('ss_player_seasons', function (Blueprint $table) {
$table->id();
- $table->integer('ss_player_id')->index();
- $table->integer('ss_team_id')->index();
- $table->string('season')->index();
+ $table->integer('ss_player_id')->index()->default(0);
+ $table->integer('ss_team_id')->index()->default(0);
+ $table->string('season')->index()->default('');
$table->integer('total_events')->default(0)->nullable();
$table->integer('total_min')->default(0)->nullable();
$table->integer('average_min')->default(0)->nullable();
@@ -29,6 +29,7 @@ return new class extends Migration
$table->integer('offsides')->default(0)->nullable();
$table->integer('shots_on_target')->default(0)->nullable();
$table->integer('shots_off_target')->default(0)->nullable();
+ $table->unique(['ss_player_id', 'ss_team_id', 'season']);
$table->timestamps();
});
}
@@ -38,6 +39,6 @@ return new class extends Migration
*/
public function down(): void
{
- Schema::dropIfExists('sofa_score_player_per_seasons');
+ Schema::dropIfExists('ss_player_seasons');
}
};
diff --git a/resources/views/filament/tables/columns/drag-card.blade.php b/resources/views/filament/tables/columns/drag-card.blade.php
index ebab2a9c..d2a8bc63 100644
--- a/resources/views/filament/tables/columns/drag-card.blade.php
+++ b/resources/views/filament/tables/columns/drag-card.blade.php
@@ -1,5 +1,24 @@
@php
$record = $getRecord();
+ /***
+ "id" => 1218016
+ "name" => "Walter Nuñez"
+ "pos_ori" => "LW"
+ "pos" => "LW"
+ "foot" => "Right"
+ "tot_evt" => 2
+ "tot_min" => 102
+ "ave_min" => 51
+ "gls" => 0
+ "fls" => 3
+ "ofs" => 0
+ "crd" => 0
+ "snt" => 0
+ "tsh" => 0
+ "color_evt" => "success"
+ "area" => "attack"
+ "color_pos" => "warning"
+ */
@endphp
@if ($record['active'])
{{ $record['gls'] }}
{{ $record['fls'] }}
{{ $record['ofs'] }}
+ {{ $record['crd'] }}
{{ $record['snt'] }}
{{ $record['tsh'] }}
- {{ $record['crd'] }}
- {{ $record['preferred_foot'] }}
- {{ $record['events_played'] }}
- {{ $record['everage_minutes'] }}
- {{ $record['position'] }}
+ {{ $record['foot'] }}
+ {{ $record['tot_evt'] }}
+ {{ $record['ave_min'] }}
+ {{ $record['pos'] }}
-
- {{ ucfirst($record['player_position']) }}
+
+ {{ ucfirst($record['pos_ori']) }}
@@ -41,14 +60,14 @@
{{ $record['snt'] }}
{{ $record['tsh'] }}
{{ $record['crd'] }}
-
{{ $record['preferred_foot'] }}
-
{{ $record['events_played'] }}
-
{{ $record['everage_minutes'] }}
-
{{ $record['position'] }}
+
{{ $record['foot'] }}
+
{{ $record['tot_evt'] }}
+
{{ $record['ave_min'] }}
+
-
- {{ ucfirst($record['player_position']) }}
+
+ {{ ucfirst($record['pos_ori']) }}
diff --git a/resources/views/livewire/board-dispatcher.blade.php b/resources/views/livewire/board-dispatcher.blade.php
index 1a394f17..9dd08167 100644
--- a/resources/views/livewire/board-dispatcher.blade.php
+++ b/resources/views/livewire/board-dispatcher.blade.php
@@ -1,10 +1,28 @@
+{{--
+ "id" => 1218016
+ "name" => "Walter Nuñez"
+ "pos" => "LW"
+ "foot" => "Right"
+ "tot_evt" => 2
+ "tot_min" => 102
+ "ave_min" => 51
+ "gls" => 0
+ "fls" => 3
+ "ofs" => 0
+ "crd" => 0
+ "snt" => 0
+ "tsh" => 0
+ "color_evt" => "success"
+ "area" => "attack"
+ "color_pos" => "warning"
+--}}
{{ $this->table }}
-
{{ $ss_team_name }}
+
{{ $team_name }}
{{ $this->form }}
Player on field: {{ $player_on_field_counter }}
@@ -40,11 +58,13 @@
}
"
:class="isOver ? 'border-red-500 bg-white/20 ring-2 ring-red-500/50 scale-[1.02]' :
- @if (in_array($benennung, ['SW', 'DR', 'DC', 'DL'])) 'border-gray-800 bg-green-500/40'
+ @if (in_array($benennung, ['SW', 'DR', 'DC', 'DL']))
+ 'border-gray-800 bg-green-500/40'
@elseif (in_array($benennung, ['DM', 'MR', 'MC', 'ML', 'AM']))
'border-gray-800 bg-blue-500/40'
@else
- 'border-gray-800 bg-amber-500/40' @endif"
+ 'border-gray-800 bg-amber-500/40'
+ @endif"
class="border-2 rounded-xl transition-all px-1 pt-0 flex flex-col justify-start transform inset-shadow-sm inset-shadow-white/50 shadow-lg">