diff --git a/pfosten/app/Http/Controllers/Leagues/LeaguesController.php b/pfosten/app/Http/Controllers/Leagues/LeaguesController.php index 8a94d03e..433afe0e 100644 --- a/pfosten/app/Http/Controllers/Leagues/LeaguesController.php +++ b/pfosten/app/Http/Controllers/Leagues/LeaguesController.php @@ -174,9 +174,9 @@ class LeaguesController extends Controller public function showLeagueRounds($league_rank, $maxRoundId) { if (Auth::guest()) { return redirect("/"); } - $maxRoundId = min(Round::getLastCompleteRoundId(),$maxRoundId); - $season=Season::getCurrent(); + $maxRoundId = min(Round::getLastRoundId($season->id),$maxRoundId); + $roundNames = Round::getNames(); $leagueNames = League::getNames(); $leagues = League::where('season_id','=',$season->id)->where('rank','=', $league_rank)->orderBy('id')->get(); @@ -198,7 +198,6 @@ class LeaguesController extends Controller $matchesTotal[$match->round_id][$league->id] = $lg; } } - } return view ('leagues.matches', compact('season', 'matchesTotal','leagues','leagueNames','roundNames')); diff --git a/pfosten/app/Round.php b/pfosten/app/Round.php index 91ba1af1..3452877f 100755 --- a/pfosten/app/Round.php +++ b/pfosten/app/Round.php @@ -116,7 +116,6 @@ class Round extends Model return $tippSpielLink; } - // Ab sofort Verzicht auf statische Methoden, soweit möglich. public function getLockTime() { @@ -153,4 +152,10 @@ class Round extends Model } return $roundnames; } + + public static function getLastRoundId($seasonId) { + $round = Round::where('season_id', '=', $seasonId)->orderBy('id','desc')->first(); // get last entry + return $round->id; + } + } diff --git a/pfosten/app/leagues/League.php b/pfosten/app/leagues/League.php index 84cd2b24..6dc0b4ea 100644 --- a/pfosten/app/leagues/League.php +++ b/pfosten/app/leagues/League.php @@ -88,13 +88,14 @@ class League extends Model $matches=Match::getMatchResults($league->id,-1); foreach ($matches as $match) { - if (!Round::isCompleted($match->round_id)) { continue; } - $memberScores[$match->user1_id][1] += $match->user1_league_score; - $memberScores[$match->user1_id][2] += $match->user1_rankscore; - $memberScores[$match->user1_id][3] += $match->user2_rankscore; - $memberScores[$match->user2_id][1] += $match->user2_league_score; - $memberScores[$match->user2_id][2] += $match->user2_rankscore; - $memberScores[$match->user2_id][3] += $match->user1_rankscore; + if (Round::isCompleted($match->round_id)) { + $memberScores[$match->user1_id][1] += $match->user1_league_score; + $memberScores[$match->user1_id][2] += $match->user1_rankscore; + $memberScores[$match->user1_id][3] += $match->user2_rankscore; + $memberScores[$match->user2_id][1] += $match->user2_league_score; + $memberScores[$match->user2_id][2] += $match->user2_rankscore; + $memberScores[$match->user2_id][3] += $match->user1_rankscore; + } } usort($memberScores, array('App\Leagues\League','cmpScore')); diff --git a/pfosten/app/leagues/Match.php b/pfosten/app/leagues/Match.php index 241db1a8..f03f57b9 100644 --- a/pfosten/app/leagues/Match.php +++ b/pfosten/app/leagues/Match.php @@ -94,7 +94,7 @@ class Match extends Model $match->round_name = $roundnames[$match->round_id]; $match->user1_name = $usernames[$match->user1_id]; $match->user2_name = $usernames[$match->user2_id]; - // Punktauswertung in Match::getResults($leagueId, $maxRoundId); + // Punktauswertung in Match::getMatchResults($leagueId, $maxRoundId); } return $matches; } @@ -156,34 +156,43 @@ class Match extends Model $roundtipps = Tipp::getRoundTipps($maxRoundId); $roundtipps = $roundtipps["roundtipps"]; $matches = Match::getLeagueMatches($leagueId, $maxRoundId); + $season = Season::getCurrent(); - if ($maxRoundId==-1) {$maxRoundId=Round::getLastCompleteRoundId();} + if ($maxRoundId==-1) { $maxRoundId = Round::getLastRoundId($season->id); } foreach($matches as $key => $match) { - if (!Round::isCompleted($match->round_id)) continue; $user1_key = $match->round_id."_".$match->user1_id; $user2_key = $match->round_id."_".$match->user2_id; - $user1_score = $roundtipps[$user1_key]["rankscore"]; - $user2_score = $roundtipps[$user2_key]["rankscore"]; + if (Round::isCompleted($match->round_id)) { - $matches[$key]->user1_rankscore = $user1_score; - $matches[$key]->user2_rankscore = $user2_score; + $user1_score = $roundtipps[$user1_key]["rankscore"]; + $user2_score = $roundtipps[$user2_key]["rankscore"]; - //$matches[$key]->user1_hits = $roundtipps[$user1_key][] + $matches[$key]->user1_rankscore = $user1_score; + $matches[$key]->user2_rankscore = $user2_score; - if ($user1_score > $user2_score) { - $matches[$key]->user1_league_score = 3; - $matches[$key]->user2_league_score = 0; + //$matches[$key]->user1_hits = $roundtipps[$user1_key][] - } - else if ($user1_score < $user2_score){ + if ($user1_score > $user2_score) { + $matches[$key]->user1_league_score = 3; + $matches[$key]->user2_league_score = 0; + + } + else if ($user1_score < $user2_score){ + $matches[$key]->user1_league_score = 0; + $matches[$key]->user2_league_score = 3; + } else { + $matches[$key]->user1_league_score = 1; + $matches[$key]->user2_league_score = 1; + } + + } else { // Untipped/future round $matches[$key]->user1_league_score = 0; - $matches[$key]->user2_league_score = 3; - } else { - $matches[$key]->user1_league_score = 1; - $matches[$key]->user2_league_score = 1; + $matches[$key]->user2_league_score = 0; + $matches[$key]->user1_rankscore = -1; + $matches[$key]->user2_rankscore = -1; } } diff --git a/pfosten/resources/views/leagues/matches.blade.php b/pfosten/resources/views/leagues/matches.blade.php index ca24fed5..f0dbb49d 100755 --- a/pfosten/resources/views/leagues/matches.blade.php +++ b/pfosten/resources/views/leagues/matches.blade.php @@ -27,7 +27,11 @@