This commit is contained in:
salam committed 2026-10-12 21:58:46 +02:00
1 parent e52722d3e1
commit d5713472fc
4 files changed
+3 -163

No files matched your search

@@ -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 ExpectationsBox3
{
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->count()) {
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;
}
}