diff --git a/app/Filament/Pages/PlayerProps.php b/app/Filament/Pages/PlayerProps.php index c7420eaa..e1ddc711 100644 --- a/app/Filament/Pages/PlayerProps.php +++ b/app/Filament/Pages/PlayerProps.php @@ -20,7 +20,6 @@ use Filament\Schemas\Components\Utilities\Get; use Filament\Schemas\Components\Utilities\Set; use Filament\Schemas\Schema; use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Facades\Log; use Livewire\Attributes\On; class PlayerProps extends Page implements HasForms @@ -36,7 +35,7 @@ class PlayerProps extends Page implements HasForms ->group(static::getNavigationGroup()) ->icon(static::getNavigationIcon()) ->activeIcon(static::getActiveNavigationIcon()) - ->isActiveWhen(fn() => request()->routeIs(static::getRouteName())) + ->isActiveWhen(fn () => request()->routeIs(static::getRouteName())) ->sort(static::getNavigationSort()) ->url(static::getUrl(), shouldOpenInNewTab: true), // 👈 Forces target="_blank" ]; @@ -87,10 +86,10 @@ class PlayerProps extends Page implements HasForms ->live() ->preload() ->searchable(false) - ->prefixIconColor(fn(Get $get): string => $get('cid') ? 'success' : 'danger') + ->prefixIconColor(fn (Get $get): string => $get('cid') ? 'success' : 'danger') ->prefixIcon('phosphor-globe-fill') ->hiddenLabel() - ->options(fn() => LoadSofaScoreCategory::load()) + ->options(fn () => LoadSofaScoreCategory::load()) ->placeholder('Country') ->afterStateUpdated(function (callable $set, $state) { $set('lid', null); @@ -101,10 +100,10 @@ class PlayerProps extends Page implements HasForms Select::make('lid') ->live() ->preload() - ->prefixIconColor(fn(Get $get): string => $get('lid') ? 'success' : 'danger') + ->prefixIconColor(fn (Get $get): string => $get('lid') ? 'success' : 'danger') ->prefixIcon('phosphor-trophy-fill') ->hiddenLabel() - ->options(fn(Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('cid'))) + ->options(fn (Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('cid'))) ->placeholder('League') ->afterStateUpdated(function (callable $set) { $set('mid', null); @@ -114,7 +113,7 @@ class PlayerProps extends Page implements HasForms Select::make('mid') ->live() ->hiddenLabel() - ->prefixIconColor(fn(Get $get): string => $get('mid') ? 'success' : 'danger') + ->prefixIconColor(fn (Get $get): string => $get('mid') ? 'success' : 'danger') ->prefixIcon('phosphor-calendar-check-fill') ->options(function (Get $get) { return LoadStatisticFixturesMatchOptions::load($get('lid')); @@ -132,7 +131,7 @@ class PlayerProps extends Page implements HasForms Select::make('tid') ->live() ->hiddenLabel() - ->prefixIconColor(fn(Get $get): string => $get('tid') ? 'success' : 'danger') + ->prefixIconColor(fn (Get $get): string => $get('tid') ? 'success' : 'danger') ->prefixIcon('icon-player') ->options(function (Get $get) { if ($get('mid')) { @@ -171,7 +170,7 @@ class PlayerProps extends Page implements HasForms $arr = []; foreach ($res as $key => $value) { if ($this->players && in_array($key, $this->clientLineUps)) { - $arr[$key] = $value . ' has lineup'; + $arr[$key] = $value.' has lineup'; } else { $arr[$key] = $value; } diff --git a/app/Filament/Widgets/Boxes/ExpectationsTeam.php b/app/Filament/Widgets/Boxes/ExpectationsTeam.php index c87f254f..c0466ece 100644 --- a/app/Filament/Widgets/Boxes/ExpectationsTeam.php +++ b/app/Filament/Widgets/Boxes/ExpectationsTeam.php @@ -58,9 +58,7 @@ class ExpectationsTeam $expectations = ExpectationCalculationMethodB::calc($tmp); } - // dd($expectations); - - ExpectationsMinMax::calc($expectations, $league_id); + ExpectationsMinMax::calc($expectations, $match); $expectations['gls']['name'] = 'Goals'; $expectations['crn']['name'] = 'Corner'; diff --git a/app/Filament/Widgets/Boxes/Helper/ExpectationsMinMax.php b/app/Filament/Widgets/Boxes/Helper/ExpectationsMinMax.php index 56721f4a..7bc47b54 100644 --- a/app/Filament/Widgets/Boxes/Helper/ExpectationsMinMax.php +++ b/app/Filament/Widgets/Boxes/Helper/ExpectationsMinMax.php @@ -6,7 +6,7 @@ use App\Models\StatistikoEvent; class ExpectationsMinMax { - public static function calc(array &$expectations, int $league_id) + public static function calc(array &$expectations, object $match) { /** * get min and max for each bettype from all DB for liga @@ -15,7 +15,7 @@ class ExpectationsMinMax $bets = ['crn', 'fls', 'ofs', 'crd', 'snt', 'tsh']; $Y = 0.25; - $res = StatistikoEvent::where('league_id', $league_id)->get(); + $res = StatistikoEvent::where('league_id', $match->league_id)->get(); $count = $res->count(); $data = []; @@ -75,5 +75,24 @@ class ExpectationsMinMax $expectations[$key]['away'] = $final[$key]['min']; } } + + // GOALS with asp from fixtures + $gls_home_max = $match->exp_home * (1 + ($Y / 2)); + $gls_home_min = $match->exp_home * (1 - ($Y / 2)); + $gls_away_max = $match->exp_away * (1 + ($Y / 2)); + $gls_away_min = $match->exp_away * (1 - ($Y / 2)); + + if ($expectations['gls']['home'] > $gls_home_max) { + $expectations['gls']['home'] = $gls_home_max; + } + if ($expectations['gls']['away'] > $gls_away_max) { + $expectations['gls']['away'] = $gls_away_max; + } + if ($expectations['gls']['home'] < $gls_home_min) { + $expectations['gls']['home'] = $gls_home_min; + } + if ($expectations['gls']['away'] < $gls_away_min) { + $expectations['gls']['away'] = $gls_away_min; + } } } diff --git a/app/Filament/Widgets/PlayerProps/LineUpMap.php b/app/Filament/Widgets/PlayerProps/LineUpMap.php index 18919725..c5578aeb 100644 --- a/app/Filament/Widgets/PlayerProps/LineUpMap.php +++ b/app/Filament/Widgets/PlayerProps/LineUpMap.php @@ -58,4 +58,65 @@ class LineUpMap '541+' => [2, 9, 16, 23, 30, 4, 11, 25, 32, 21], ]; } + + public static function get(string $key) + { + $lup = [ + '3313' => [9, 16, 23, 11, 18, 25, 19, 6, 34, 21], + '3331' => [9, 16, 23, 17, 11, 25, 12, 19, 26, 21], + '3331-' => [9, 16, 23, 10, 18, 24, 12, 19, 26, 21], + '3331+' => [9, 16, 23, 11, 18, 25, 12, 19, 26, 21], + '3412-' => [9, 16, 23, 4, 10, 24, 32, 19, 20, 21], + '3412+' => [9, 16, 23, 4, 11, 25, 32, 19, 20, 21], + '3421-' => [9, 16, 23, 4, 10, 24, 32, 12, 26, 21], + '3421+' => [9, 16, 23, 4, 11, 25, 32, 12, 26, 21], + '343-' => [9, 16, 23, 4, 10, 24, 32, 6, 34, 21], + '343+' => [9, 16, 23, 4, 11, 25, 32, 6, 34, 21], + '3511' => [9, 16, 23, 4, 11, 17, 25, 32, 19, 21], + '3511-' => [9, 16, 23, 4, 10, 18, 24, 32, 19, 21], + '3511+' => [9, 16, 23, 4, 11, 18, 25, 32, 19, 21], + '352' => [9, 16, 23, 4, 11, 17, 25, 32, 20, 21], + '352-' => [9, 16, 23, 4, 10, 18, 24, 32, 20, 21], + '352+' => [9, 16, 23, 4, 11, 18, 25, 32, 20, 21], + '4132' => [2, 9, 23, 30, 17, 12, 19, 26, 20, 21], + '4213-' => [2, 9, 23, 30, 10, 24, 19, 6, 34, 21], + '4213+' => [2, 9, 23, 30, 11, 25, 19, 6, 34, 21], + '4222' => [2, 9, 23, 30, 10, 24, 12, 26, 20, 21], + '4231' => [2, 9, 23, 30, 10, 24, 12, 19, 26, 21], + '424' => [2, 9, 23, 30, 10, 24, 6, 34, 20, 21], + '4312' => [2, 9, 23, 30, 17, 11, 25, 19, 20, 21], + '4312-' => [2, 9, 23, 30, 10, 18, 24, 19, 20, 21], + '4312+' => [2, 9, 23, 30, 11, 18, 25, 19, 20, 21], + '4321' => [2, 9, 23, 30, 17, 11, 25, 12, 26, 21], + '4321-' => [2, 9, 23, 30, 10, 18, 24, 12, 26, 21], + '4321+' => [2, 9, 23, 30, 11, 18, 25, 12, 26, 21], + '433' => [2, 9, 23, 30, 17, 11, 25, 6, 34, 21], + '433-' => [2, 9, 23, 30, 10, 18, 24, 6, 34, 21], + '433+' => [2, 9, 23, 30, 11, 18, 25, 6, 34, 21], + '4411-' => [2, 9, 23, 30, 4, 10, 24, 32, 19, 21], + '4411+' => [2, 9, 23, 30, 4, 11, 25, 32, 19, 21], + '442' => [2, 9, 23, 30, 4, 17, 18, 32, 20, 21], + '442-' => [2, 9, 23, 30, 4, 10, 24, 32, 20, 21], + '442+' => [2, 9, 23, 30, 4, 11, 25, 32, 20, 21], + '451' => [2, 9, 23, 30, 4, 17, 11, 25, 32, 21], + '451-' => [2, 9, 23, 30, 4, 10, 18, 24, 32, 21], + '451+' => [2, 9, 23, 30, 4, 11, 18, 25, 32, 21], + '523-' => [2, 9, 16, 23, 30, 10, 24, 6, 34, 21], + '523+' => [2, 9, 16, 23, 30, 11, 25, 6, 34, 21], + '5311' => [2, 9, 16, 23, 30, 17, 11, 25, 19, 21], + '5311-' => [2, 9, 16, 23, 30, 10, 18, 24, 19, 21], + '5311+' => [2, 9, 16, 23, 30, 11, 18, 25, 19, 21], + '532' => [2, 9, 16, 23, 30, 17, 11, 25, 20, 21], + '532-' => [2, 9, 16, 23, 30, 10, 18, 24, 20, 21], + '532+' => [2, 9, 16, 23, 30, 11, 18, 25, 20, 21], + '541-' => [2, 9, 16, 23, 30, 4, 10, 24, 32, 21], + '541+' => [2, 9, 16, 23, 30, 4, 11, 25, 32, 21], + ]; + + if (isset($lup[$key])) { + return $lup[$key]; + } + + return []; + } } diff --git a/app/Filament/Widgets/PlayerProps/PositionHirarchie.php b/app/Filament/Widgets/PlayerProps/PositionHirarchie.php new file mode 100644 index 00000000..e7f046ce --- /dev/null +++ b/app/Filament/Widgets/PlayerProps/PositionHirarchie.php @@ -0,0 +1,25 @@ + ['DC'], + 'DR' => ['MR', 'DC'], + 'DL' => ['ML', 'DC'], + 'SW' => ['DC'], + 'MR' => ['DR', 'RW'], + 'ML' => ['DL', 'LW'], + // 'MC' => ['MC'], + 'DM' => ['MC'], + 'AM' => ['LW', 'RW', 'MC'], + 'LW' => ['AM', 'ST'], + 'RW' => ['AM', 'ST'], + // 'ST' => ['ST'], + 'SS' => ['ST'], + ]; + } +} diff --git a/app/Filament/Widgets/PlayerPropsDrop.php b/app/Filament/Widgets/PlayerPropsDrop.php index 775942b3..b27b964f 100644 --- a/app/Filament/Widgets/PlayerPropsDrop.php +++ b/app/Filament/Widgets/PlayerPropsDrop.php @@ -5,6 +5,7 @@ namespace App\Filament\Widgets; use App\Filament\Widgets\PlayerProps\BoxNames; use App\Filament\Widgets\PlayerProps\Expectations; use App\Filament\Widgets\PlayerProps\LineUpMap; +use App\Filament\Widgets\PlayerProps\PositionHirarchie; use App\Livewire\PlayerCalculator; use App\Models\ExpectedMinimumPosition; use App\Models\SofaScorePlayerPerSeason; @@ -44,7 +45,7 @@ class PlayerPropsDrop extends Widget public int $team_id = 0; - public int $match_id; + public int $match_id = 0; public int $player_on_field_counter; @@ -297,9 +298,9 @@ class PlayerPropsDrop extends Widget 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`)"); @@ -319,7 +320,7 @@ class PlayerPropsDrop extends Widget return; } $header = ['name', 'foot', 'events', 'average min', 'position', 'on field', 'gls', 'fls', 'ofs', 'crd', 'snt', 'tsh']; - $copystring = implode(';', $header) . "\n"; + $copystring = implode(';', $header)."\n"; foreach ($this->players as $row) { $tmp = []; $tmp[] = $row['name']; @@ -339,7 +340,7 @@ class PlayerPropsDrop extends Widget $tmp[] = $row['snt']; $tmp[] = $row['tsh']; - $copystring .= implode(';', $tmp) . "\n"; + $copystring .= implode(';', $tmp)."\n"; } $this->js("navigator.clipboard.writeText(`$copystring`)"); @@ -454,8 +455,8 @@ class PlayerPropsDrop extends Widget $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 ($val->ss_player_id == 243651) // dd($val, $asp_statistica); @@ -470,61 +471,61 @@ class PlayerPropsDrop extends Widget case 'goals': $asp_gioco = $val->goals / $val->total_min * 90; if ($asp_gioco == 0 || $val->total_min < $this->y_value) { - $tmp['asp_gioco_' . $bettype] = 0; - $tmp['asp_teorica_' . $bettype] = $asp_statistica; + $tmp['asp_gioco_'.$bettype] = 0; + $tmp['asp_teorica_'.$bettype] = $asp_statistica; } else { - $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': $asp_gioco = $val->cards / $val->total_min * 90; if ($asp_gioco == 0 || $val->total_min < $this->y_value) { - $tmp['asp_gioco_' . $bettype] = 0; - $tmp['asp_teorica_' . $bettype] = $asp_statistica; + $tmp['asp_gioco_'.$bettype] = 0; + $tmp['asp_teorica_'.$bettype] = $asp_statistica; } else { - $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': $asp_gioco = $val->fouls / $val->total_min * 90; if ($asp_gioco == 0 || $val->total_min < $this->y_value) { - $tmp['asp_gioco_' . $bettype] = 0; - $tmp['asp_teorica_' . $bettype] = $asp_statistica; + $tmp['asp_gioco_'.$bettype] = 0; + $tmp['asp_teorica_'.$bettype] = $asp_statistica; } else { - $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': $asp_gioco = $val->offsides / $val->total_min * 90; if ($asp_gioco == 0 || $val->total_min < $this->y_value) { - $tmp['asp_gioco_' . $bettype] = 0; - $tmp['asp_teorica_' . $bettype] = $asp_statistica; + $tmp['asp_gioco_'.$bettype] = 0; + $tmp['asp_teorica_'.$bettype] = $asp_statistica; } else { - $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': $asp_gioco = $val->total_shots / $val->total_min * 90; if ($asp_gioco == 0 || $val->total_min < $this->y_value) { - $tmp['asp_gioco_' . $bettype] = 0; - $tmp['asp_teorica_' . $bettype] = $asp_statistica; + $tmp['asp_gioco_'.$bettype] = 0; + $tmp['asp_teorica_'.$bettype] = $asp_statistica; } else { - $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': $asp_gioco = $val->shots_on_target / $val->total_min * 90; if ($asp_gioco == 0 || $val->total_min < $this->y_value) { - $tmp['asp_gioco_' . $bettype] = 0; - $tmp['asp_teorica_' . $bettype] = $asp_statistica; + $tmp['asp_gioco_'.$bettype] = 0; + $tmp['asp_teorica_'.$bettype] = $asp_statistica; } else { - $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; } @@ -546,7 +547,7 @@ class PlayerPropsDrop extends Widget $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) { switch ($bettype) { @@ -557,38 +558,38 @@ class PlayerPropsDrop extends Widget $asp_team_riferimento = (float) $asp_team * $count_player / 10; $results[$key]['asp_riferimento_goals'] = $asp_team_riferimento; - $results[$key]['asp_player_' . $bettype] = $value['asp_teorica_' . $bettype] * $asp_team_riferimento / $total_bettype; - $results[$key]['asp_total_' . $bettype] = $total_bettype; + $results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_riferimento / $total_bettype; + $results[$key]['asp_total_'.$bettype] = $total_bettype; break; case 'cards': $asp_team_riferimento = (float) $asp_team_all[$team_home_away]['crd'] * $count_player / 10; $results[$key]['asp_team_riferimento_card'] = $asp_team_riferimento; - $results[$key]['asp_total_' . $bettype] = $total_bettype; - $results[$key]['asp_player_' . $bettype] = $value['asp_teorica_' . $bettype] * $asp_team_riferimento / $total_bettype; + $results[$key]['asp_total_'.$bettype] = $total_bettype; + $results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_riferimento / $total_bettype; break; case 'fouls': $asp_team_riferimento = (float) $asp_team_all[$team_home_away]['fls'] * $count_player / 10; $results[$key]['asp_team_riferimento_fouls'] = $asp_team_riferimento; - $results[$key]['asp_total_' . $bettype] = $total_bettype; - $results[$key]['asp_player_' . $bettype] = $value['asp_teorica_' . $bettype] * $asp_team_riferimento / $total_bettype; + $results[$key]['asp_total_'.$bettype] = $total_bettype; + $results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_riferimento / $total_bettype; break; case 'offsides': $asp_team_riferimento = (float) $asp_team_all[$team_home_away]['ofs'] * $count_player / 10; $results[$key]['asp_team_riferimento_offside'] = $asp_team_riferimento; - $results[$key]['asp_total_' . $bettype] = $total_bettype; - $results[$key]['asp_player_' . $bettype] = $value['asp_teorica_' . $bettype] * $asp_team_riferimento / $total_bettype; + $results[$key]['asp_total_'.$bettype] = $total_bettype; + $results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_riferimento / $total_bettype; break; case 'total_shots': $asp_team_riferimento = (float) $asp_team_all[$team_home_away]['tsh'] * $count_player / 10; $results[$key]['asp_team_riferimento_tsh'] = $asp_team_riferimento; - $results[$key]['asp_total_' . $bettype] = $total_bettype; - $results[$key]['asp_player_' . $bettype] = $value['asp_teorica_' . $bettype] * $asp_team_riferimento / $total_bettype; + $results[$key]['asp_total_'.$bettype] = $total_bettype; + $results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_riferimento / $total_bettype; break; case 'shots_on_target': $asp_team_riferimento = (float) $asp_team_all[$team_home_away]['snt'] * $count_player / 10; $results[$key]['asp_team_riferimento_snt'] = $asp_team_riferimento; - $results[$key]['asp_total_' . $bettype] = $total_bettype; - $results[$key]['asp_player_' . $bettype] = $value['asp_teorica_' . $bettype] * $asp_team_riferimento / $total_bettype; + $results[$key]['asp_total_'.$bettype] = $total_bettype; + $results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_riferimento / $total_bettype; break; } } @@ -614,8 +615,9 @@ class PlayerPropsDrop extends Widget $this->players[$k]['active'] = $result['active']; $pos = $this->players[$k]['pos']; - if (!$pos) + if (! $pos) { $pos = $this->players[$k]['pos_ori']; + } $tamx = number_format($map[$pos]['gls'], 3); $final = number_format($result['asp_player_goals'], 3); @@ -672,4 +674,99 @@ class PlayerPropsDrop extends Widget return false; } + + public function prepareLineUp() + { + $players = SofaScorePlayerPerSeason::with('details')->where('season', 'total')->where('ss_team_id', $this->team_id)->get(); + $arr = collect(); + foreach ($players as $value) { + if ($value?->details->position ?? 0) { + $arr->push([ + 'id' => $value->ss_player_id, + 'min' => $value->total_min, + 'pos' => $value->details->position, + ]); + } + } + + return $arr; + } + + public function generateLineUp(): void + { + // { + // "975216": 6, + // "1122806": 9, + // "1003010": 11, + // "881215": 16, + // "158277": 18, + // "221636": 19, + // "2282985": 21, + // "1631268": 23, + // "1064039": 25, + // "922559": 34 + // } + if ($this->activeLineUp && $this->team_id) { + + $players = $this->prepareLineUp(); + + $hirarchy = PositionHirarchie::load(); + + $places = LineUpMap::get($this->activeLineUp); + + $lineup = []; + + $id_used = []; + + foreach ($places as $k => $place) { + + $position = $this->activeBoxes[$place]; + $fitered = $players->where('pos', $position)->whereNotIn('id', $id_used)->sortBy('min')->first(); + if (isset($fitered['id'])) { + $lineup[$fitered['id']] = ['id' => $fitered['id'], 'place' => $place, 'position' => $position]; + $id_used[] = $fitered['id']; + } else { + if (isset($hirarchy[$position])) { + $position = $hirarchy[$position][0]; + $fitered = $players->where('pos', $position)->sortBy('min')->first(); + if (isset($fitered['id'])) { + $lineup[$fitered['id']] = ['id' => $fitered['id'], 'place' => $place, 'position' => $position]; + $id_used[] = $fitered['id']; + } elseif (isset($hirarchy[$position][1])) { + $position = $hirarchy[$position][1]; + $fitered = $players->where('pos', $position)->sortBy('min')->first(); + if (isset($fitered['id'])) { + $lineup[$fitered['id']] = ['id' => $fitered['id'], 'place' => $place, 'position' => $position]; + $id_used[] = $fitered['id']; + } elseif (isset($hirarchy[$position][2])) { + $position = $hirarchy[$position][2]; + $fitered = $players->where('pos', $position)->sortBy('min')->first(); + if (isset($fitered['id'])) { + $lineup[$fitered['id']] = ['id' => $fitered['id'], 'place' => $place, 'position' => $position]; + $id_used[] = $fitered['id']; + } + } + } + } + } + } + + $this->clearResultTable(); + + $this->player_on_field_counter = 0; + + foreach ($this->players as $k => $record) { + $id = $record['id']; + if (isset($lineup[$id])) { + $this->boxes[$lineup[$id]['place']] = $record; + $this->players[$k]['active'] = 1; + $this->players[$k]['pos'] = $lineup[$id]['position']; + + $this->player_on_field_counter++; + } + } + + $this->calculateAspg(); + } + } } diff --git a/resources/views/livewire/player-props-drop.blade.php b/resources/views/livewire/player-props-drop.blade.php index 8d03ae30..fbba60f0 100644 --- a/resources/views/livewire/player-props-drop.blade.php +++ b/resources/views/livewire/player-props-drop.blade.php @@ -6,6 +6,9 @@
{{ $team_name }} ({{ $player_on_field_counter }})
+ + + @@ -22,7 +25,6 @@
- {{-- --}}