wip fix
This commit is contained in:
1 parent
9bcd4432c6
commit
6f92f9e1d5
1209 files changed
+220940
No files matched your search
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets\Boxes;
|
||||
|
||||
use App\Filament\Pages\Selections\Helper\GetSeason;
|
||||
use App\Filament\Widgets\Boxes\Helper\ExpectationAverage;
|
||||
use App\Models\StatistikoEvent;
|
||||
|
||||
class AverageLeagueSeason
|
||||
{
|
||||
public static function load(array &$expectations, array $filter)
|
||||
{
|
||||
$tournament_id = (int) $filter['league_id'] ?? 0;
|
||||
$seasonmode = $filter['seasonmode'];
|
||||
$active_season = GetSeason::active($seasonmode);
|
||||
|
||||
// Box 2
|
||||
// average made and got for liga selected
|
||||
// fixed to active season
|
||||
|
||||
$res = StatistikoEvent::where('league_id', $tournament_id)
|
||||
->when($active_season, function ($query) use ($active_season) {
|
||||
return $query->where('season', $active_season);
|
||||
})->get();
|
||||
|
||||
$result = [];
|
||||
if ($res) {
|
||||
foreach ($res as $val) {
|
||||
ExpectationAverage::filter($result, 'liga', 'gls', $val->gls_h, $val->gls_a);
|
||||
ExpectationAverage::filter($result, 'liga', 'fls', $val->fls_h, $val->fls_a);
|
||||
ExpectationAverage::filter($result, 'liga', 'ofs', $val->ofs_h, $val->ofs_a);
|
||||
ExpectationAverage::filter($result, 'liga', 'crd', $val->crd_h, $val->crd_a);
|
||||
ExpectationAverage::filter($result, 'liga', 'snt', $val->snt_h, $val->snt_a);
|
||||
ExpectationAverage::filter($result, 'liga', 'tsh', $val->tsh_h, $val->tsh_a);
|
||||
}
|
||||
|
||||
$bets = ['gls', 'fls', 'ofs', 'crd', 'snt', 'tsh'];
|
||||
if ($result) {
|
||||
foreach ($bets as $bet) {
|
||||
$expectations[$bet.'_liga_season']['home'] = round(array_sum($result['liga'][$bet]['home']) / \count($result['liga'][$bet]['home']), 1);
|
||||
$expectations[$bet.'_liga_season']['away'] = round(array_sum($result['liga'][$bet]['away']) / \count($result['liga'][$bet]['away']), 1);
|
||||
}
|
||||
} else {
|
||||
foreach ($bets as $bet) {
|
||||
$expectations[$bet.'_liga_season']['home'] = 0;
|
||||
$expectations[$bet.'_liga_season']['away'] = 0;
|
||||
}
|
||||
}
|
||||
$expectations['gls_liga_season']['name'] = 'Goals';
|
||||
$expectations['fls_liga_season']['name'] = 'Fouls';
|
||||
$expectations['ofs_liga_season']['name'] = 'Offsides';
|
||||
$expectations['crd_liga_season']['name'] = 'Cards';
|
||||
$expectations['snt_liga_season']['name'] = 'Shots on Target';
|
||||
$expectations['tsh_liga_season']['name'] = 'Total Shots';
|
||||
$expectations['active_season'] = $active_season;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets\Boxes;
|
||||
|
||||
use App\Filament\Pages\Selections\Helper\GetSeason;
|
||||
use App\Filament\Widgets\Boxes\Helper\ExpectationAverage;
|
||||
use App\Models\StatistikoEvent;
|
||||
|
||||
class AverageTeam
|
||||
{
|
||||
public static function load(array &$expectations, array $filter)
|
||||
{
|
||||
$tournament_id = (int) $filter['league_id'] ?? 0;
|
||||
$team_position = $filter['team_position'];
|
||||
$team_id = (int) $filter['team_id'] ?? 0;
|
||||
$season = $filter['season'] ?? 0;
|
||||
$season_or_date = $filter['season_or_date'] ?? 'season';
|
||||
$start = $filter['start_date'] ?? 0;
|
||||
$end = $filter['end_date'] ?? 0;
|
||||
$seasonmode = $filter['seasonmode'];
|
||||
|
||||
if ($season_or_date != 'season') {
|
||||
$season = 0;
|
||||
} else {
|
||||
$end = 0;
|
||||
$start = 0;
|
||||
$season = GetSeason::load($season, $seasonmode);
|
||||
}
|
||||
|
||||
$active_season = GetSeason::active($seasonmode);
|
||||
|
||||
// Average made and got for team selected
|
||||
// Box 1
|
||||
// for selected Date or Time or All
|
||||
// Box 2
|
||||
// fixed to active season
|
||||
// Box 3 wie 2
|
||||
// fixed to active season but all league
|
||||
$res = StatistikoEvent::where('league_id', $tournament_id)
|
||||
->when($start, function ($query) use ($start) {
|
||||
return $query->whereDate('starttime', '>=', $start);
|
||||
})->when($end, function ($query) use ($end) {
|
||||
return $query->whereDate('starttime', '<=', $end);
|
||||
})->when($season, function ($query) use ($season) {
|
||||
return $query->whereIn('season', $season);
|
||||
})->when($team_id, function ($query) use ($team_position, $team_id) {
|
||||
switch ($team_position) {
|
||||
case 'home':
|
||||
return $query->where('home_id', $team_id);
|
||||
case 'away':
|
||||
return $query->where('away_id', $team_id);
|
||||
default:
|
||||
return $query->orWhere('home_id', $team_id)
|
||||
->orWhere('away_id', '=', $team_id);
|
||||
}
|
||||
})->get();
|
||||
|
||||
$result = [];
|
||||
if ($res) {
|
||||
|
||||
// 1) la media dei falli di tutte le partite giocate dal Flamengo
|
||||
// (esempio, giocate 6 partite con falli 17-11-15-14-15-12, la media è 14)
|
||||
|
||||
// 2) la media dei falli di tutte le partite giocate nel campionato Brasiliano
|
||||
// (esempio 6 giornate giocate = 60 partite quindi 120 squadre, quindi 120 dati tipo 17-12-12-15-8-15-13-21-...,
|
||||
// quindi la media di questi 120 dati)
|
||||
|
||||
foreach ($res as $val) {
|
||||
|
||||
if ($team_position == 'home' && $team_id == $val->home_id) {
|
||||
ExpectationAverage::filter($result, 'team', 'gls', $val->gls_h, $val->gls_a);
|
||||
ExpectationAverage::filter($result, 'team', 'fls', $val->fls_h, $val->fls_a);
|
||||
ExpectationAverage::filter($result, 'team', 'ofs', $val->ofs_h, $val->ofs_a);
|
||||
ExpectationAverage::filter($result, 'team', 'crd', $val->crd_h, $val->crd_a);
|
||||
ExpectationAverage::filter($result, 'team', 'snt', $val->snt_h, $val->snt_a);
|
||||
ExpectationAverage::filter($result, 'team', 'tsh', $val->tsh_h, $val->tsh_a);
|
||||
} elseif ($team_position == 'away' && $team_id == $val->away_id) {
|
||||
ExpectationAverage::filter($result, 'team', 'gls', $val->gls_a, $val->gls_h);
|
||||
ExpectationAverage::filter($result, 'team', 'fls', $val->fls_a, $val->fls_h);
|
||||
ExpectationAverage::filter($result, 'team', 'ofs', $val->ofs_a, $val->ofs_h);
|
||||
ExpectationAverage::filter($result, 'team', 'crd', $val->crd_a, $val->crd_h);
|
||||
ExpectationAverage::filter($result, 'team', 'snt', $val->snt_a, $val->snt_h);
|
||||
ExpectationAverage::filter($result, 'team', 'tsh', $val->tsh_a, $val->tsh_h);
|
||||
} else {
|
||||
ExpectationAverage::filter($result, 'team', 'gls', $val->gls_a, $val->gls_h);
|
||||
ExpectationAverage::filter($result, 'team', 'fls', $val->fls_a, $val->fls_h);
|
||||
ExpectationAverage::filter($result, 'team', 'ofs', $val->ofs_a, $val->ofs_h);
|
||||
ExpectationAverage::filter($result, 'team', 'crd', $val->crd_a, $val->crd_h);
|
||||
ExpectationAverage::filter($result, 'team', 'snt', $val->snt_a, $val->snt_h);
|
||||
ExpectationAverage::filter($result, 'team', 'tsh', $val->tsh_a, $val->tsh_h);
|
||||
}
|
||||
}
|
||||
|
||||
$bets = ['gls', 'fls', 'ofs', 'crd', 'snt', 'tsh'];
|
||||
if ($result) {
|
||||
foreach ($bets as $bet) {
|
||||
$expectations[$bet.'_team']['home'] = round(array_sum($result['team'][$bet]['home']) / \count($result['team'][$bet]['home']), 1);
|
||||
$expectations[$bet.'_team']['away'] = round(array_sum($result['team'][$bet]['away']) / \count($result['team'][$bet]['away']), 1);
|
||||
}
|
||||
} else {
|
||||
foreach ($bets as $bet) {
|
||||
$expectations[$bet.'_team']['home'] = 0;
|
||||
$expectations[$bet.'_team']['away'] = 0;
|
||||
}
|
||||
}
|
||||
$expectations['gls_team']['name'] = 'Goals';
|
||||
$expectations['fls_team']['name'] = 'Fouls';
|
||||
$expectations['ofs_team']['name'] = 'Offsides';
|
||||
$expectations['crd_team']['name'] = 'Cards';
|
||||
$expectations['snt_team']['name'] = 'Shots on Target';
|
||||
$expectations['tsh_team']['name'] = 'Total Shots';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets\Boxes;
|
||||
|
||||
use App\Filament\Pages\Selections\Helper\GetSeason;
|
||||
use App\Filament\Widgets\Boxes\Helper\ExpectationAverage;
|
||||
use App\Models\StatistikoEvent;
|
||||
|
||||
class AverageTeamSeason
|
||||
{
|
||||
public static function load(array &$expectations, array $filter)
|
||||
{
|
||||
$tournament_id = (int) $filter['league_id'] ?? 0;
|
||||
$team_position = $filter['team_position'];
|
||||
$team_id = (int) $filter['team_id'] ?? 0;
|
||||
$seasonmode = $filter['seasonmode'];
|
||||
$active_season = GetSeason::active($seasonmode);
|
||||
|
||||
// Box 2
|
||||
// average made and got for team selected
|
||||
// fixed to active season
|
||||
|
||||
$res = StatistikoEvent::where('league_id', $tournament_id)
|
||||
->when($active_season, function ($query) use ($active_season) {
|
||||
return $query->where('season', $active_season);
|
||||
})->when($team_id, function ($query) use ($team_position, $team_id) {
|
||||
switch ($team_position) {
|
||||
case 'home':
|
||||
return $query->where('home_id', $team_id);
|
||||
case 'away':
|
||||
return $query->where('away_id', $team_id);
|
||||
default:
|
||||
return $query->orWhere('home_id', $team_id)
|
||||
->orWhere('away_id', '=', $team_id);
|
||||
}
|
||||
})->get();
|
||||
|
||||
$result = [];
|
||||
if ($res) {
|
||||
|
||||
// 1) la media dei falli di tutte le partite giocate dal Flamengo
|
||||
// (esempio, giocate 6 partite con falli 17-11-15-14-15-12, la media è 14)
|
||||
|
||||
// 2) la media dei falli di tutte le partite giocate nel campionato Brasiliano
|
||||
// (esempio 6 giornate giocate = 60 partite quindi 120 squadre, quindi 120 dati tipo 17-12-12-15-8-15-13-21-...,
|
||||
// quindi la media di questi 120 dati)
|
||||
|
||||
foreach ($res as $val) {
|
||||
if ($team_position == 'home' && $team_id == $val->home_id) {
|
||||
ExpectationAverage::filter($result, 'team', 'gls', $val->gls_h, $val->gls_a);
|
||||
ExpectationAverage::filter($result, 'team', 'fls', $val->fls_h, $val->fls_a);
|
||||
ExpectationAverage::filter($result, 'team', 'ofs', $val->ofs_h, $val->ofs_a);
|
||||
ExpectationAverage::filter($result, 'team', 'crd', $val->crd_h, $val->crd_a);
|
||||
ExpectationAverage::filter($result, 'team', 'snt', $val->snt_h, $val->snt_a);
|
||||
ExpectationAverage::filter($result, 'team', 'tsh', $val->tsh_h, $val->tsh_a);
|
||||
} elseif ($team_position == 'away' && $team_id == $val->away_id) {
|
||||
ExpectationAverage::filter($result, 'team', 'gls', $val->gls_a, $val->gls_h);
|
||||
ExpectationAverage::filter($result, 'team', 'fls', $val->fls_a, $val->fls_h);
|
||||
ExpectationAverage::filter($result, 'team', 'ofs', $val->ofs_a, $val->ofs_h);
|
||||
ExpectationAverage::filter($result, 'team', 'crd', $val->crd_a, $val->crd_h);
|
||||
ExpectationAverage::filter($result, 'team', 'snt', $val->snt_a, $val->snt_h);
|
||||
ExpectationAverage::filter($result, 'team', 'tsh', $val->tsh_a, $val->tsh_h);
|
||||
} else {
|
||||
ExpectationAverage::filter($result, 'team', 'gls', $val->gls_a, $val->gls_h);
|
||||
ExpectationAverage::filter($result, 'team', 'fls', $val->fls_a, $val->fls_h);
|
||||
ExpectationAverage::filter($result, 'team', 'ofs', $val->ofs_a, $val->ofs_h);
|
||||
ExpectationAverage::filter($result, 'team', 'crd', $val->crd_a, $val->crd_h);
|
||||
ExpectationAverage::filter($result, 'team', 'snt', $val->snt_a, $val->snt_h);
|
||||
ExpectationAverage::filter($result, 'team', 'tsh', $val->tsh_a, $val->tsh_h);
|
||||
}
|
||||
}
|
||||
|
||||
$bets = ['gls', 'fls', 'ofs', 'crd', 'snt', 'tsh'];
|
||||
if ($result) {
|
||||
foreach ($bets as $bet) {
|
||||
$expectations[$bet.'_team_season']['home'] = round(array_sum($result['team'][$bet]['home']) / \count($result['team'][$bet]['home']), 1);
|
||||
$expectations[$bet.'_team_season']['away'] = round(array_sum($result['team'][$bet]['away']) / \count($result['team'][$bet]['away']), 1);
|
||||
}
|
||||
} else {
|
||||
foreach ($bets as $bet) {
|
||||
$expectations[$bet.'_team_season']['home'] = 0;
|
||||
$expectations[$bet.'_team_season']['away'] = 0;
|
||||
}
|
||||
}
|
||||
$expectations['gls_team_season']['name'] = 'Goals';
|
||||
$expectations['fls_team_season']['name'] = 'Fouls';
|
||||
$expectations['ofs_team_season']['name'] = 'Offsides';
|
||||
$expectations['crd_team_season']['name'] = 'Cards';
|
||||
$expectations['snt_team_season']['name'] = 'Shots on Target';
|
||||
$expectations['tsh_team_season']['name'] = 'Total Shots';
|
||||
$expectations['active_season'] = $active_season;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets\Boxes;
|
||||
|
||||
use App\Filament\Widgets\Boxes\Helper\ExpectationCalculation;
|
||||
use App\Filament\Widgets\Boxes\Helper\ExpectationCollecting;
|
||||
use App\Filament\Widgets\Charts\LoadEvents\LoadEventsQueryAll;
|
||||
use App\Utilities\Round;
|
||||
|
||||
class ExpectationsTeam
|
||||
{
|
||||
public static function load(array &$expectations, array $filter, object $match)
|
||||
{
|
||||
/**
|
||||
* STATTISTIC DATA
|
||||
*/
|
||||
$team_id = (int) $filter['team_id'] ?? 0;
|
||||
$team_position = $filter['team_position'];
|
||||
$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);
|
||||
$count_events = $res->count();
|
||||
if (! $res) {
|
||||
return [];
|
||||
}
|
||||
$tmp = [];
|
||||
foreach ($res as $value) {
|
||||
ExpectationCollecting::sort($tmp, 'gls', $value->home_id, $value->away_id, $value->gls_h, $value->gls_a, $match);
|
||||
ExpectationCollecting::sort($tmp, 'fls', $value->home_id, $value->away_id, $value->fls_h, $value->fls_a, $match);
|
||||
ExpectationCollecting::sort($tmp, 'ofs', $value->home_id, $value->away_id, $value->ofs_h, $value->ofs_a, $match);
|
||||
ExpectationCollecting::sort($tmp, 'crd', $value->home_id, $value->away_id, $value->crd_h, $value->crd_a, $match);
|
||||
ExpectationCollecting::sort($tmp, 'snt', $value->home_id, $value->away_id, $value->snt_h, $value->snt_a, $match);
|
||||
ExpectationCollecting::sort($tmp, 'tsh', $value->home_id, $value->away_id, $value->tsh_h, $value->tsh_a, $match);
|
||||
ExpectationCollecting::sort($tmp, 'crn', $value->home_id, $value->away_id, $value->crn_h, $value->crn_a, $match);
|
||||
}
|
||||
$expectations = ExpectationCalculation::calc($tmp);
|
||||
$expectations['gls']['name'] = 'Goals';
|
||||
$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;
|
||||
|
||||
$expectations += ['win_count' => 0, 'draw_count' => 0, 'lost_count' => 0];
|
||||
foreach ($res 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_events / $expectations['win_count']), 2) : 0;
|
||||
$expectations['draw_odd'] = $expectations['draw_count'] ? number_format(Round::odd($count_events / $expectations['draw_count']), 2) : 0;
|
||||
$expectations['lost_odd'] = $expectations['lost_count'] ? number_format(Round::odd($count_events / $expectations['lost_count']), 2) : 0;
|
||||
$expectations['count_events'] = $count_events;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets\Boxes\Helper;
|
||||
|
||||
class ExpectationAverage
|
||||
{
|
||||
public static function filter(array &$result, string $type, string $bettype, float $val_home, float $val_away)
|
||||
{
|
||||
$result[$type][$bettype]['home'][] = (int) $val_home;
|
||||
$result[$type][$bettype]['away'][] = (int) $val_away;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets\Boxes\Helper;
|
||||
|
||||
use App\Models\StatistikoConfig;
|
||||
|
||||
class ExpectationCalculation
|
||||
{
|
||||
public static function calc(array $expectations)
|
||||
{
|
||||
$summen = [];
|
||||
$config = StatistikoConfig::pluck('value', 'varname');
|
||||
foreach ($config as $name => $value) {
|
||||
if (isset($expectations[$name])) {
|
||||
$summen[$name]['sum'] = array_sum($expectations[$name]) * $value;
|
||||
$summen[$name]['cnt'] = \count($expectations[$name]);
|
||||
} else {
|
||||
$summen[$name]['sum'] = 0;
|
||||
$summen[$name]['cnt'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$summen2 = [];
|
||||
$bets = ['gls', 'fls', 'ofs', 'crd', 'snt', 'tsh'];
|
||||
foreach ($bets as $name) {
|
||||
$summen2[$name]['home']['sum'] = 0;
|
||||
$summen2[$name]['home']['cnt'] = 0;
|
||||
$summen2[$name]['away']['sum'] = 0;
|
||||
$summen2[$name]['away']['cnt'] = 0;
|
||||
}
|
||||
|
||||
foreach ($summen as $key => $value) {
|
||||
foreach ($bets as $name) {
|
||||
if (strpos($key, $name) !== false) {
|
||||
if (strpos($key, 'home') !== false) {
|
||||
$summen2[$name]['home']['sum'] += $value['sum'];
|
||||
$summen2[$name]['home']['cnt'] += +$value['cnt'];
|
||||
}
|
||||
if (strpos($key, 'away') !== false) {
|
||||
$summen2[$name]['away']['sum'] += $value['sum'];
|
||||
$summen2[$name]['away']['cnt'] += +$value['cnt'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$asp_result = [];
|
||||
foreach ($summen2 as $bettype => $value) {
|
||||
$asp_result[$bettype]['home'] = round($value['home']['sum'] / $value['home']['cnt'], 1);
|
||||
$asp_result[$bettype]['away'] = round($value['away']['sum'] / $value['away']['cnt'], 1);
|
||||
}
|
||||
|
||||
return $asp_result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets\Boxes\Helper;
|
||||
|
||||
class ExpectationCollecting
|
||||
{
|
||||
public static function sort(array &$result, string $type, int $home_id, int $away_id, float $val_home, float $val_away, object $match)
|
||||
{
|
||||
|
||||
if ($home_id == $match->home_id) {
|
||||
$result[$type.'_home_made_total'][] = $val_home;
|
||||
$result[$type.'_home_made_home'][] = $val_home;
|
||||
$result[$type.'_home_got_total'][] = $val_away;
|
||||
$result[$type.'_home_got_home'][] = $val_away;
|
||||
} elseif ($away_id == $match->home_id) {
|
||||
$result[$type.'_home_made_total'][] = $val_away;
|
||||
$result[$type.'_home_got_total'][] = $val_away;
|
||||
} elseif ($home_id == $match->away_id) {
|
||||
$result[$type.'_home_made_total'][] = $val_away;
|
||||
$result[$type.'_home_got_total'][] = $val_away;
|
||||
} elseif ($away_id == $match->away_id) {
|
||||
$result[$type.'_home_made_total'][] = $val_home;
|
||||
$result[$type.'_home_made_home'][] = $val_home;
|
||||
$result[$type.'_home_got_total'][] = $val_away;
|
||||
$result[$type.'_home_got_home'][] = $val_home;
|
||||
}
|
||||
|
||||
if ($away_id == $match->away_id) {
|
||||
$result[$type.'_away_made_total'][] = $val_away;
|
||||
$result[$type.'_away_made_home'][] = $val_away;
|
||||
$result[$type.'_away_got_total'][] = $val_home;
|
||||
$result[$type.'_away_got_home'][] = $val_home;
|
||||
} elseif ($home_id == $match->away_id) {
|
||||
$result[$type.'_away_made_total'][] = $val_home;
|
||||
$result[$type.'_away_got_total'][] = $val_home;
|
||||
} elseif ($away_id == $match->home_id) {
|
||||
$result[$type.'_away_made_total'][] = $val_home;
|
||||
$result[$type.'_away_got_total'][] = $val_home;
|
||||
} elseif ($home_id == $match->home_id) {
|
||||
$result[$type.'_away_made_total'][] = $val_away;
|
||||
$result[$type.'_away_made_home'][] = $val_away;
|
||||
$result[$type.'_away_got_total'][] = $val_home;
|
||||
$result[$type.'_away_got_home'][] = $val_away;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets\Boxes;
|
||||
|
||||
use App\Models\StatisticFixtures;
|
||||
|
||||
class LoadEventsBoxes
|
||||
{
|
||||
public static function load(array $filter, bool $hasdots)
|
||||
{
|
||||
$league_id = (int) $filter['league_id'] ?? 0;
|
||||
$match_id = (int) $filter['match_id'] ?? 0;
|
||||
$team_id = (int) $filter['team_id'] ?? 0;
|
||||
$similar_past_matches = $filter['similar_past_matches'];
|
||||
|
||||
if (! $league_id) {
|
||||
return [];
|
||||
}
|
||||
if (! $match_id) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$match = StatisticFixtures::with('home')->with('away')->where('id', (int) $match_id)->first();
|
||||
|
||||
if (! $match) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$expectations = [];
|
||||
ExpectationsTeam::load($expectations, $filter, $match);
|
||||
|
||||
if ($team_id == $match->home_id) {
|
||||
$expectations['active_team'] = $match->home->ss_team_name;
|
||||
} else {
|
||||
$expectations['active_team'] = $match->away->ss_team_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* LEAGUE AVERAGES
|
||||
*/
|
||||
if ($team_id != 0 && $similar_past_matches == 'none') {
|
||||
AverageTeam::load($expectations, $filter);
|
||||
AverageTeamSeason::load($expectations, $filter);
|
||||
AverageLeagueSeason::load($expectations, $filter);
|
||||
}
|
||||
|
||||
return $expectations;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user