diff --git a/pfosten/app/Game.php b/pfosten/app/Game.php index 3b28284e..6c814f71 100644 --- a/pfosten/app/Game.php +++ b/pfosten/app/Game.php @@ -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; } diff --git a/pfosten/app/Http/Controllers/UsersController.php b/pfosten/app/Http/Controllers/UsersController.php index 90db0066..c013b389 100644 --- a/pfosten/app/Http/Controllers/UsersController.php +++ b/pfosten/app/Http/Controllers/UsersController.php @@ -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')); } diff --git a/pfosten/app/Round.php b/pfosten/app/Round.php index edee1dbf..ad1e3852 100644 --- a/pfosten/app/Round.php +++ b/pfosten/app/Round.php @@ -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; + } + } diff --git a/pfosten/resources/views/registration/create.blade.php b/pfosten/resources/views/registration/create.blade.php index 2bf5c31d..11fafcc1 100644 --- a/pfosten/resources/views/registration/create.blade.php +++ b/pfosten/resources/views/registration/create.blade.php @@ -34,18 +34,6 @@ - - @include('layouts.errors') - @endsection \ No newline at end of file diff --git a/pfosten/resources/views/rounds/index.blade.php b/pfosten/resources/views/rounds/index.blade.php index e46dd673..ab90d515 100644 --- a/pfosten/resources/views/rounds/index.blade.php +++ b/pfosten/resources/views/rounds/index.blade.php @@ -22,14 +22,16 @@
| Spiel | +Anstoss | Ergebnis | |||||||||
| {{$game->team1 . " : " . $game->team2}} | -{{ App\Game::resultString($game->id) }} | +{{$game->team1 . " : " . $game->team2}} | +{{App\User::toGermanDate($game->kickoff)}} | +{{ App\Game::resultString($game->id) }} |
| Spiel | +Anstoss | Ergebnis | Tipp | @@ -30,11 +31,13 @@ @foreach($round->games as $game)||||||||
| - | {{ App\Game::has_result($game->id)==true ? $game->score1 . ' : ' . $game->score2 : 'Anstoss: ' . $game->kickoff }} | ++ + | {{ App\Game::has_result($game->id)==true ? $game->score1 . ' : ' . $game->score2 : ' Tippen ' }} |
- @if(App\Round::hasLockedGame($game->id)==true)
+ @if(App\Round::hasLockedGame($round->id)==true)
{{ App\Tipp::resultString(App\Tipp::getTipp( $user->id,$game->id)->id) }}
@else
{{ App\Tipp::getTipp($user->id,$game->id)->score1== -1 ? 'Tippen': App\Tipp::resultString(App\Tipp::getTipp($user->id,$game->id)->id) }}
diff --git a/pfosten/resources/views/users/ranking.blade.php b/pfosten/resources/views/users/ranking.blade.php
index 505107ff..25ef08dd 100644
--- a/pfosten/resources/views/users/ranking.blade.php
+++ b/pfosten/resources/views/users/ranking.blade.php
@@ -3,49 +3,18 @@
@section('content')
-
Runde1
- Runde2
- Runde3
- Runde4
- Runde5
- Runde6
- Runde7
- Runde8
- Runde9
- Runde10
- Runde11
- Runde12
- Runde13
- Runde14
- Runde15
- Runde16
- Runde17
- Runde18
- Runde19
- Runde20
-
- Runde21
- Runde22
- Runde23
- Runde24
- Runde25
- Runde26
- Runde27
- Runde28
- Runde29
- Runde30
-
- Runde31
- Runde32
- Runde33
- Runde34
- Runde35
- Runde36
- Runde37
- Runde38
- Runde39
- Runde40
+ @foreach($all_rounds as $r)
+ @if (App\Round::hasLockedGame($r->id) )
+
+ @if ($r->id == $round->id)
+
+ @else
+ {{$r->name}}
+ @endif
+
+ @endif
+ @endforeach
@@ -71,7 +40,32 @@
-
|