diff --git a/app/Livewire/BoardDispatcher.php b/app/Livewire/BoardDispatcher.php index ad6346aa..f110efbc 100644 --- a/app/Livewire/BoardDispatcher.php +++ b/app/Livewire/BoardDispatcher.php @@ -237,12 +237,14 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa Action::make('close') ->size(Size::Small) ->tooltip('Close application') + ->color('success') ->hiddenLabel() ->icon('phosphor-x') ->close(), Action::make('lineups') ->size(Size::Small) ->tooltip('Lineup abbreviation explanation') + ->color('success') ->hiddenLabel() ->icon('phosphor-question-mark') ->slideOver() @@ -250,27 +252,33 @@ 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(fn () => $this->clearResultTable()), + Action::make('calculate') + ->tooltip('Calculate') + ->hiddenLabel() + ->size(Size::Small) + ->icon('phosphor-calculator') + ->action(fn () => $this->calculateAspg()), Action::make('copy_results') ->tooltip('Copy results for pasting into a spread sheet') ->hiddenLabel() ->size(Size::Small) ->icon('phosphor-copy') - ->action(fn() => $this->copyResult()), + ->action(fn () => $this->copyResult()), Action::make('copy_development') ->tooltip('Copy calculation variables') ->hiddenLabel() ->size(Size::Small) - ->hidden(fn() => ! in_array(Auth::user()->id, [1, 2])) + ->hidden(fn () => ! in_array(Auth::user()->id, [1, 2])) ->color('warning') ->icon('phosphor-copy') - ->action(fn() => $this->copyDevelopment()), + ->action(fn () => $this->copyDevelopment()), ]) /** * WICHTIG: Da Filament v5 zwingend eine Query braucht, nutzen wir ein @@ -283,7 +291,7 @@ 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([ @@ -299,7 +307,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 { @@ -381,7 +389,6 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa } } - public function storePlacement() { $store = []; @@ -472,9 +479,9 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa foreach ($this->calculationVariables as $row) { if ($copystring == '') { $keys = array_keys($row); - $copystring .= implode(";", $keys) . "\n"; + $copystring .= implode(';', $keys)."\n"; } - $copystring .= implode(";", $row) . "\n"; + $copystring .= implode(';', $row)."\n"; } $this->js("navigator.clipboard.writeText(`$copystring`)"); @@ -490,7 +497,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa return; } $header = ['name', 'foot', 'events', 'average min', 'position', 'on field', 'gls', 'fls', 'ofs', 'snt', 'tsh', 'crd']; - $copystring = implode(";", $header) . "\n"; + $copystring = implode(';', $header)."\n"; foreach ($this->sourceRecords as $row) { $tmp = []; $tmp[] = $row['name']; @@ -510,7 +517,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa $tmp[] = $row['tsh']; $tmp[] = $row['crd']; - $copystring .= implode(",", $tmp) . "\n"; + $copystring .= implode(',', $tmp)."\n"; } $this->js("navigator.clipboard.writeText(`$copystring`)"); @@ -620,74 +627,73 @@ 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; switch ($bettype) { case 'goals': if ($val->total_min < $this->y_value || $val->goals == 0) { - $tmp['asp_gioco_' . $bettype] = $asp_statistica; - $tmp['asp_teorica_' . $bettype] = $asp_statistica; + $tmp['asp_gioco_'.$bettype] = $asp_statistica; + $tmp['asp_teorica_'.$bettype] = $asp_statistica; } else { $asp_gioco = $val->goals / $val->total_min * 90; - $tmp['asp_gioco_' . $bettype] = $asp_gioco; - $tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); + $tmp['asp_gioco_'.$bettype] = $asp_gioco; + $tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); } break; case 'cards': if ($val->total_min < $this->y_value || $val->cards == 0) { - $tmp['asp_gioco_' . $bettype] = $asp_statistica; - $tmp['asp_teorica_' . $bettype] = $asp_statistica; + $tmp['asp_gioco_'.$bettype] = $asp_statistica; + $tmp['asp_teorica_'.$bettype] = $asp_statistica; } else { $asp_gioco = $val->cards / $val->total_min * 90; - $tmp['asp_gioco_' . $bettype] = $asp_gioco; - $tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); + $tmp['asp_gioco_'.$bettype] = $asp_gioco; + $tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); } break; case 'fouls': if ($val->total_min < $this->y_value || $val->fouls == 0) { - $tmp['asp_gioco_' . $bettype] = $asp_statistica; - $tmp['asp_teorica_' . $bettype] = $asp_statistica; + $tmp['asp_gioco_'.$bettype] = $asp_statistica; + $tmp['asp_teorica_'.$bettype] = $asp_statistica; } else { $asp_gioco = $val->fouls / $val->total_min * 90; - $tmp['asp_gioco_' . $bettype] = $asp_gioco; - $tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); + $tmp['asp_gioco_'.$bettype] = $asp_gioco; + $tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); } break; case 'offsides': if ($val->total_min < $this->y_value || $val->offsides == 0) { - $tmp['asp_gioco_' . $bettype] = $asp_statistica; - $tmp['asp_teorica_' . $bettype] = $asp_statistica; + $tmp['asp_gioco_'.$bettype] = $asp_statistica; + $tmp['asp_teorica_'.$bettype] = $asp_statistica; } else { $asp_gioco = $val->offsides / $val->total_min * 90; - $tmp['asp_gioco_' . $bettype] = $asp_gioco; - $tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); + $tmp['asp_gioco_'.$bettype] = $asp_gioco; + $tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); } break; case 'total_shots': if ($val->total_min < $this->y_value || $val->total_shots == 0) { - $tmp['asp_gioco_' . $bettype] = $asp_statistica; - $tmp['asp_teorica_' . $bettype] = $asp_statistica; + $tmp['asp_gioco_'.$bettype] = $asp_statistica; + $tmp['asp_teorica_'.$bettype] = $asp_statistica; } else { $asp_gioco = $val->total_shots / $val->total_min * 90; - $tmp['asp_gioco_' . $bettype] = $asp_gioco; - $tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); + $tmp['asp_gioco_'.$bettype] = $asp_gioco; + $tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); } break; case 'shots_on_target': if ($val->total_min < $this->y_value || $val->shots_on_target == 0) { - $tmp['asp_gioco_' . $bettype] = $asp_statistica; - $tmp['asp_teorica_' . $bettype] = $asp_statistica; + $tmp['asp_gioco_'.$bettype] = $asp_statistica; + $tmp['asp_teorica_'.$bettype] = $asp_statistica; } else { $asp_gioco = $val->shots_on_target / $val->total_min * 90; - $tmp['asp_gioco_' . $bettype] = $asp_gioco; - $tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); + $tmp['asp_gioco_'.$bettype] = $asp_gioco; + $tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); } break; } } - // Calcolare la Somma di tutte le AT (colonna G della Tabella) // Considerare la ATR calcolata allo Step 1 (colonna I della Tabella) // Aspettativa per Player: AP = AT * ATR / TOT AT @@ -700,11 +706,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; } } diff --git a/resources/views/livewire/board-dispatcher.blade.php b/resources/views/livewire/board-dispatcher.blade.php index a69d2b27..36eb79c2 100644 --- a/resources/views/livewire/board-dispatcher.blade.php +++ b/resources/views/livewire/board-dispatcher.blade.php @@ -1,21 +1,3 @@ -{{-- - "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 }} @@ -43,7 +25,7 @@
+ style="background-image: url({{ asset('images/soccerfield-cleand.jpg') }});"> @foreach ($beschriftung as $boxNumber => $benennung) @if ($benennung) @if (in_array($boxNumber, $lineup))