hasMany('App\Game'); } // true, wenn irgend ein Game locked ist. public static function hasLockedGame($round_id) { //Log::info("Check Round::HasLockedGame => ".$round_id); $games = Game::where('round_id', $round_id)->get(); foreach ($games as $game) { if (Game::locked($game->id)==true) { return true; } } return false; } public static function isCompleted($round_id) { $round = Round::where('id','=',$round_id)->first(); $games = Game::where('round_id','=',$round->id)->get(); $completed = true; foreach($games as $game) { if ($game->score1==-1 || $game->score2==-1) { $completed=false; } } return $completed; } public static function getLastCompleteRoundId() { $season = Season::getCurrent(); $rounds=Round::where('season_id','=',$season->id)->orderBy('id')->get(); $lastCompleteRound=-1; foreach ($rounds as $round) { if (Round::isCompleted($round->id) == true) { $lastCompleteRound = $round->id; } } return $lastCompleteRound; } public static function getLastLockedRoundId() { $season = Season::getCurrent(); $rounds=Round::where('season_id','=',$season->id)->orderBy('id')->get(); $lastLockedRoundId=-1; foreach ($rounds as $round) { if (Round::hasLockedGame($round->id) == true) { $lastLockedRoundId = $round->id; } } return $lastLockedRoundId; } }