diff --git a/pfosten/app/Game.php b/pfosten/app/Game.php index 9c1bedb6..13f6459e 100755 --- a/pfosten/app/Game.php +++ b/pfosten/app/Game.php @@ -26,14 +26,8 @@ class Game extends Model public function hasResult() { $game = $this; - $hasIt = $game->score1 > -1; + return $game->score1 > -1; - if ($hasIt==false) { - - return false; - } - - return true; } public static function has_result($game_id) { diff --git a/pfosten/app/Http/Controllers/TippsController.php b/pfosten/app/Http/Controllers/TippsController.php index f7795bff..aca6bbef 100755 --- a/pfosten/app/Http/Controllers/TippsController.php +++ b/pfosten/app/Http/Controllers/TippsController.php @@ -62,17 +62,12 @@ class TippsController extends Controller return redirect('/'); } - if (! User::payment_date($user->id, $activeSeason->id)) { return view('users.no_payment'); } - $rounds = null; - - - TippsController::createTipps($user->id); // ggfs. fehlender Tipp Eintraege einfügen @@ -106,20 +101,21 @@ class TippsController extends Controller $user=Auth::user(); - if (Game::locked(request('id'))) return redirect('/tipps'); // Für Schlauberger, die die Tippmaske auflassen. - // Fetch, modify, save Tipp $tipp = Tipp::where('id', request('id'))->first(); + $game = Game::where('id', $tipp->game_id)->first(); + $round= Round::where('id',$game->round_id)->first(); + if (Round::hasLockedGame($round->id)) { return redirect('/tipps'); } // Für Schlauberger, die die Tippmaske auflassen. + $tipp->score1= request('score1'); $tipp->score2= request('score2'); if (request()->has('joker')) { - if (Round::hasLockedGame(request('round_id'))==false) { // Jokermod nur wenn Runde noch nicht begonnen hat - $tipp->joker=true; - } else { - $tipp->joker = false; - } + $tipp->joker=true; + } else { + $tipp->joker = false; } + $tipp->save(); diff --git a/pfosten/app/Http/Controllers/UsersController.php b/pfosten/app/Http/Controllers/UsersController.php index c6afd4db..236a83db 100755 --- a/pfosten/app/Http/Controllers/UsersController.php +++ b/pfosten/app/Http/Controllers/UsersController.php @@ -113,7 +113,18 @@ class UsersController extends Controller if($round_id==-1) { $round_id = Round::getLastLockedRoundId(); - if ($round_id==-1) {return redirect("/");} + if ($round_id==-1) { + + $sql="select DATE_FORMAT(date_sub(min(games.kickoff), interval 1 hour),'%d.%m.%Y %H:%i') as start_date from rounds,games where rounds.season_id=".$currentSeason->id." and games.round_id=rounds.id;"; + $date = DB::select($sql); + + if (count($date)>0) { + $start_date = $date[0]->start_date; + return view('users.no_ranking', compact('start_date')); + } else { + return redirect("/"); + } + } } if (Auth::guest()) { return redirect("/"); } diff --git a/pfosten/app/Round.php b/pfosten/app/Round.php index 9558e0f2..5fa64c35 100755 --- a/pfosten/app/Round.php +++ b/pfosten/app/Round.php @@ -5,6 +5,7 @@ namespace App; use Illuminate\Database\Eloquent\Model; use App\Game; use Log; +use DB; class Round extends Model { @@ -66,4 +67,11 @@ class Round extends Model return $lastLockedRoundId; } + public static function getClosestRoundToNow() { + $sql="select round_id,DATEDIFF(NOW(),kickoff) from games order by 2 desc limit 1;"; + $result=DB::select($sql); + if (count($result)==0) return 0; + + return $result[0]->round_id; + } } diff --git a/pfosten/resources/views/layouts/nav.blade.php b/pfosten/resources/views/layouts/nav.blade.php index 0ed5f457..c211b6ab 100644 --- a/pfosten/resources/views/layouts/nav.blade.php +++ b/pfosten/resources/views/layouts/nav.blade.php @@ -8,7 +8,7 @@ Start       @if (Auth::user()->admin) Saison       - Runden       + Runden       Spieler       @endif Tipps       diff --git a/pfosten/resources/views/rounds/index.blade.php b/pfosten/resources/views/rounds/index.blade.php index 614c9868..2d1db294 100755 --- a/pfosten/resources/views/rounds/index.blade.php +++ b/pfosten/resources/views/rounds/index.blade.php @@ -14,8 +14,8 @@
- @foreach($rounds->reverse() as $round) -
{{ $round->name }}
+ @foreach($rounds as $round) +
{{ $round->name }}
@@ -56,6 +56,8 @@

 

+

 

+ @endforeach diff --git a/pfosten/resources/views/tipps/index.blade.php b/pfosten/resources/views/tipps/index.blade.php index ecad1dc7..ba4cecd3 100755 --- a/pfosten/resources/views/tipps/index.blade.php +++ b/pfosten/resources/views/tipps/index.blade.php @@ -16,7 +16,7 @@ @if ($activeSeason)
- @foreach($rounds->reverse() as $round) + @foreach($rounds as $round)
diff --git a/pfosten/resources/views/users/no_ranking.blade.php b/pfosten/resources/views/users/no_ranking.blade.php new file mode 100644 index 00000000..5128c6ec --- /dev/null +++ b/pfosten/resources/views/users/no_ranking.blade.php @@ -0,0 +1,21 @@ +@extends('layouts.layout') + +@section('content') +
+
+

+

Dein Zahlungseingang für die Saison wurde noch nicht registriert.

+

+ +
+ Ok +
+

+
+ +
+ + + + +@endsection \ No newline at end of file