wip
This commit is contained in:
1 parent
2734b06350
commit
fbaadcd248
9 files changed
+213
-219
No files matched your search
@@ -2,15 +2,14 @@
|
||||
|
||||
namespace App\Filament\Widgets\Data;
|
||||
|
||||
use App\Models\StatisticFixtures;
|
||||
use App\Models\StatistikoEvent;
|
||||
use App\Models\StatistikoPlayer;
|
||||
|
||||
class EventsLoadAspGoal
|
||||
class LoadEventsAspGoal
|
||||
{
|
||||
public static function load($filter)
|
||||
{
|
||||
// dd($filter);
|
||||
dd($filter);
|
||||
|
||||
$league_id = (int) $filter['league_id'] ?? 0;
|
||||
|
||||
@@ -23,27 +22,41 @@ class EventsLoadAspGoal
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* WITH PLAYER
|
||||
*/
|
||||
$tm_player_id = $filter['tm_player_id'];
|
||||
|
||||
if ($tm_player_id) {
|
||||
$matches_played = StatistikoPlayer::where('tm_player_id', (int) $tm_player_id)->pluck('match_id')->toArray();
|
||||
} else {
|
||||
$matches_played = false;
|
||||
}
|
||||
|
||||
$team_position = $filter['team_position'];
|
||||
|
||||
/**
|
||||
* ACCURACY DATA
|
||||
* STATTISTIC DATA
|
||||
*/
|
||||
switch ($filter['team_position']) {
|
||||
case 'home':
|
||||
$res = StatisticFixtures::where('league_id', $league_id)->where('home_id', $team_id)->first();
|
||||
break;
|
||||
|
||||
case 'away':
|
||||
$res = StatisticFixtures::where('league_id', $league_id)->where('away_id', $team_id)->first();
|
||||
break;
|
||||
|
||||
default:
|
||||
$res = StatisticFixtures::where('league_id', $league_id)
|
||||
->where(function ($query) use ($team_id) {
|
||||
$query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
|
||||
})->first();
|
||||
break;
|
||||
}
|
||||
$res = StatistikoEvent::where('league_id', $league_id)
|
||||
->where(function ($query) use ($team_id, $team_position) {
|
||||
switch ($team_position) {
|
||||
case 'home':
|
||||
return $query->where('home_id', '=', $team_id);
|
||||
case 'away':
|
||||
return $query->where('away_id', '=', $team_id);
|
||||
default:
|
||||
return $query->where('home_id', '=', $team_id)
|
||||
->orWhere('away_id', '=', $team_id);
|
||||
}
|
||||
})
|
||||
->when($matches_played, function ($query) use ($matches_played) {
|
||||
return $query->whereIn('match_id', $matches_played);
|
||||
})->when($start, function ($query) use ($start) {
|
||||
return $query->where('starttime', '>=', $start);
|
||||
})->when($end, function ($query) use ($end) {
|
||||
return $query->where('starttime', '<=', $end);
|
||||
})->first();
|
||||
|
||||
$start = $filter['start_date'] ?? 0;
|
||||
|
||||
@@ -81,63 +94,84 @@ class EventsLoadAspGoal
|
||||
|
||||
$similar_past_matches = $filter['similar_past_matches'] ?? 0;
|
||||
|
||||
switch ($similar_past_matches) {
|
||||
case 'league':
|
||||
$res = StatistikoEvent::when($league_id, function ($query) use ($league_id) {
|
||||
$res = StatistikoEvent::when($league_id, function ($query) use ($league_id, $similar_past_matches) {
|
||||
switch ($similar_past_matches) {
|
||||
case 'league':
|
||||
return $query->where('league_id', $league_id);
|
||||
})->when($matches_played, function ($query) use ($matches_played) {
|
||||
return $query->whereIn('match_id', $matches_played);
|
||||
})->when($handicap_range, function ($query) use ($handicap_range) {
|
||||
default:
|
||||
return $query->whereBetween('exp_handicap', $handicap_range);
|
||||
})->when($total_range, function ($query) use ($total_range) {
|
||||
return $query->whereBetween('exp_total', $total_range);
|
||||
})->when($start, function ($query) use ($start) {
|
||||
return $query->where('starttime', '>=', $start);
|
||||
})->when($end, function ($query) use ($end) {
|
||||
return $query->where('starttime', '<=', $end);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
|
||||
break;
|
||||
case 'all':
|
||||
$res = StatistikoEvent::when($handicap_range, function ($query) use ($handicap_range) {
|
||||
return $query->whereBetween('exp_handicap', $handicap_range);
|
||||
})->when($matches_played, function ($query) use ($matches_played) {
|
||||
return $query->whereIn('match_id', $matches_played);
|
||||
})->when($total_range, function ($query) use ($total_range) {
|
||||
return $query->whereBetween('exp_total', $total_range);
|
||||
})->when($start, function ($query) use ($start) {
|
||||
return $query->where('starttime', '>=', $start);
|
||||
})->when($end, function ($query) use ($end) {
|
||||
return $query->where('starttime', '<=', $end);
|
||||
})
|
||||
->get();
|
||||
})->when($matches_played, function ($query) use ($matches_played) {
|
||||
return $query->whereIn('match_id', $matches_played);
|
||||
})->when($handicap_range, function ($query) use ($handicap_range) {
|
||||
return $query->whereBetween('exp_handicap', $handicap_range);
|
||||
})->when($total_range, function ($query) use ($total_range) {
|
||||
return $query->whereBetween('exp_total', $total_range);
|
||||
})->when($start, function ($query) use ($start) {
|
||||
return $query->where('starttime', '>=', $start);
|
||||
})->when($end, function ($query) use ($end) {
|
||||
return $query->where('starttime', '<=', $end);
|
||||
})
|
||||
->get();
|
||||
|
||||
break;
|
||||
// case 'none':
|
||||
// $res = StatistikoEvent::when($league_id, function ($query) use ($league_id) {
|
||||
// return $query->where('league_id', $league_id);
|
||||
// })->when($team_id, function ($query) use ($team_id, $team_position) {
|
||||
// switch ($team_position) {
|
||||
// case 'home':
|
||||
// return $query->where('home_id', $team_id);
|
||||
// break;
|
||||
// case 'away':
|
||||
// return $query->where('away_id', $team_id);
|
||||
// break;
|
||||
// default:
|
||||
// return $query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
|
||||
// break;
|
||||
// }
|
||||
// })->when($start, function ($query) use ($start) {
|
||||
// return $query->where('starttime', '>=', $start);
|
||||
// })->when($end, function ($query) use ($end) {
|
||||
// return $query->where('starttime', '<=', $end);
|
||||
// })
|
||||
// ->get();
|
||||
// switch ($similar_past_matches) {
|
||||
// case 'league':
|
||||
// $res = StatistikoEvent::when($league_id, function ($query) use ($league_id) {
|
||||
// return $query->where('league_id', $league_id);
|
||||
// })->when($matches_played, function ($query) use ($matches_played) {
|
||||
// return $query->whereIn('match_id', $matches_played);
|
||||
// })->when($handicap_range, function ($query) use ($handicap_range) {
|
||||
// return $query->whereBetween('exp_handicap', $handicap_range);
|
||||
// })->when($total_range, function ($query) use ($total_range) {
|
||||
// return $query->whereBetween('exp_total', $total_range);
|
||||
// })->when($start, function ($query) use ($start) {
|
||||
// return $query->where('starttime', '>=', $start);
|
||||
// })->when($end, function ($query) use ($end) {
|
||||
// return $query->where('starttime', '<=', $end);
|
||||
// })
|
||||
// ->get();
|
||||
|
||||
// break;
|
||||
}
|
||||
// break;
|
||||
// case 'all':
|
||||
// $res = StatistikoEvent::when($handicap_range, function ($query) use ($handicap_range) {
|
||||
// return $query->whereBetween('exp_handicap', $handicap_range);
|
||||
// })->when($matches_played, function ($query) use ($matches_played) {
|
||||
// return $query->whereIn('match_id', $matches_played);
|
||||
// })->when($total_range, function ($query) use ($total_range) {
|
||||
// return $query->whereBetween('exp_total', $total_range);
|
||||
// })->when($start, function ($query) use ($start) {
|
||||
// return $query->where('starttime', '>=', $start);
|
||||
// })->when($end, function ($query) use ($end) {
|
||||
// return $query->where('starttime', '<=', $end);
|
||||
// })
|
||||
// ->get();
|
||||
|
||||
// break;
|
||||
// // case 'none':
|
||||
// // $res = StatistikoEvent::when($league_id, function ($query) use ($league_id) {
|
||||
// // return $query->where('league_id', $league_id);
|
||||
// // })->when($team_id, function ($query) use ($team_id, $team_position) {
|
||||
// // switch ($team_position) {
|
||||
// // case 'home':
|
||||
// // return $query->where('home_id', $team_id);
|
||||
// // break;
|
||||
// // case 'away':
|
||||
// // return $query->where('away_id', $team_id);
|
||||
// // break;
|
||||
// // default:
|
||||
// // return $query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
|
||||
// // break;
|
||||
// // }
|
||||
// // })->when($start, function ($query) use ($start) {
|
||||
// // return $query->where('starttime', '>=', $start);
|
||||
// // })->when($end, function ($query) use ($end) {
|
||||
// // return $query->where('starttime', '<=', $end);
|
||||
// // })
|
||||
// // ->get();
|
||||
|
||||
// // break;
|
||||
// }
|
||||
|
||||
$datasets = [];
|
||||
$labels = [];
|
||||
|
||||
Reference in new issue
Block a user