This commit is contained in:
salam committed 2026-09-18 18:50:12 +02:00
1 parent 02f008e1ba
commit e9921ea26d
1 file changed
+57 -48
+57 -48
View File
@@ -297,9 +297,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 +319,7 @@ class PlayerPropsDrop extends Widget
return; return;
} }
$header = ['name', 'foot', 'events', 'average min', 'position', 'on field', 'gls', 'fls', 'ofs', 'snt', 'tsh', 'crd']; $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->players as $row) { foreach ($this->players as $row) {
$tmp = []; $tmp = [];
$tmp[] = $row['name']; $tmp[] = $row['name'];
@@ -339,7 +339,7 @@ class PlayerPropsDrop extends Widget
$tmp[] = $row['tsh']; $tmp[] = $row['tsh'];
$tmp[] = $row['crd']; $tmp[] = $row['crd'];
$copystring .= implode(';', $tmp)."\n"; $copystring .= implode(';', $tmp) . "\n";
} }
$this->js("navigator.clipboard.writeText(`$copystring`)"); $this->js("navigator.clipboard.writeText(`$copystring`)");
@@ -454,8 +454,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 +470,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 +546,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,51 +557,52 @@ 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;
} }
} }
} }
$this->calculationVariables = $results;
foreach ($this->players as $k => $player) { foreach ($this->players as $k => $player) {
foreach ($results as $key => $result) { foreach ($results as $key => $result) {
if ((int) $player['id'] == (int) $result['id']) { if ((int) $player['id'] == (int) $result['id']) {
$this->players[$k]['active'] = $result['active']; $this->players[$k]['active'] = $result['active'];
$min = ExpectedMinimumPosition::where('position', $this->players[$k]['pos'])->where('gls', '>', $result['asp_player_goals'])->first(); $min = ExpectedMinimumPosition::where('position', $this->players[$k]['pos'])->where('gls', '>', $result['asp_player_goals'])->first();
$results[$key]['asp_mini_pos_gls'] = $min->gls ?? 0;
if ($min) { if ($min) {
$this->players[$k]['gls'] = number_format($min->gls, 3); $this->players[$k]['gls'] = number_format($min->gls, 3);
} else { } else {
@@ -609,6 +610,7 @@ class PlayerPropsDrop extends Widget
} }
$min = ExpectedMinimumPosition::where('position', $this->players[$k]['pos'])->where('fls', '>', $result['asp_player_fouls'])->first(); $min = ExpectedMinimumPosition::where('position', $this->players[$k]['pos'])->where('fls', '>', $result['asp_player_fouls'])->first();
$results[$key]['asp_mini_pos_fls'] = $min->fls ?? 0;
if ($min) { if ($min) {
$this->players[$k]['fls'] = number_format($min->fls, 3); $this->players[$k]['fls'] = number_format($min->fls, 3);
} else { } else {
@@ -616,29 +618,33 @@ class PlayerPropsDrop extends Widget
} }
$min = ExpectedMinimumPosition::where('position', $this->players[$k]['pos'])->where('ofs', '>', $result['asp_player_offsides'])->first(); $min = ExpectedMinimumPosition::where('position', $this->players[$k]['pos'])->where('ofs', '>', $result['asp_player_offsides'])->first();
$results[$key]['asp_mini_pos_ofs'] = $min->ofs ?? 0;
if ($min) { if ($min) {
$this->players[$k]['ofs'] = number_format($min->fls, 3); $this->players[$k]['ofs'] = number_format($min->ofs, 3);
} else { } else {
$this->players[$k]['ofs'] = number_format($result['asp_player_offsides'], 3); $this->players[$k]['ofs'] = number_format($result['asp_player_offsides'], 3);
} }
$min = ExpectedMinimumPosition::where('position', $this->players[$k]['pos'])->where('snt', '>', $result['asp_player_shots_on_target'])->first(); $min = ExpectedMinimumPosition::where('position', $this->players[$k]['pos'])->where('snt', '>', $result['asp_player_shots_on_target'])->first();
$results[$key]['asp_mini_pos_snt'] = $min->snt ?? 0;
if ($min) { if ($min) {
$this->players[$k]['snt'] = number_format($min->fls, 3); $this->players[$k]['snt'] = number_format($min->snt, 3);
} else { } else {
$this->players[$k]['snt'] = number_format($result['asp_player_total_shots'], 3); $this->players[$k]['snt'] = number_format($result['asp_player_total_shots'], 3);
} }
$min = ExpectedMinimumPosition::where('position', $this->players[$k]['pos'])->where('tsh', '>', $result['asp_player_total_shots'])->first(); $min = ExpectedMinimumPosition::where('position', $this->players[$k]['pos'])->where('tsh', '>', $result['asp_player_total_shots'])->first();
$results[$key]['asp_mini_pos_tsh'] = $min->tsh ?? 0;
if ($min) { if ($min) {
$this->players[$k]['tsh'] = number_format($min->fls, 3); $this->players[$k]['tsh'] = number_format($min->tsh, 3);
} else { } else {
$this->players[$k]['tsh'] = number_format($result['asp_player_shots_on_target'], 3); $this->players[$k]['tsh'] = number_format($result['asp_player_shots_on_target'], 3);
} }
$min = ExpectedMinimumPosition::where('position', $this->players[$k]['pos'])->where('crd', '>', $result['asp_player_cards'])->first(); $min = ExpectedMinimumPosition::where('position', $this->players[$k]['pos'])->where('crd', '>', $result['asp_player_cards'])->first();
$results[$key]['asp_mini_pos_crd'] = $min->crd ?? 0;
if ($min) { if ($min) {
$this->players[$k]['crd'] = number_format($min->fls, 3); $this->players[$k]['crd'] = number_format($min->crd, 3);
} else { } else {
$this->players[$k]['crd'] = number_format($result['asp_player_cards'], 3); $this->players[$k]['crd'] = number_format($result['asp_player_cards'], 3);
} }
@@ -646,6 +652,9 @@ class PlayerPropsDrop extends Widget
} }
} }
$this->calculationVariables = $results;
$this->dispatch('update-players', players: $this->players); $this->dispatch('update-players', players: $this->players);
} }