Working in Liga Auf/Abstieg
This commit is contained in:
parent
0d690560ab
commit
444ce18f63
4 changed files with 115 additions and 4 deletions
|
|
@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
use App\Season;
|
||||
use App\Round;
|
||||
use App\User;
|
||||
|
||||
use DB;
|
||||
use Log;
|
||||
|
|
@ -66,8 +67,9 @@ class League extends Model
|
|||
return ($score1[1] < $score2[1]);
|
||||
}
|
||||
|
||||
public static function getRanking($rank) {
|
||||
public static function getRanking($rank, $seasonId=-1) {
|
||||
$season = Season::getCurrent();
|
||||
if ($seasonId > -1) { $season=Season::where('id','=',$seasonId)->first(); };
|
||||
$leagues = League::where('rank','=',$rank)->where('season_id','=', $season->id)->orderBy('id')->get();
|
||||
|
||||
error_log("LeagueCount:".sizeof($leagues));
|
||||
|
|
@ -80,7 +82,7 @@ class League extends Model
|
|||
foreach($memberIds as $memberId) {
|
||||
$tpl=array();
|
||||
$tpl[0]=$memberId;
|
||||
$tpl[1]=0;
|
||||
$tpl[1]=0; // league_score
|
||||
$tpl[2]=0; // goals
|
||||
$tpl[3]=0; // countergoals
|
||||
$memberScores[$memberId] = $tpl;
|
||||
|
|
@ -105,4 +107,44 @@ class League extends Model
|
|||
return $leagueScores;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Aktuelle Liga-Zuordnung auf Basis des Rangs in der letzten Liga
|
||||
public static function getNewLeagueForPlayers()
|
||||
{
|
||||
$lastSeason = Season::getLast();
|
||||
$currentSeason = Season::getCurrent();
|
||||
|
||||
if (!$lastSeason) {
|
||||
dd("No last season handling implemented. Please fix/implement.");
|
||||
//TODO: Implement a qualification round
|
||||
}
|
||||
|
||||
$users = User::getActives();
|
||||
$usersLastSeason = User::getActives($lastSeason->id);
|
||||
|
||||
// Wenn der User in den roundTipps der previousSeaoson nicht existiert, nahm er an der Runde nicht
|
||||
// teil, und ist automatisch Liga 3.
|
||||
|
||||
foreach ($users as $key => $user) {
|
||||
|
||||
$found = false;
|
||||
foreach ($usersLastSeason as $userLastSeason) {
|
||||
if ($userLastSeason->id == $user->id) $found = true;
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
$users[$key]['rank']=League::RANK_LEAGUE3; // In der letzten Season unter den Actives nicht gefunden
|
||||
} else {
|
||||
// League1, 1-16: RANK_LEAGUE1
|
||||
// League1, 17-22: RANK_LEAGUE2
|
||||
// League2, 1-6: RANK_LEAGUE1
|
||||
// League2, 7-16: RANK_LEAGUE2
|
||||
// League2, 17-22: RANK_LEAGUE3
|
||||
// League3, best6: RANK_LEAGUE2
|
||||
// League3, 7-end: RANK_LEAGUE3
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue