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