wip generate positions in PP
This commit is contained in:
1 parent
01b62be635
commit
8ae58d2e2a
7 files changed
+261
-60
No files matched your search
@@ -20,7 +20,6 @@ use Filament\Schemas\Components\Utilities\Get;
|
|||||||
use Filament\Schemas\Components\Utilities\Set;
|
use Filament\Schemas\Components\Utilities\Set;
|
||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Livewire\Attributes\On;
|
use Livewire\Attributes\On;
|
||||||
|
|
||||||
class PlayerProps extends Page implements HasForms
|
class PlayerProps extends Page implements HasForms
|
||||||
@@ -36,7 +35,7 @@ class PlayerProps extends Page implements HasForms
|
|||||||
->group(static::getNavigationGroup())
|
->group(static::getNavigationGroup())
|
||||||
->icon(static::getNavigationIcon())
|
->icon(static::getNavigationIcon())
|
||||||
->activeIcon(static::getActiveNavigationIcon())
|
->activeIcon(static::getActiveNavigationIcon())
|
||||||
->isActiveWhen(fn() => request()->routeIs(static::getRouteName()))
|
->isActiveWhen(fn () => request()->routeIs(static::getRouteName()))
|
||||||
->sort(static::getNavigationSort())
|
->sort(static::getNavigationSort())
|
||||||
->url(static::getUrl(), shouldOpenInNewTab: true), // 👈 Forces target="_blank"
|
->url(static::getUrl(), shouldOpenInNewTab: true), // 👈 Forces target="_blank"
|
||||||
];
|
];
|
||||||
@@ -87,10 +86,10 @@ class PlayerProps extends Page implements HasForms
|
|||||||
->live()
|
->live()
|
||||||
->preload()
|
->preload()
|
||||||
->searchable(false)
|
->searchable(false)
|
||||||
->prefixIconColor(fn(Get $get): string => $get('cid') ? 'success' : 'danger')
|
->prefixIconColor(fn (Get $get): string => $get('cid') ? 'success' : 'danger')
|
||||||
->prefixIcon('phosphor-globe-fill')
|
->prefixIcon('phosphor-globe-fill')
|
||||||
->hiddenLabel()
|
->hiddenLabel()
|
||||||
->options(fn() => LoadSofaScoreCategory::load())
|
->options(fn () => LoadSofaScoreCategory::load())
|
||||||
->placeholder('Country')
|
->placeholder('Country')
|
||||||
->afterStateUpdated(function (callable $set, $state) {
|
->afterStateUpdated(function (callable $set, $state) {
|
||||||
$set('lid', null);
|
$set('lid', null);
|
||||||
@@ -101,10 +100,10 @@ class PlayerProps extends Page implements HasForms
|
|||||||
Select::make('lid')
|
Select::make('lid')
|
||||||
->live()
|
->live()
|
||||||
->preload()
|
->preload()
|
||||||
->prefixIconColor(fn(Get $get): string => $get('lid') ? 'success' : 'danger')
|
->prefixIconColor(fn (Get $get): string => $get('lid') ? 'success' : 'danger')
|
||||||
->prefixIcon('phosphor-trophy-fill')
|
->prefixIcon('phosphor-trophy-fill')
|
||||||
->hiddenLabel()
|
->hiddenLabel()
|
||||||
->options(fn(Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('cid')))
|
->options(fn (Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('cid')))
|
||||||
->placeholder('League')
|
->placeholder('League')
|
||||||
->afterStateUpdated(function (callable $set) {
|
->afterStateUpdated(function (callable $set) {
|
||||||
$set('mid', null);
|
$set('mid', null);
|
||||||
@@ -114,7 +113,7 @@ class PlayerProps extends Page implements HasForms
|
|||||||
Select::make('mid')
|
Select::make('mid')
|
||||||
->live()
|
->live()
|
||||||
->hiddenLabel()
|
->hiddenLabel()
|
||||||
->prefixIconColor(fn(Get $get): string => $get('mid') ? 'success' : 'danger')
|
->prefixIconColor(fn (Get $get): string => $get('mid') ? 'success' : 'danger')
|
||||||
->prefixIcon('phosphor-calendar-check-fill')
|
->prefixIcon('phosphor-calendar-check-fill')
|
||||||
->options(function (Get $get) {
|
->options(function (Get $get) {
|
||||||
return LoadStatisticFixturesMatchOptions::load($get('lid'));
|
return LoadStatisticFixturesMatchOptions::load($get('lid'));
|
||||||
@@ -132,7 +131,7 @@ class PlayerProps extends Page implements HasForms
|
|||||||
Select::make('tid')
|
Select::make('tid')
|
||||||
->live()
|
->live()
|
||||||
->hiddenLabel()
|
->hiddenLabel()
|
||||||
->prefixIconColor(fn(Get $get): string => $get('tid') ? 'success' : 'danger')
|
->prefixIconColor(fn (Get $get): string => $get('tid') ? 'success' : 'danger')
|
||||||
->prefixIcon('icon-player')
|
->prefixIcon('icon-player')
|
||||||
->options(function (Get $get) {
|
->options(function (Get $get) {
|
||||||
if ($get('mid')) {
|
if ($get('mid')) {
|
||||||
@@ -171,7 +170,7 @@ class PlayerProps extends Page implements HasForms
|
|||||||
$arr = [];
|
$arr = [];
|
||||||
foreach ($res as $key => $value) {
|
foreach ($res as $key => $value) {
|
||||||
if ($this->players && in_array($key, $this->clientLineUps)) {
|
if ($this->players && in_array($key, $this->clientLineUps)) {
|
||||||
$arr[$key] = $value . '<span class="text-blue-600"> has lineup</span>';
|
$arr[$key] = $value.'<span class="text-blue-600"> has lineup</span>';
|
||||||
} else {
|
} else {
|
||||||
$arr[$key] = $value;
|
$arr[$key] = $value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,9 +58,7 @@ class ExpectationsTeam
|
|||||||
$expectations = ExpectationCalculationMethodB::calc($tmp);
|
$expectations = ExpectationCalculationMethodB::calc($tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// dd($expectations);
|
ExpectationsMinMax::calc($expectations, $match);
|
||||||
|
|
||||||
ExpectationsMinMax::calc($expectations, $league_id);
|
|
||||||
|
|
||||||
$expectations['gls']['name'] = 'Goals';
|
$expectations['gls']['name'] = 'Goals';
|
||||||
$expectations['crn']['name'] = 'Corner';
|
$expectations['crn']['name'] = 'Corner';
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use App\Models\StatistikoEvent;
|
|||||||
|
|
||||||
class ExpectationsMinMax
|
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
|
* 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'];
|
$bets = ['crn', 'fls', 'ofs', 'crd', 'snt', 'tsh'];
|
||||||
$Y = 0.25;
|
$Y = 0.25;
|
||||||
|
|
||||||
$res = StatistikoEvent::where('league_id', $league_id)->get();
|
$res = StatistikoEvent::where('league_id', $match->league_id)->get();
|
||||||
$count = $res->count();
|
$count = $res->count();
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
@@ -75,5 +75,24 @@ class ExpectationsMinMax
|
|||||||
$expectations[$key]['away'] = $final[$key]['min'];
|
$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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,4 +58,65 @@ class LineUpMap
|
|||||||
'541+' => [2, 9, 16, 23, 30, 4, 11, 25, 32, 21],
|
'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 [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Widgets\PlayerProps;
|
||||||
|
|
||||||
|
class PositionHirarchie
|
||||||
|
{
|
||||||
|
public static function load()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// 'DC' => ['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'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ namespace App\Filament\Widgets;
|
|||||||
use App\Filament\Widgets\PlayerProps\BoxNames;
|
use App\Filament\Widgets\PlayerProps\BoxNames;
|
||||||
use App\Filament\Widgets\PlayerProps\Expectations;
|
use App\Filament\Widgets\PlayerProps\Expectations;
|
||||||
use App\Filament\Widgets\PlayerProps\LineUpMap;
|
use App\Filament\Widgets\PlayerProps\LineUpMap;
|
||||||
|
use App\Filament\Widgets\PlayerProps\PositionHirarchie;
|
||||||
use App\Livewire\PlayerCalculator;
|
use App\Livewire\PlayerCalculator;
|
||||||
use App\Models\ExpectedMinimumPosition;
|
use App\Models\ExpectedMinimumPosition;
|
||||||
use App\Models\SofaScorePlayerPerSeason;
|
use App\Models\SofaScorePlayerPerSeason;
|
||||||
@@ -44,7 +45,7 @@ class PlayerPropsDrop extends Widget
|
|||||||
|
|
||||||
public int $team_id = 0;
|
public int $team_id = 0;
|
||||||
|
|
||||||
public int $match_id;
|
public int $match_id = 0;
|
||||||
|
|
||||||
public int $player_on_field_counter;
|
public int $player_on_field_counter;
|
||||||
|
|
||||||
@@ -297,9 +298,9 @@ class PlayerPropsDrop extends Widget
|
|||||||
foreach ($this->calculationVariables as $row) {
|
foreach ($this->calculationVariables as $row) {
|
||||||
if ($copystring == '') {
|
if ($copystring == '') {
|
||||||
$keys = array_keys($row);
|
$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`)");
|
$this->js("navigator.clipboard.writeText(`$copystring`)");
|
||||||
|
|
||||||
@@ -319,7 +320,7 @@ class PlayerPropsDrop extends Widget
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$header = ['name', 'foot', 'events', 'average min', 'position', 'on field', 'gls', 'fls', 'ofs', 'crd', 'snt', 'tsh'];
|
$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) {
|
foreach ($this->players as $row) {
|
||||||
$tmp = [];
|
$tmp = [];
|
||||||
$tmp[] = $row['name'];
|
$tmp[] = $row['name'];
|
||||||
@@ -339,7 +340,7 @@ class PlayerPropsDrop extends Widget
|
|||||||
$tmp[] = $row['snt'];
|
$tmp[] = $row['snt'];
|
||||||
$tmp[] = $row['tsh'];
|
$tmp[] = $row['tsh'];
|
||||||
|
|
||||||
$copystring .= implode(';', $tmp) . "\n";
|
$copystring .= implode(';', $tmp)."\n";
|
||||||
}
|
}
|
||||||
$this->js("navigator.clipboard.writeText(`$copystring`)");
|
$this->js("navigator.clipboard.writeText(`$copystring`)");
|
||||||
|
|
||||||
@@ -454,8 +455,8 @@ class PlayerPropsDrop extends Widget
|
|||||||
$bettypes = ['goals', 'cards', 'fouls', 'offsides', 'total_shots', 'shots_on_target'];
|
$bettypes = ['goals', 'cards', 'fouls', 'offsides', 'total_shots', 'shots_on_target'];
|
||||||
foreach ($bettypes as $bettype) {
|
foreach ($bettypes as $bettype) {
|
||||||
|
|
||||||
$asp_statistica = (float) SofaScorePlayerPosition::where('ss_code', $position)->value('exp_' . $bettype);
|
$asp_statistica = (float) SofaScorePlayerPosition::where('ss_code', $position)->value('exp_'.$bettype);
|
||||||
$tmp['asp_statistica_' . $bettype] = $asp_statistica;
|
$tmp['asp_statistica_'.$bettype] = $asp_statistica;
|
||||||
|
|
||||||
// if ($val->ss_player_id == 243651)
|
// if ($val->ss_player_id == 243651)
|
||||||
// dd($val, $asp_statistica);
|
// dd($val, $asp_statistica);
|
||||||
@@ -470,61 +471,61 @@ class PlayerPropsDrop extends Widget
|
|||||||
case 'goals':
|
case 'goals':
|
||||||
$asp_gioco = $val->goals / $val->total_min * 90;
|
$asp_gioco = $val->goals / $val->total_min * 90;
|
||||||
if ($asp_gioco == 0 || $val->total_min < $this->y_value) {
|
if ($asp_gioco == 0 || $val->total_min < $this->y_value) {
|
||||||
$tmp['asp_gioco_' . $bettype] = 0;
|
$tmp['asp_gioco_'.$bettype] = 0;
|
||||||
$tmp['asp_teorica_' . $bettype] = $asp_statistica;
|
$tmp['asp_teorica_'.$bettype] = $asp_statistica;
|
||||||
} else {
|
} else {
|
||||||
$tmp['asp_gioco_' . $bettype] = $asp_gioco;
|
$tmp['asp_gioco_'.$bettype] = $asp_gioco;
|
||||||
$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);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'cards':
|
case 'cards':
|
||||||
$asp_gioco = $val->cards / $val->total_min * 90;
|
$asp_gioco = $val->cards / $val->total_min * 90;
|
||||||
if ($asp_gioco == 0 || $val->total_min < $this->y_value) {
|
if ($asp_gioco == 0 || $val->total_min < $this->y_value) {
|
||||||
$tmp['asp_gioco_' . $bettype] = 0;
|
$tmp['asp_gioco_'.$bettype] = 0;
|
||||||
$tmp['asp_teorica_' . $bettype] = $asp_statistica;
|
$tmp['asp_teorica_'.$bettype] = $asp_statistica;
|
||||||
} else {
|
} else {
|
||||||
$tmp['asp_gioco_' . $bettype] = $asp_gioco;
|
$tmp['asp_gioco_'.$bettype] = $asp_gioco;
|
||||||
$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);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'fouls':
|
case 'fouls':
|
||||||
$asp_gioco = $val->fouls / $val->total_min * 90;
|
$asp_gioco = $val->fouls / $val->total_min * 90;
|
||||||
if ($asp_gioco == 0 || $val->total_min < $this->y_value) {
|
if ($asp_gioco == 0 || $val->total_min < $this->y_value) {
|
||||||
$tmp['asp_gioco_' . $bettype] = 0;
|
$tmp['asp_gioco_'.$bettype] = 0;
|
||||||
$tmp['asp_teorica_' . $bettype] = $asp_statistica;
|
$tmp['asp_teorica_'.$bettype] = $asp_statistica;
|
||||||
} else {
|
} else {
|
||||||
$tmp['asp_gioco_' . $bettype] = $asp_gioco;
|
$tmp['asp_gioco_'.$bettype] = $asp_gioco;
|
||||||
$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);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'offsides':
|
case 'offsides':
|
||||||
$asp_gioco = $val->offsides / $val->total_min * 90;
|
$asp_gioco = $val->offsides / $val->total_min * 90;
|
||||||
if ($asp_gioco == 0 || $val->total_min < $this->y_value) {
|
if ($asp_gioco == 0 || $val->total_min < $this->y_value) {
|
||||||
$tmp['asp_gioco_' . $bettype] = 0;
|
$tmp['asp_gioco_'.$bettype] = 0;
|
||||||
$tmp['asp_teorica_' . $bettype] = $asp_statistica;
|
$tmp['asp_teorica_'.$bettype] = $asp_statistica;
|
||||||
} else {
|
} else {
|
||||||
$tmp['asp_gioco_' . $bettype] = $asp_gioco;
|
$tmp['asp_gioco_'.$bettype] = $asp_gioco;
|
||||||
$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);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'total_shots':
|
case 'total_shots':
|
||||||
$asp_gioco = $val->total_shots / $val->total_min * 90;
|
$asp_gioco = $val->total_shots / $val->total_min * 90;
|
||||||
if ($asp_gioco == 0 || $val->total_min < $this->y_value) {
|
if ($asp_gioco == 0 || $val->total_min < $this->y_value) {
|
||||||
$tmp['asp_gioco_' . $bettype] = 0;
|
$tmp['asp_gioco_'.$bettype] = 0;
|
||||||
$tmp['asp_teorica_' . $bettype] = $asp_statistica;
|
$tmp['asp_teorica_'.$bettype] = $asp_statistica;
|
||||||
} else {
|
} else {
|
||||||
$tmp['asp_gioco_' . $bettype] = $asp_gioco;
|
$tmp['asp_gioco_'.$bettype] = $asp_gioco;
|
||||||
$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);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'shots_on_target':
|
case 'shots_on_target':
|
||||||
$asp_gioco = $val->shots_on_target / $val->total_min * 90;
|
$asp_gioco = $val->shots_on_target / $val->total_min * 90;
|
||||||
if ($asp_gioco == 0 || $val->total_min < $this->y_value) {
|
if ($asp_gioco == 0 || $val->total_min < $this->y_value) {
|
||||||
$tmp['asp_gioco_' . $bettype] = 0;
|
$tmp['asp_gioco_'.$bettype] = 0;
|
||||||
$tmp['asp_teorica_' . $bettype] = $asp_statistica;
|
$tmp['asp_teorica_'.$bettype] = $asp_statistica;
|
||||||
} else {
|
} else {
|
||||||
$tmp['asp_gioco_' . $bettype] = $asp_gioco;
|
$tmp['asp_gioco_'.$bettype] = $asp_gioco;
|
||||||
$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);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -546,7 +547,7 @@ class PlayerPropsDrop extends Widget
|
|||||||
$bettypes = ['goals', 'cards', 'fouls', 'offsides', 'total_shots', 'shots_on_target'];
|
$bettypes = ['goals', 'cards', 'fouls', 'offsides', 'total_shots', 'shots_on_target'];
|
||||||
foreach ($bettypes as $bettype) {
|
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) {
|
foreach ($results as $key => $value) {
|
||||||
switch ($bettype) {
|
switch ($bettype) {
|
||||||
@@ -557,38 +558,38 @@ class PlayerPropsDrop extends Widget
|
|||||||
|
|
||||||
$asp_team_riferimento = (float) $asp_team * $count_player / 10;
|
$asp_team_riferimento = (float) $asp_team * $count_player / 10;
|
||||||
$results[$key]['asp_riferimento_goals'] = $asp_team_riferimento;
|
$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_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_riferimento / $total_bettype;
|
||||||
$results[$key]['asp_total_' . $bettype] = $total_bettype;
|
$results[$key]['asp_total_'.$bettype] = $total_bettype;
|
||||||
break;
|
break;
|
||||||
case 'cards':
|
case 'cards':
|
||||||
$asp_team_riferimento = (float) $asp_team_all[$team_home_away]['crd'] * $count_player / 10;
|
$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_team_riferimento_card'] = $asp_team_riferimento;
|
||||||
$results[$key]['asp_total_' . $bettype] = $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_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_riferimento / $total_bettype;
|
||||||
break;
|
break;
|
||||||
case 'fouls':
|
case 'fouls':
|
||||||
$asp_team_riferimento = (float) $asp_team_all[$team_home_away]['fls'] * $count_player / 10;
|
$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_team_riferimento_fouls'] = $asp_team_riferimento;
|
||||||
$results[$key]['asp_total_' . $bettype] = $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_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_riferimento / $total_bettype;
|
||||||
break;
|
break;
|
||||||
case 'offsides':
|
case 'offsides':
|
||||||
$asp_team_riferimento = (float) $asp_team_all[$team_home_away]['ofs'] * $count_player / 10;
|
$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_team_riferimento_offside'] = $asp_team_riferimento;
|
||||||
$results[$key]['asp_total_' . $bettype] = $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_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_riferimento / $total_bettype;
|
||||||
break;
|
break;
|
||||||
case 'total_shots':
|
case 'total_shots':
|
||||||
$asp_team_riferimento = (float) $asp_team_all[$team_home_away]['tsh'] * $count_player / 10;
|
$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_team_riferimento_tsh'] = $asp_team_riferimento;
|
||||||
$results[$key]['asp_total_' . $bettype] = $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_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_riferimento / $total_bettype;
|
||||||
break;
|
break;
|
||||||
case 'shots_on_target':
|
case 'shots_on_target':
|
||||||
$asp_team_riferimento = (float) $asp_team_all[$team_home_away]['snt'] * $count_player / 10;
|
$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_team_riferimento_snt'] = $asp_team_riferimento;
|
||||||
$results[$key]['asp_total_' . $bettype] = $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_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_riferimento / $total_bettype;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -614,8 +615,9 @@ class PlayerPropsDrop extends Widget
|
|||||||
$this->players[$k]['active'] = $result['active'];
|
$this->players[$k]['active'] = $result['active'];
|
||||||
|
|
||||||
$pos = $this->players[$k]['pos'];
|
$pos = $this->players[$k]['pos'];
|
||||||
if (!$pos)
|
if (! $pos) {
|
||||||
$pos = $this->players[$k]['pos_ori'];
|
$pos = $this->players[$k]['pos_ori'];
|
||||||
|
}
|
||||||
|
|
||||||
$tamx = number_format($map[$pos]['gls'], 3);
|
$tamx = number_format($map[$pos]['gls'], 3);
|
||||||
$final = number_format($result['asp_player_goals'], 3);
|
$final = number_format($result['asp_player_goals'], 3);
|
||||||
@@ -672,4 +674,99 @@ class PlayerPropsDrop extends Widget
|
|||||||
|
|
||||||
return false;
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,9 @@
|
|||||||
<div class="text-3xl font-bold"> {{ $team_name }} <span
|
<div class="text-3xl font-bold"> {{ $team_name }} <span
|
||||||
class="text-sm font-light">({{ $player_on_field_counter }})</span></div>
|
class="text-sm font-light">({{ $player_on_field_counter }})</span></div>
|
||||||
<div class="flex gap-3">
|
<div class="flex gap-3">
|
||||||
|
<x-filament::button icon="phosphor-user-switch" tooltip="Create Lienup" wire:click="generateLineUp()"/>
|
||||||
|
<x-filament::button icon="phosphor-x" tooltip="Clear all" wire:click="clearResultTable()" />
|
||||||
|
|
||||||
<x-filament::modal id="custom-view-modal" slide-over width="xl">
|
<x-filament::modal id="custom-view-modal" slide-over width="xl">
|
||||||
<x-slot name="trigger">
|
<x-slot name="trigger">
|
||||||
<x-filament::button icon="phosphor-question-mark" tooltip="Lineup code explanation" />
|
<x-filament::button icon="phosphor-question-mark" tooltip="Lineup code explanation" />
|
||||||
@@ -22,7 +25,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</x-slot>
|
</x-slot>
|
||||||
</x-filament::modal>
|
</x-filament::modal>
|
||||||
<x-filament::button icon="phosphor-x" tooltip="Clear all" wire:click="clearResultTable()" />
|
|
||||||
<x-filament::button icon="phosphor-arrows-clockwise" tooltip="Reload" wire:click="loadPlacement()" />
|
<x-filament::button icon="phosphor-arrows-clockwise" tooltip="Reload" wire:click="loadPlacement()" />
|
||||||
{{-- <x-filament::button icon="phosphor-calculator" tooltip="Calculate" wire:click="calculateAspg(1)" /> --}}
|
{{-- <x-filament::button icon="phosphor-calculator" tooltip="Calculate" wire:click="calculateAspg(1)" /> --}}
|
||||||
<x-filament::button icon="phosphor-copy" color="success"
|
<x-filament::button icon="phosphor-copy" color="success"
|
||||||
|
|||||||
Reference in new issue
Block a user