This commit is contained in:
Torsten 2017-10-25 10:42:05 +02:00
parent ed0c445bfa
commit 30f6157606
15 changed files with 248 additions and 169 deletions

View file

@ -59,8 +59,10 @@ class Round extends Model
}
public static function getFirstIncompleteRound() {
$season_id = Season::getCurrent()->id;
$rounds = Round::where('season_id','=',$season_id)->orderBy('id')->get();
$season = Season::getCurrent();
if (!$season) return -1;
$rounds = Round::where('season_id','=',$season->id)->orderBy('id')->get();
foreach($rounds as $round) {
if (!Round::isCompleted($round->id)) return $round->id;
}
@ -69,6 +71,8 @@ class Round extends Model
public static function getNextRoundId($roundId) {
$currentSeason = Season::getCurrent();
if (!$currentSeason) return -1;
$rounds = Round::where('season_id','=',$currentSeason->id)->where('id','>=',$roundId)->get();
foreach($rounds as $round) {
if ($round->id == $roundId) { continue; }
@ -79,6 +83,7 @@ class Round extends Model
public static function getLastLockedRoundId() {
$season = Season::getCurrent();
if (!$season) return -1;
$rounds=Round::where('season_id','=',$season->id)->orderBy('id')->get();
$lastLockedRoundId=-1;
foreach ($rounds as $round) {
@ -89,8 +94,15 @@ class Round extends Model
return $lastLockedRoundId;
}
public static function getFirstTippableRoundId() {
$round = Round::getFirstTippableRound();
if (!$round) return -1;
return $round->id;
}
public static function getFirstTippableRound() {
$season = Season::getCurrent();
if (!$season) return null;
$rounds=Round::where('season_id','=',$season->id)->orderBy('id')->get();
$locked = false;
foreach ($rounds as $round) {