88 lines
2.6 KiB
PHP
88 lines
2.6 KiB
PHP
<?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'];
|
|
|
|
$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) {
|
|
return [];
|
|
}
|
|
if (! $match_id) {
|
|
return [];
|
|
}
|
|
|
|
if (! $match) {
|
|
return [];
|
|
}
|
|
|
|
$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;
|
|
|
|
Expectation1X2::load($expectations, $filter, $match);
|
|
|
|
ExpectationsTeamNew::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, $match);
|
|
AverageLeagueSeason::load($expectations, $filter);
|
|
}
|
|
|
|
return $expectations;
|
|
}
|
|
|
|
public static function template()
|
|
{
|
|
$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;
|
|
}
|
|
}
|