wip
This commit is contained in:
1 parent
d30eb76442
commit
01a3f41ec0
6 files changed
+210
-14
No files matched your search
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Statistics;
|
||||
|
||||
use App\Models\StatistikoEvent;
|
||||
|
||||
class EventData
|
||||
{
|
||||
public static function get($filter)
|
||||
{
|
||||
$league_id = (int) $filter['league_id'] ?? 0;
|
||||
$team_id = (int) $filter['team_id'] ?? 0;
|
||||
|
||||
if (! $league_id) {
|
||||
return [];
|
||||
}
|
||||
if (! $team_id) {
|
||||
return [];
|
||||
}
|
||||
|
||||
switch ($filter['team_position']) {
|
||||
case 'home':
|
||||
$res = StatistikoEvent::where('league_id', $league_id)->where('home_id', '=', $team_id)->get();
|
||||
break;
|
||||
|
||||
case 'away':
|
||||
$res = StatistikoEvent::where('league_id', $league_id)->where('away_id', '=', $team_id)->get();
|
||||
break;
|
||||
|
||||
default:
|
||||
$res = StatistikoEvent::where('league_id', $league_id)
|
||||
->where(function ($query) use ($team_id) {
|
||||
$query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
|
||||
})->get();
|
||||
break;
|
||||
}
|
||||
|
||||
$datasets = [];
|
||||
$labels = [];
|
||||
|
||||
foreach ($res as $value) {
|
||||
$labels[] = $value['starttime']->format('d. M.y');
|
||||
|
||||
$tmp = [];
|
||||
$tmp['crd_a'] = (int) $value['crd_a'];
|
||||
$tmp['crd_h'] = (int) $value['crd_h'];
|
||||
$tmp['crn_a'] = (int) $value['crn_a'];
|
||||
$tmp['crn_h'] = (int) $value['crn_h'];
|
||||
$tmp['fls_a'] = (int) $value['fls_a'];
|
||||
$tmp['fls_h'] = (int) $value['fls_h'];
|
||||
$tmp['gls_a'] = (int) $value['gls_a'];
|
||||
$tmp['gls_h'] = (int) $value['gls_h'];
|
||||
$tmp['ofs_a'] = (int) $value['ofs_a'];
|
||||
$tmp['ofs_h'] = (int) $value['ofs_h'];
|
||||
$tmp['snt_a'] = (int) $value['snt_a'];
|
||||
$tmp['snt_h'] = (int) $value['snt_h'];
|
||||
$tmp['tsh_a'] = (int) $value['tsh_a'];
|
||||
$tmp['tsh_h'] = (int) $value['tsh_h'];
|
||||
|
||||
$tmp['exp_handicap'] = (float) $value['exp_handicap'];
|
||||
$tmp['exp_total'] = (float) $value['exp_total'];
|
||||
$tmp['exp_away'] = (float) $value['expgoalsaway_value'];
|
||||
$tmp['exp_home'] = (float) $value['expgoalshome_value'];
|
||||
|
||||
$datasets[] = $tmp;
|
||||
}
|
||||
|
||||
return ['lables' => $labels, 'datasets' => $datasets];
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user