92 lines
4.4 KiB
PHP
92 lines
4.4 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Widgets\Boxes\Helper;
|
|
|
|
use App\Filament\Widgets\Boxes\ExpectationsTeam;
|
|
|
|
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);
|
|
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)
|
|
{
|
|
/**
|
|
* takes values form statistiko_conf table
|
|
* there are 2 mthods A and B noe running B hardcodet
|
|
*/
|
|
if ($similar_past_matches != 'none') {
|
|
$result[$bettype.'_home_made_total'][] = $val_home;
|
|
$result[$bettype.'_away_made_total'][] = $val_away;
|
|
} elseif (ExpectationsTeam::$collectionMethod == 'B') {
|
|
// TEAM HOME
|
|
if ($match->home_id == $home_id) {
|
|
self::add($result, 'team_home', $bettype, 'scored', 'home', $val_home);
|
|
self::add($result, 'team_home', $bettype, 'conceded', 'home', $val_away);
|
|
}
|
|
|
|
if ($match->home_id == $away_id) {
|
|
self::add($result, 'team_home', $bettype, 'scored', 'away', $val_away);
|
|
self::add($result, 'team_home', $bettype, 'conceded', 'away', $val_home);
|
|
}
|
|
|
|
// TEAM AWAY
|
|
if ($match->away_id == $home_id) {
|
|
self::add($result, 'team_away', $bettype, 'scored', 'home', $val_home);
|
|
self::add($result, 'team_away', $bettype, 'conceded', 'home', $val_away);
|
|
}
|
|
|
|
if ($match->away_id == $away_id) {
|
|
self::add($result, 'team_away', $bettype, 'scored', 'away', $val_away);
|
|
self::add($result, 'team_away', $bettype, 'conceded', 'away', $val_home);
|
|
}
|
|
} else {
|
|
if ($home_id == $match->home_id) {
|
|
$result[$bettype.'_home_made_total'][] = $val_home;
|
|
$result[$bettype.'_home_made_home'][] = $val_home;
|
|
$result[$bettype.'_home_got_total'][] = $val_away;
|
|
$result[$bettype.'_home_got_home'][] = $val_away;
|
|
} elseif ($away_id == $match->home_id) {
|
|
$result[$bettype.'_home_made_total'][] = $val_away;
|
|
$result[$bettype.'_home_got_total'][] = $val_away;
|
|
} elseif ($home_id == $match->away_id) {
|
|
$result[$bettype.'_home_made_total'][] = $val_away;
|
|
$result[$bettype.'_home_got_total'][] = $val_away;
|
|
} elseif ($away_id == $match->away_id) {
|
|
$result[$bettype.'_home_made_total'][] = $val_home;
|
|
$result[$bettype.'_home_made_home'][] = $val_home;
|
|
$result[$bettype.'_home_got_total'][] = $val_away;
|
|
$result[$bettype.'_home_got_home'][] = $val_home;
|
|
}
|
|
|
|
if ($away_id == $match->away_id) {
|
|
$result[$bettype.'_away_made_total'][] = $val_away;
|
|
$result[$bettype.'_away_made_home'][] = $val_away;
|
|
$result[$bettype.'_away_got_total'][] = $val_home;
|
|
$result[$bettype.'_away_got_home'][] = $val_home;
|
|
} elseif ($home_id == $match->away_id) {
|
|
$result[$bettype.'_away_made_total'][] = $val_home;
|
|
$result[$bettype.'_away_got_total'][] = $val_home;
|
|
} elseif ($away_id == $match->home_id) {
|
|
$result[$bettype.'_away_made_total'][] = $val_home;
|
|
$result[$bettype.'_away_got_total'][] = $val_home;
|
|
} elseif ($home_id == $match->home_id) {
|
|
$result[$bettype.'_away_made_total'][] = $val_away;
|
|
$result[$bettype.'_away_made_home'][] = $val_away;
|
|
$result[$bettype.'_away_got_total'][] = $val_home;
|
|
$result[$bettype.'_away_got_home'][] = $val_away;
|
|
}
|
|
}
|
|
}
|
|
}
|