Rangliste vollständig
This commit is contained in:
parent
43fd8c8cbf
commit
c4973664b9
8 changed files with 76 additions and 68 deletions
|
|
@ -37,8 +37,17 @@ class Game extends Model
|
|||
|
||||
public static function resultString($game_id) {
|
||||
$game = Game::where('id',$game_id)->first();
|
||||
$now=Carbon\Carbon::now();
|
||||
|
||||
if (!Game::has_result($game_id)) { return "Anstoss: " . $game->kickoff;}
|
||||
if (!Game::has_result($game_id)) {
|
||||
if ($game->kickoff>$now) return "Anstoss: " . $game->kickoff;
|
||||
|
||||
$start=Carbon\Carbon::parse($game->kickoff);
|
||||
$end=$start->addHours(2);
|
||||
if ($end<$now && $start>$now) return "Läuft";
|
||||
|
||||
return "(Eingeben)";
|
||||
}
|
||||
return $game->score1. " : " . $game->score2;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,16 +113,13 @@ class UsersController extends Controller
|
|||
if (!$currentSeason) { return redirect("/"); }
|
||||
|
||||
if($round_id==-1) {
|
||||
$round_id = Round::getLastCompleteRoundId();
|
||||
$round_id = Round::getLastLockedRoundId();
|
||||
//Log::info("Last complete round id=" . $round_id);
|
||||
if ($round_id==-1) {return redirect("/");}
|
||||
}
|
||||
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
|
||||
|
||||
|
||||
|
||||
TippsController::createAllTips();
|
||||
|
||||
$users = DB::table('users')->where('deleted',null)->get();
|
||||
|
|
@ -149,8 +146,6 @@ class UsersController extends Controller
|
|||
$user->dayScore += $score;
|
||||
}
|
||||
|
||||
//if ($user->id==3 && $score>0) { Log::info("Adding score=" . $score. "from game_id=".$game->id."(".$game->team1." - ".$game->team2.", ".$round->name.") totalScore=".$user->totalScore.", dayScore=".$user->dayScore); }
|
||||
|
||||
$tippDisplay[$user->id][$game->id][0] = $tipp->score1 ==-1 ? 'x' : $tipp->score1;
|
||||
$tippDisplay[$user->id][$game->id][1] = $tipp->score2 ==-1 ? 'x' : $tipp->score2;
|
||||
$tippDisplay[$user->id][$game->id][2] = $tipp->joker;
|
||||
|
|
@ -171,7 +166,8 @@ class UsersController extends Controller
|
|||
$round=Round::where('id','=',$round_id)->first();
|
||||
$games=Game::where('round_id','=',$round->id)->get();
|
||||
|
||||
return view('users.ranking', compact('users','round','games','tippDisplay'));
|
||||
$all_rounds=Round::where('season_id','=',$currentSeason->id)->get();
|
||||
return view('users.ranking', compact('users','round','all_rounds','games','tippDisplay'));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ class Round extends Model
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function isCompleted($round_id) {
|
||||
$round = Round::where('id','=',$round_id)->first();
|
||||
$games = Game::where('round_id','=',$round->id)->get();
|
||||
|
|
@ -51,4 +53,16 @@ class Round extends Model
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue