wip fix error box 3
This commit is contained in:
1 parent
2728944c39
commit
e52722d3e1
9 files changed
+455
-119
No files matched your search
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Widgets\Boxes;
|
||||||
|
|
||||||
|
use App\Filament\Widgets\Charts\LoadEvents\LoadEventsQueryTP;
|
||||||
|
use App\Utilities\Round;
|
||||||
|
|
||||||
|
class Expectation1X2
|
||||||
|
{
|
||||||
|
public static function load(array &$expectations, array $filter, object $match)
|
||||||
|
{
|
||||||
|
$team_id = (int) $filter['team_id'] ?? 0;
|
||||||
|
$team_position = $filter['team_position'];
|
||||||
|
|
||||||
|
$res_tp = LoadEventsQueryTP::load($filter, $match);
|
||||||
|
|
||||||
|
$count_tp = $res_tp->count();
|
||||||
|
$expectations['count_events'] = $count_tp;
|
||||||
|
|
||||||
|
$expectations += ['win_count' => 0, 'draw_count' => 0, 'lost_count' => 0];
|
||||||
|
foreach ($res_tp as $value) {
|
||||||
|
if ($team_id && $team_position == 'home') {
|
||||||
|
switch ($value['result_code']) {
|
||||||
|
case '1':
|
||||||
|
$expectations['win_count']++;
|
||||||
|
break;
|
||||||
|
case 'X':
|
||||||
|
$expectations['draw_count']++;
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
$expectations['lost_count']++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} elseif ($team_id && $team_position == 'away') {
|
||||||
|
switch ($value['result_code']) {
|
||||||
|
case '1':
|
||||||
|
$expectations['win_count']++;
|
||||||
|
break;
|
||||||
|
case 'X':
|
||||||
|
$expectations['draw_count']++;
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
$expectations['lost_count']++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch ($value['result_code']) {
|
||||||
|
case '1':
|
||||||
|
$expectations['win_count']++;
|
||||||
|
break;
|
||||||
|
case 'X':
|
||||||
|
$expectations['draw_count']++;
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
$expectations['lost_count']++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$expectations['win_odd'] = $expectations['win_count'] ? number_format(Round::odd($count_tp / $expectations['win_count']), 2) : 0;
|
||||||
|
$expectations['draw_odd'] = $expectations['draw_count'] ? number_format(Round::odd($count_tp / $expectations['draw_count']), 2) : 0;
|
||||||
|
$expectations['lost_odd'] = $expectations['lost_count'] ? number_format(Round::odd($count_tp / $expectations['lost_count']), 2) : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,8 +7,6 @@ use App\Filament\Widgets\Boxes\Helper\ExpectationMethodA;
|
|||||||
use App\Filament\Widgets\Boxes\Helper\ExpectationMethodB;
|
use App\Filament\Widgets\Boxes\Helper\ExpectationMethodB;
|
||||||
use App\Filament\Widgets\Boxes\Helper\ExpectationsMinMax;
|
use App\Filament\Widgets\Boxes\Helper\ExpectationsMinMax;
|
||||||
use App\Filament\Widgets\Charts\LoadEvents\LoadEventsQueryAll;
|
use App\Filament\Widgets\Charts\LoadEvents\LoadEventsQueryAll;
|
||||||
use App\Filament\Widgets\Charts\LoadEvents\LoadEventsQueryTP;
|
|
||||||
use App\Utilities\Round;
|
|
||||||
|
|
||||||
class ExpectationsTeam
|
class ExpectationsTeam
|
||||||
{
|
{
|
||||||
@@ -19,20 +17,8 @@ class ExpectationsTeam
|
|||||||
/**
|
/**
|
||||||
* STATTISTIC DATA
|
* STATTISTIC DATA
|
||||||
*/
|
*/
|
||||||
$team_id = (int) $filter['team_id'] ?? 0;
|
|
||||||
$team_position = $filter['team_position'];
|
|
||||||
$similar_past_matches = $filter['similar_past_matches'];
|
$similar_past_matches = $filter['similar_past_matches'];
|
||||||
|
|
||||||
if ($similar_past_matches != 'none') {
|
|
||||||
$team_id = 0;
|
|
||||||
$team_position = '';
|
|
||||||
$home_team = $match->home->ss_team_name;
|
|
||||||
$away_team = $match->away->ss_team_name;
|
|
||||||
} else {
|
|
||||||
$home_team = 'In Favour';
|
|
||||||
$away_team = 'Against';
|
|
||||||
}
|
|
||||||
|
|
||||||
$res = LoadEventsQueryAll::load($filter, $match);
|
$res = LoadEventsQueryAll::load($filter, $match);
|
||||||
|
|
||||||
if (! $res) {
|
if (! $res) {
|
||||||
@@ -42,13 +28,13 @@ class ExpectationsTeam
|
|||||||
$tmp = [];
|
$tmp = [];
|
||||||
foreach ($res as $value) {
|
foreach ($res as $value) {
|
||||||
// dd($match->home_id, $match->away_id, $value);
|
// dd($match->home_id, $match->away_id, $value);
|
||||||
ExpectationCollecting::sort($similar_past_matches, $tmp, 'gls', $value->home_id, $value->away_id, $value->gls_h, $value->gls_a, $match);
|
ExpectationCollecting::sort($similar_past_matches, $expectations, 'gls', $value->home_id, $value->away_id, $value->gls_h, $value->gls_a, $match);
|
||||||
ExpectationCollecting::sort($similar_past_matches, $tmp, 'fls', $value->home_id, $value->away_id, $value->fls_h, $value->fls_a, $match);
|
ExpectationCollecting::sort($similar_past_matches, $expectations, 'fls', $value->home_id, $value->away_id, $value->fls_h, $value->fls_a, $match);
|
||||||
ExpectationCollecting::sort($similar_past_matches, $tmp, 'ofs', $value->home_id, $value->away_id, $value->ofs_h, $value->ofs_a, $match);
|
ExpectationCollecting::sort($similar_past_matches, $expectations, 'ofs', $value->home_id, $value->away_id, $value->ofs_h, $value->ofs_a, $match);
|
||||||
ExpectationCollecting::sort($similar_past_matches, $tmp, 'crd', $value->home_id, $value->away_id, $value->crd_h, $value->crd_a, $match);
|
ExpectationCollecting::sort($similar_past_matches, $expectations, 'crd', $value->home_id, $value->away_id, $value->crd_h, $value->crd_a, $match);
|
||||||
ExpectationCollecting::sort($similar_past_matches, $tmp, 'snt', $value->home_id, $value->away_id, $value->snt_h, $value->snt_a, $match);
|
ExpectationCollecting::sort($similar_past_matches, $expectations, 'snt', $value->home_id, $value->away_id, $value->snt_h, $value->snt_a, $match);
|
||||||
ExpectationCollecting::sort($similar_past_matches, $tmp, 'tsh', $value->home_id, $value->away_id, $value->tsh_h, $value->tsh_a, $match);
|
ExpectationCollecting::sort($similar_past_matches, $expectations, 'tsh', $value->home_id, $value->away_id, $value->tsh_h, $value->tsh_a, $match);
|
||||||
ExpectationCollecting::sort($similar_past_matches, $tmp, 'crn', $value->home_id, $value->away_id, $value->crn_h, $value->crn_a, $match);
|
ExpectationCollecting::sort($similar_past_matches, $expectations, 'crn', $value->home_id, $value->away_id, $value->crn_h, $value->crn_a, $match);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($expectations) {
|
if ($expectations) {
|
||||||
@@ -56,87 +42,29 @@ class ExpectationsTeam
|
|||||||
$expectations = ExpectationMethodA::calc($tmp);
|
$expectations = ExpectationMethodA::calc($tmp);
|
||||||
} else {
|
} else {
|
||||||
$expectations = ExpectationMethodB::calc($tmp);
|
$expectations = ExpectationMethodB::calc($tmp);
|
||||||
|
|
||||||
ExpectationsMinMax::calc($expectations, $match);
|
ExpectationsMinMax::calc($expectations, $match);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$expectations['gls']['name'] = 'Goals';
|
|
||||||
$expectations['crn']['name'] = 'Corner';
|
|
||||||
$expectations['fls']['name'] = 'Fouls';
|
|
||||||
$expectations['ofs']['name'] = 'Offsides';
|
|
||||||
$expectations['crd']['name'] = 'Cards';
|
|
||||||
$expectations['snt']['name'] = 'Shots on Target';
|
|
||||||
$expectations['tsh']['name'] = 'Total Shots';
|
|
||||||
$expectations['home'] = $home_team;
|
|
||||||
$expectations['away'] = $away_team;
|
|
||||||
|
|
||||||
$res_tp = LoadEventsQueryTP::load($filter, $match);
|
|
||||||
|
|
||||||
$count_tp = $res_tp->count();
|
|
||||||
$expectations['count_events'] = $count_tp;
|
|
||||||
|
|
||||||
$expectations += ['win_count' => 0, 'draw_count' => 0, 'lost_count' => 0];
|
|
||||||
foreach ($res_tp as $value) {
|
|
||||||
if ($team_id && $team_position == 'home') {
|
|
||||||
switch ($value['result_code']) {
|
|
||||||
case '1':
|
|
||||||
$expectations['win_count']++;
|
|
||||||
break;
|
|
||||||
case 'X':
|
|
||||||
$expectations['draw_count']++;
|
|
||||||
break;
|
|
||||||
case '2':
|
|
||||||
$expectations['lost_count']++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} elseif ($team_id && $team_position == 'away') {
|
|
||||||
switch ($value['result_code']) {
|
|
||||||
case '1':
|
|
||||||
$expectations['win_count']++;
|
|
||||||
break;
|
|
||||||
case 'X':
|
|
||||||
$expectations['draw_count']++;
|
|
||||||
break;
|
|
||||||
case '2':
|
|
||||||
$expectations['lost_count']++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
switch ($value['result_code']) {
|
|
||||||
case '1':
|
|
||||||
$expectations['win_count']++;
|
|
||||||
break;
|
|
||||||
case 'X':
|
|
||||||
$expectations['draw_count']++;
|
|
||||||
break;
|
|
||||||
case '2':
|
|
||||||
$expectations['lost_count']++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$expectations['win_odd'] = $expectations['win_count'] ? number_format(Round::odd($count_tp / $expectations['win_count']), 2) : 0;
|
// public static function template()
|
||||||
$expectations['draw_odd'] = $expectations['draw_count'] ? number_format(Round::odd($count_tp / $expectations['draw_count']), 2) : 0;
|
// {
|
||||||
$expectations['lost_odd'] = $expectations['lost_count'] ? number_format(Round::odd($count_tp / $expectations['lost_count']), 2) : 0;
|
// $arr = [];
|
||||||
}
|
// $bets = ['gls', 'crn', 'fls', 'ofs', 'crd', 'snt', 'tsh'];
|
||||||
|
// foreach ($bets as $bet) {
|
||||||
|
// foreach (['team_home', 'team_away'] as $team) {
|
||||||
|
// foreach (['scored', 'conceded'] as $sc) {
|
||||||
|
// foreach (['home', 'away'] as $ha) {
|
||||||
|
// foreach (['evt', 'sum'] as $es) {
|
||||||
|
// $arr[$bet][$team][$sc][$ha][$es] = 0;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
public static function template()
|
// return $arr;
|
||||||
{
|
// }
|
||||||
$arr = [];
|
|
||||||
$bets = ['gls', 'crn', 'fls', 'ofs', 'crd', 'snt', 'tsh'];
|
|
||||||
foreach ($bets as $bet) {
|
|
||||||
foreach (['team_home', 'team_away'] as $team) {
|
|
||||||
foreach (['scored', 'conceded'] as $sc) {
|
|
||||||
foreach (['home', 'away'] as $ha) {
|
|
||||||
foreach (['evt', 'sum'] as $es) {
|
|
||||||
$arr[$bet][$team][$sc][$ha][$es] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $arr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,209 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Widgets\Boxes;
|
||||||
|
|
||||||
|
use App\Filament\Widgets\Boxes\Helper\ExpectationsMinMax;
|
||||||
|
use App\Filament\Widgets\Charts\LoadEvents\LoadEventsQueryAll;
|
||||||
|
|
||||||
|
class ExpectationsTeamNew
|
||||||
|
{
|
||||||
|
public static function load(array &$expectations, array $filter, object $match)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* BOX 3
|
||||||
|
*/
|
||||||
|
$spm = $filter['similar_past_matches'];
|
||||||
|
$bets = ['gls', 'crn', 'fls', 'ofs', 'crd', 'snt', 'tsh'];
|
||||||
|
|
||||||
|
$res = LoadEventsQueryAll::load($filter, $match);
|
||||||
|
|
||||||
|
if (! $res) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// $sum = self::summen($res);
|
||||||
|
|
||||||
|
$tmp = self::sceleton();
|
||||||
|
foreach ($res as $val) {
|
||||||
|
// home home
|
||||||
|
if ($match->home_id == $val->home_id) {
|
||||||
|
// GLS
|
||||||
|
$tmp['gls']['home']['events']['home']++;
|
||||||
|
$tmp['gls']['home']['scored']['home'] += $val->gls_h;
|
||||||
|
$tmp['gls']['home']['conceded']['home'] += $val->gls_a;
|
||||||
|
// CRN
|
||||||
|
$tmp['crn']['home']['events']['home']++;
|
||||||
|
$tmp['crn']['home']['scored']['home'] += $val->crn_h;
|
||||||
|
$tmp['crn']['home']['conceded']['home'] += $val->crn_a;
|
||||||
|
// FLS
|
||||||
|
$tmp['fls']['home']['events']['home']++;
|
||||||
|
$tmp['fls']['home']['scored']['home'] += $val->fls_h;
|
||||||
|
$tmp['fls']['home']['conceded']['home'] += $val->fls_a;
|
||||||
|
// OFS
|
||||||
|
$tmp['ofs']['home']['events']['home']++;
|
||||||
|
$tmp['ofs']['home']['scored']['home'] += $val->ofs_h;
|
||||||
|
$tmp['ofs']['home']['conceded']['home'] += $val->ofs_a;
|
||||||
|
// CRD
|
||||||
|
$tmp['crd']['home']['events']['home']++;
|
||||||
|
$tmp['crd']['home']['scored']['home'] += $val->crd_h;
|
||||||
|
$tmp['crd']['home']['conceded']['home'] += $val->crd_a;
|
||||||
|
// SNT
|
||||||
|
$tmp['snt']['home']['events']['home']++;
|
||||||
|
$tmp['snt']['home']['scored']['home'] += $val->snt_h;
|
||||||
|
$tmp['snt']['home']['conceded']['home'] += $val->snt_a;
|
||||||
|
// TSH
|
||||||
|
$tmp['tsh']['home']['events']['home']++;
|
||||||
|
$tmp['tsh']['home']['scored']['home'] += $val->tsh_h;
|
||||||
|
$tmp['tsh']['home']['conceded']['home'] += $val->tsh_a;
|
||||||
|
|
||||||
|
}
|
||||||
|
// away home
|
||||||
|
if ($match->away_id == $val->home_id) {
|
||||||
|
// GLS
|
||||||
|
$tmp['gls']['away']['events']['home']++;
|
||||||
|
$tmp['gls']['away']['scored']['home'] += $val->gls_h;
|
||||||
|
$tmp['gls']['away']['conceded']['home'] += $val->gls_a;
|
||||||
|
// CRN
|
||||||
|
$tmp['crn']['away']['events']['home']++;
|
||||||
|
$tmp['crn']['away']['scored']['home'] += $val->crn_h;
|
||||||
|
$tmp['crn']['away']['conceded']['home'] += $val->crn_a;
|
||||||
|
// FLS
|
||||||
|
$tmp['fls']['away']['events']['home']++;
|
||||||
|
$tmp['fls']['away']['scored']['home'] += $val->fls_h;
|
||||||
|
$tmp['fls']['away']['conceded']['home'] += $val->fls_a;
|
||||||
|
// OFS
|
||||||
|
$tmp['ofs']['away']['events']['home']++;
|
||||||
|
$tmp['ofs']['away']['scored']['home'] += $val->ofs_h;
|
||||||
|
$tmp['ofs']['away']['conceded']['home'] += $val->ofs_a;
|
||||||
|
// CRD
|
||||||
|
$tmp['crd']['away']['events']['home']++;
|
||||||
|
$tmp['crd']['away']['scored']['home'] += $val->crd_h;
|
||||||
|
$tmp['crd']['away']['conceded']['home'] += $val->crd_a;
|
||||||
|
// SNT
|
||||||
|
$tmp['snt']['away']['events']['home']++;
|
||||||
|
$tmp['snt']['away']['scored']['home'] += $val->snt_h;
|
||||||
|
$tmp['snt']['away']['conceded']['home'] += $val->snt_a;
|
||||||
|
// TSH
|
||||||
|
$tmp['tsh']['away']['events']['home']++;
|
||||||
|
$tmp['tsh']['away']['scored']['home'] += $val->tsh_h;
|
||||||
|
$tmp['tsh']['away']['conceded']['home'] += $val->tsh_a;
|
||||||
|
}
|
||||||
|
// home away
|
||||||
|
if ($match->home_id == $val->away_id) {
|
||||||
|
// GLS
|
||||||
|
$tmp['gls']['home']['events']['away']++;
|
||||||
|
$tmp['gls']['home']['scored']['away'] += $val->gls_a;
|
||||||
|
$tmp['gls']['home']['conceded']['away'] += $val->gls_h;
|
||||||
|
// CRN
|
||||||
|
$tmp['crn']['home']['events']['away']++;
|
||||||
|
$tmp['crn']['home']['scored']['away'] += $val->crn_a;
|
||||||
|
$tmp['crn']['home']['conceded']['away'] += $val->crn_h;
|
||||||
|
// FLS
|
||||||
|
$tmp['fls']['home']['events']['away']++;
|
||||||
|
$tmp['fls']['home']['scored']['away'] += $val->fls_a;
|
||||||
|
$tmp['fls']['home']['conceded']['away'] += $val->fls_h;
|
||||||
|
// OFS
|
||||||
|
$tmp['ofs']['home']['events']['away']++;
|
||||||
|
$tmp['ofs']['home']['scored']['away'] += $val->ofs_a;
|
||||||
|
$tmp['ofs']['home']['conceded']['away'] += $val->ofs_h;
|
||||||
|
// CRD
|
||||||
|
$tmp['crd']['home']['events']['away']++;
|
||||||
|
$tmp['crd']['home']['scored']['away'] += $val->crd_a;
|
||||||
|
$tmp['crd']['home']['conceded']['away'] += $val->crd_h;
|
||||||
|
// SNT
|
||||||
|
$tmp['snt']['home']['events']['away']++;
|
||||||
|
$tmp['snt']['home']['scored']['away'] += $val->snt_a;
|
||||||
|
$tmp['snt']['home']['conceded']['away'] += $val->snt_h;
|
||||||
|
// TSH
|
||||||
|
$tmp['tsh']['home']['events']['away']++;
|
||||||
|
$tmp['tsh']['home']['scored']['away'] += $val->tsh_a;
|
||||||
|
$tmp['tsh']['home']['conceded']['away'] += $val->tsh_h;
|
||||||
|
|
||||||
|
}
|
||||||
|
// away away
|
||||||
|
if ($match->away_id == $val->away_id) {
|
||||||
|
// GLS
|
||||||
|
$tmp['gls']['away']['events']['away']++;
|
||||||
|
$tmp['gls']['away']['scored']['away'] += $val->gls_a;
|
||||||
|
$tmp['gls']['away']['conceded']['away'] += $val->gls_h;
|
||||||
|
// CRN
|
||||||
|
$tmp['crn']['away']['events']['away']++;
|
||||||
|
$tmp['crn']['away']['scored']['away'] += $val->crn_a;
|
||||||
|
$tmp['crn']['away']['conceded']['away'] += $val->crn_h;
|
||||||
|
// FLS
|
||||||
|
$tmp['fls']['away']['events']['away']++;
|
||||||
|
$tmp['fls']['away']['scored']['away'] += $val->fls_a;
|
||||||
|
$tmp['fls']['away']['conceded']['away'] += $val->fls_h;
|
||||||
|
// OFS
|
||||||
|
$tmp['ofs']['away']['events']['away']++;
|
||||||
|
$tmp['ofs']['away']['scored']['away'] += $val->ofs_a;
|
||||||
|
$tmp['ofs']['away']['conceded']['away'] += $val->ofs_h;
|
||||||
|
// CRD
|
||||||
|
$tmp['crd']['away']['events']['away']++;
|
||||||
|
$tmp['crd']['away']['scored']['away'] += $val->crd_a;
|
||||||
|
$tmp['crd']['away']['conceded']['away'] += $val->crd_h;
|
||||||
|
// SNT
|
||||||
|
$tmp['snt']['away']['events']['away']++;
|
||||||
|
$tmp['snt']['away']['scored']['away'] += $val->snt_a;
|
||||||
|
$tmp['snt']['away']['conceded']['away'] += $val->snt_h;
|
||||||
|
// TSH
|
||||||
|
$tmp['tsh']['away']['events']['away']++;
|
||||||
|
$tmp['tsh']['away']['scored']['away'] += $val->tsh_a;
|
||||||
|
$tmp['tsh']['away']['conceded']['away'] += $val->tsh_h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$cfHA = 2;
|
||||||
|
|
||||||
|
foreach ($tmp as $bet => $data) {
|
||||||
|
$expectations[$bet]['home'] = round((
|
||||||
|
$data['home']['scored']['home'] * $cfHA +
|
||||||
|
$data['home']['scored']['away'] +
|
||||||
|
$data['away']['conceded']['away'] * $cfHA +
|
||||||
|
$data['away']['conceded']['home']
|
||||||
|
) / (
|
||||||
|
$data['home']['events']['home'] * $cfHA +
|
||||||
|
$data['home']['events']['away'] +
|
||||||
|
$data['away']['events']['home'] +
|
||||||
|
$data['away']['events']['away'] * $cfHA
|
||||||
|
), 1);
|
||||||
|
$expectations[$bet]['away'] = round((
|
||||||
|
$data['home']['conceded']['home'] * $cfHA +
|
||||||
|
$data['home']['conceded']['away'] +
|
||||||
|
$data['away']['scored']['away'] * $cfHA +
|
||||||
|
$data['away']['scored']['home']
|
||||||
|
) / (
|
||||||
|
$data['home']['events']['home'] * $cfHA +
|
||||||
|
$data['home']['events']['away'] +
|
||||||
|
$data['away']['events']['home'] +
|
||||||
|
$data['away']['events']['away'] * $cfHA
|
||||||
|
), 1);
|
||||||
|
}
|
||||||
|
ExpectationsMinMax::calc($expectations, $match);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function sceleton()
|
||||||
|
{
|
||||||
|
$tmp = [];
|
||||||
|
$bets = ['gls', 'crn', 'fls', 'ofs', 'crd', 'snt', 'tsh'];
|
||||||
|
foreach ($bets as $bet) {
|
||||||
|
$tmp[$bet]['home']['events']['home'] = 0;
|
||||||
|
$tmp[$bet]['home']['scored']['home'] = 0;
|
||||||
|
$tmp[$bet]['home']['conceded']['home'] = 0;
|
||||||
|
// away home
|
||||||
|
$tmp[$bet]['away']['events']['home'] = 0;
|
||||||
|
$tmp[$bet]['away']['scored']['home'] = 0;
|
||||||
|
$tmp[$bet]['away']['conceded']['home'] = 0;
|
||||||
|
// home away
|
||||||
|
$tmp[$bet]['home']['events']['away'] = 0;
|
||||||
|
$tmp[$bet]['home']['scored']['away'] = 0;
|
||||||
|
$tmp[$bet]['home']['conceded']['away'] = 0;
|
||||||
|
// away away
|
||||||
|
$tmp[$bet]['away']['events']['away'] = 0;
|
||||||
|
$tmp[$bet]['away']['scored']['away'] = 0;
|
||||||
|
$tmp[$bet]['away']['conceded']['away'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,18 +6,6 @@ use App\Filament\Widgets\Boxes\ExpectationsTeam;
|
|||||||
|
|
||||||
class ExpectationCollecting
|
class ExpectationCollecting
|
||||||
{
|
{
|
||||||
public static function add(array &$result, string $team, string $bettype, string $scored_conceded, string $location, int $value)
|
|
||||||
{
|
|
||||||
if (! isset($result[$bettype][$team][$scored_conceded][$location])) {
|
|
||||||
$result[$bettype][$team][$scored_conceded][$location]['evt'] = 1;
|
|
||||||
$result[$bettype][$team][$scored_conceded][$location]['sum'] = $value;
|
|
||||||
} else {
|
|
||||||
$result[$bettype][$team][$scored_conceded][$location]['evt']++;
|
|
||||||
$result[$bettype][$team][$scored_conceded][$location]['sum'] += $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// ExpectationCollecting::sort($similar_past_matches, $tmp, 'gls', $value->home_id, $value->away_id, $value->gls_h, $value->gls_a, $match);
|
// ExpectationCollecting::sort($similar_past_matches, $tmp, 'gls', $value->home_id, $value->away_id, $value->gls_h, $value->gls_a, $match);
|
||||||
public static function sort(string $similar_past_matches, array &$result, string $bettype, int $home_id, int $away_id, float $val_home, float $val_away, object $match)
|
public static function sort(string $similar_past_matches, array &$result, string $bettype, int $home_id, int $away_id, float $val_home, float $val_away, object $match)
|
||||||
{
|
{
|
||||||
@@ -88,4 +76,15 @@ class ExpectationCollecting
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function add(array &$result, string $team, string $bettype, string $scored_conceded, string $location, int $value)
|
||||||
|
{
|
||||||
|
if (! isset($result[$bettype][$team][$scored_conceded][$location])) {
|
||||||
|
$result[$bettype][$team][$scored_conceded][$location]['evt'] = 1;
|
||||||
|
$result[$bettype][$team][$scored_conceded][$location]['sum'] = $value;
|
||||||
|
} else {
|
||||||
|
$result[$bettype][$team][$scored_conceded][$location]['evt']++;
|
||||||
|
$result[$bettype][$team][$scored_conceded][$location]['sum'] += $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,15 @@ class LoadEventsBoxes
|
|||||||
$team_id = (int) $filter['team_id'] ?? 0;
|
$team_id = (int) $filter['team_id'] ?? 0;
|
||||||
$similar_past_matches = $filter['similar_past_matches'];
|
$similar_past_matches = $filter['similar_past_matches'];
|
||||||
|
|
||||||
|
$match = StatisticFixtures::with('home')->with('away')->where('id', (int) $match_id)->first();
|
||||||
|
if ($similar_past_matches != 'none') {
|
||||||
|
$home_team = $match->home->ss_team_name;
|
||||||
|
$away_team = $match->away->ss_team_name;
|
||||||
|
} else {
|
||||||
|
$home_team = 'In Favour';
|
||||||
|
$away_team = 'Against';
|
||||||
|
}
|
||||||
|
|
||||||
if (! $league_id) {
|
if (! $league_id) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -20,15 +29,24 @@ class LoadEventsBoxes
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$match = StatisticFixtures::with('home')->with('away')->where('id', (int) $match_id)->first();
|
|
||||||
|
|
||||||
if (! $match) {
|
if (! $match) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$expectations = self::template();
|
$expectations = [];
|
||||||
|
$expectations['gls']['name'] = 'Goals';
|
||||||
|
$expectations['crn']['name'] = 'Corner';
|
||||||
|
$expectations['fls']['name'] = 'Fouls';
|
||||||
|
$expectations['ofs']['name'] = 'Offsides';
|
||||||
|
$expectations['crd']['name'] = 'Cards';
|
||||||
|
$expectations['snt']['name'] = 'Shots on Target';
|
||||||
|
$expectations['tsh']['name'] = 'Total Shots';
|
||||||
|
$expectations['home'] = $home_team;
|
||||||
|
$expectations['away'] = $away_team;
|
||||||
|
|
||||||
ExpectationsTeam::load($expectations, $filter, $match);
|
Expectation1X2::load($expectations, $filter, $match);
|
||||||
|
|
||||||
|
ExpectationsTeamNew::load($expectations, $filter, $match);
|
||||||
|
|
||||||
if ($team_id == $match->home_id) {
|
if ($team_id == $match->home_id) {
|
||||||
$expectations['active_team'] = $match->home->ss_team_name;
|
$expectations['active_team'] = $match->home->ss_team_name;
|
||||||
|
|||||||
@@ -0,0 +1,116 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Widgets\Boxes;
|
||||||
|
|
||||||
|
use App\Models\StatistikoDetail;
|
||||||
|
use App\Models\StatistikoPlayer;
|
||||||
|
|
||||||
|
class LoadPlayerAverages
|
||||||
|
{
|
||||||
|
public static function load(int &$team_id, string $season)
|
||||||
|
{
|
||||||
|
|
||||||
|
$players = StatistikoDetail::where('ss_team_id', $team_id)->get();
|
||||||
|
|
||||||
|
$arr = [];
|
||||||
|
|
||||||
|
foreach ($players as $val) {
|
||||||
|
|
||||||
|
$res = StatistikoPlayer::whereIn('ss_player_id', $players)->get();
|
||||||
|
|
||||||
|
$ss_player_id = (int) $val->ss_player_id;
|
||||||
|
$activeteam_id = (int) $val->activeteam_id;
|
||||||
|
$minutes_played = (int) $val->minutes_played;
|
||||||
|
$season = $val->event->season;
|
||||||
|
$home_id = (int) $val->event->home_id;
|
||||||
|
$away_id = (int) $val->event->away_id;
|
||||||
|
$startime = $val->event->starttime;
|
||||||
|
|
||||||
|
if ($startime->greaterThan(now()->subDays(180))) {
|
||||||
|
$last_180_days = true;
|
||||||
|
} else {
|
||||||
|
$last_180_days = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! isset($arr[$ss_player_id])) {
|
||||||
|
self::array_template($arr, $ss_player_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($activeteam_id == $home_id) {
|
||||||
|
$arr[$ss_player_id]['events_played_home'] += 1;
|
||||||
|
$arr[$ss_player_id]['minutes_played_home'] += $minutes_played;
|
||||||
|
$arr[$ss_player_id]['events_played_home'] += 1;
|
||||||
|
$arr[$ss_player_id]['minutes_played_home'] += $minutes_played;
|
||||||
|
if ($last_180_days) {
|
||||||
|
$arr[$ss_player_id]['events_played_home'] += 1;
|
||||||
|
$arr[$ss_player_id]['minutes_played_home'] += $minutes_played;
|
||||||
|
}
|
||||||
|
} elseif ($activeteam_id == $away_id) {
|
||||||
|
$arr[$ss_player_id]['events_played_away'] += 1;
|
||||||
|
$arr[$ss_player_id]['minutes_played_away'] += $minutes_played;
|
||||||
|
$arr[$ss_player_id]['events_played_away'] += 1;
|
||||||
|
$arr[$ss_player_id]['minutes_played_away'] += $minutes_played;
|
||||||
|
if ($last_180_days) {
|
||||||
|
$arr[$ss_player_id]['events_played_away'] += 1;
|
||||||
|
$arr[$ss_player_id]['minutes_played_away'] += $minutes_played;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
$cards = $val->card_yellow + $val->card_yellowred;
|
||||||
|
|
||||||
|
if ($season == 'last180days' && $last_180_days) {
|
||||||
|
$arr[$ss_player_id]['ss_player_id'] = $ss_player_id;
|
||||||
|
$arr[$ss_player_id]['season'] = 'last180days';
|
||||||
|
$arr[$ss_player_id]['total_events']++;
|
||||||
|
$arr[$ss_player_id]['total_min'] += $minutes_played;
|
||||||
|
$arr[$ss_player_id]['average_min'] = round($arr[$ss_player_id]['total_min'] / $arr[$ss_player_id]['total_events']);
|
||||||
|
$arr[$ss_player_id]['goals'] += $val->goals;
|
||||||
|
$arr[$ss_player_id]['fouls'] += $val->fouls;
|
||||||
|
$arr[$ss_player_id]['cards'] += $cards;
|
||||||
|
$arr[$ss_player_id]['offsides'] += $val->offsides;
|
||||||
|
$arr[$ss_player_id]['shots_on_target'] += $val->shots_on_target;
|
||||||
|
$arr[$ss_player_id]['shots_off_target'] += $val->shots_off_target;
|
||||||
|
$arr[$ss_player_id]['shots_blocked'] += $val->shots_blocked;
|
||||||
|
$arr[$ss_player_id]['total_shots'] += $val->shots_on_target + $val->shots_off_target + $val->shots_blocked;
|
||||||
|
}
|
||||||
|
if ($season != 'last180days') {
|
||||||
|
$arr[$ss_player_id]['ss_player_id'] = $ss_player_id;
|
||||||
|
$arr[$ss_player_id]['season'] = $season;
|
||||||
|
$arr[$ss_player_id]['total_events']++;
|
||||||
|
$arr[$ss_player_id]['total_min'] += $minutes_played;
|
||||||
|
$arr[$ss_player_id]['average_min'] = round($arr[$ss_player_id]['total_min'] / $arr[$ss_player_id]['total_events']);
|
||||||
|
$arr[$ss_player_id]['goals'] += $val->goals;
|
||||||
|
$arr[$ss_player_id]['fouls'] += $val->fouls;
|
||||||
|
$arr[$ss_player_id]['cards'] += $cards;
|
||||||
|
$arr[$ss_player_id]['offsides'] += $val->offsides;
|
||||||
|
$arr[$ss_player_id]['shots_on_target'] += $val->shots_on_target;
|
||||||
|
$arr[$ss_player_id]['shots_off_target'] += $val->shots_off_target;
|
||||||
|
$arr[$ss_player_id]['shots_blocked'] += $val->shots_blocked;
|
||||||
|
$arr[$ss_player_id]['total_shots'] += $val->shots_on_target + $val->shots_off_target + $val->shots_blocked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function array_template(array &$arr, int $ss_player_id)
|
||||||
|
{
|
||||||
|
$arr[$ss_player_id]['ss_player_id'] = 0;
|
||||||
|
$arr[$ss_player_id]['season'] = '';
|
||||||
|
$arr[$ss_player_id]['total_events'] = 0;
|
||||||
|
$arr[$ss_player_id]['total_min'] = 0;
|
||||||
|
$arr[$ss_player_id]['average_min'] = 0;
|
||||||
|
$arr[$ss_player_id]['events_played_home'] = 0;
|
||||||
|
$arr[$ss_player_id]['events_played_away'] = 0;
|
||||||
|
$arr[$ss_player_id]['minutes_played_home'] = 0;
|
||||||
|
$arr[$ss_player_id]['minutes_played_away'] = 0;
|
||||||
|
$arr[$ss_player_id]['goals'] = 0;
|
||||||
|
$arr[$ss_player_id]['fouls'] = 0;
|
||||||
|
$arr[$ss_player_id]['offsides'] = 0;
|
||||||
|
$arr[$ss_player_id]['shots_on_target'] = 0;
|
||||||
|
$arr[$ss_player_id]['shots_off_target'] = 0;
|
||||||
|
$arr[$ss_player_id]['shots_blocked'] = 0;
|
||||||
|
$arr[$ss_player_id]['total_shots'] = 0;
|
||||||
|
$arr[$ss_player_id]['cards'] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -94,7 +94,8 @@ class LoadEventsQueryAll
|
|||||||
})
|
})
|
||||||
->where(function ($query) use ($match, $similar_past_matches) {
|
->where(function ($query) use ($match, $similar_past_matches) {
|
||||||
if ($similar_past_matches == 'none') {
|
if ($similar_past_matches == 'none') {
|
||||||
return $query->orWhere('home_id', '=', $match->home_id)
|
return $query
|
||||||
|
->where('home_id', $match->home_id)
|
||||||
->orWhere('home_id', '=', $match->away_id)
|
->orWhere('home_id', '=', $match->away_id)
|
||||||
->orWhere('away_id', '=', $match->home_id)
|
->orWhere('away_id', '=', $match->home_id)
|
||||||
->orWhere('away_id', '=', $match->away_id);
|
->orWhere('away_id', '=', $match->away_id);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Filament\Widgets;
|
namespace App\Filament\Widgets;
|
||||||
|
|
||||||
|
use App\Filament\Widgets\Boxes\LoadPlayerAverages;
|
||||||
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;
|
||||||
@@ -391,14 +392,15 @@ class PlayerPropsDrop extends Widget
|
|||||||
$team_home_away = 'away';
|
$team_home_away = 'away';
|
||||||
}
|
}
|
||||||
|
|
||||||
$team_player_ids = StatistikoDetail::where('ss_team_id', $team_id)->pluck('ss_player_id')->toArray();
|
// $player_totals = LoadPlayerAverages::load($team_id, 'total');
|
||||||
|
|
||||||
|
$team_player_ids = StatistikoDetail::where('ss_team_id', $team_id)->pluck('ss_player_id')->toArray();
|
||||||
$player_totals = SofaScorePlayerPerSeason::with('details')->where('season', 'total')->whereIn('ss_player_id', $team_player_ids)->get();
|
$player_totals = SofaScorePlayerPerSeason::with('details')->where('season', 'total')->whereIn('ss_player_id', $team_player_ids)->get();
|
||||||
|
|
||||||
$count_player = 0;
|
$count_player = 0;
|
||||||
$tmp = [];
|
$tmp = [];
|
||||||
foreach ($player_totals as $key => $value) {
|
foreach ($player_totals as $ss_player_id => $value) {
|
||||||
$tmp[] = $value->details->ss_player_id;
|
$tmp[] = $ss_player_id;
|
||||||
if ($value->details != null && $value->details->position != 'GK' && (int) $value->details->is_active) {
|
if ($value->details != null && $value->details->position != 'GK' && (int) $value->details->is_active) {
|
||||||
$count_player++;
|
$count_player++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -267,8 +267,6 @@ trait UpdateHelper
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
StatistikoPlayer::where('ss_player_id', 0)->delete();
|
|
||||||
|
|
||||||
// 1. Finde alle Kombinationen, die mehrfach existieren
|
// 1. Finde alle Kombinationen, die mehrfach existieren
|
||||||
$duplicates = DB::table('ss_player_seasons')
|
$duplicates = DB::table('ss_player_seasons')
|
||||||
->select('season', 'ss_player_id', DB::raw('COUNT(*) as count'))
|
->select('season', 'ss_player_id', DB::raw('COUNT(*) as count'))
|
||||||
|
|||||||
Reference in new issue
Block a user