wip
This commit is contained in:
1 parent
e7936de68d
commit
d39a3a1dc2
1 file changed
+64
-35
@@ -4,8 +4,6 @@ namespace App\Actions\Statistics;
|
||||
|
||||
use App\Models\StatisticFixtures;
|
||||
use App\Models\StatistikoEvent;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class LoadEventsAspGoal
|
||||
{
|
||||
@@ -64,16 +62,53 @@ class LoadEventsAspGoal
|
||||
|
||||
switch ($similar_past_matches) {
|
||||
case 'league':
|
||||
$team_id = 0;
|
||||
$res = StatistikoEvent::when($league_id, function ($query) use ($league_id) {
|
||||
return $query->where('league_id', $league_id);
|
||||
})->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 'all':
|
||||
$league_id = 0;
|
||||
$team_id = 0;
|
||||
$res = StatistikoEvent::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;
|
||||
default:
|
||||
// none
|
||||
$handicap_range = 0;
|
||||
$total_range = 0;
|
||||
/**
|
||||
* STATISTIC DATA
|
||||
*/
|
||||
$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);
|
||||
case 'away':
|
||||
return $query->where('away_id', $team_id);
|
||||
default:
|
||||
return $query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
|
||||
}
|
||||
})->when($start, function ($query) use ($start) {
|
||||
return $query->where('starttime', '>=', $start);
|
||||
})->when($end, function ($query) use ($end) {
|
||||
return $query->where('starttime', '<=', $end);
|
||||
})
|
||||
->get();
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -81,33 +116,27 @@ class LoadEventsAspGoal
|
||||
/**
|
||||
* STATISTIC DATA
|
||||
*/
|
||||
DB::connection()->enableQueryLog();
|
||||
|
||||
$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);
|
||||
case 'away':
|
||||
return $query->where('away_id', $team_id);
|
||||
default:
|
||||
return $query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
|
||||
}
|
||||
})->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();
|
||||
|
||||
DB::listen(function ($res) {
|
||||
Log::info($res->sql, $res->bindings);
|
||||
});
|
||||
// $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);
|
||||
// case 'away':
|
||||
// return $query->where('away_id', $team_id);
|
||||
// default:
|
||||
// return $query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
|
||||
// }
|
||||
// })->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();
|
||||
|
||||
$datasets = [];
|
||||
$labels = [];
|
||||
|
||||
Reference in new issue
Block a user