Rangliste vollständig

This commit is contained in:
Torsten 2017-06-27 08:22:25 +02:00
parent 43fd8c8cbf
commit c4973664b9
8 changed files with 76 additions and 68 deletions

View file

@ -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;
}

View file

@ -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'));
}

View file

@ -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;
}
}

View file

@ -34,18 +34,6 @@
</form>
</div>
@include('layouts.errors')
<!--
<section class="jumbotron text-center">
<div class="container">
<h1 class="jumbotron-heading">Hoschis Vollpfosten</h1>
<p class="lead text-muted">Eine Tippgemeinschaft unter Freunden.</p>
<a href="#" class="btn btn-primary">Erste Eingabe</a>
<a href="#" class="btn btn-secondary">Zweite Eingabe</a>
</div>
</section>
-->
@endsection

View file

@ -22,14 +22,16 @@
<table class="table-bordered">
<tr class="table-bordered">
<td class="table-bordered">Spiel</td>
<td class="table-bordered">Anstoss</td>
<td class="table-bordered">Ergebnis</td>
</tr>
<p>&nbsp;</p>
@foreach($round->games as $game)
<tr class="table-bordered">
<td>{{$game->team1 . " : " . $game->team2}}</td>
<td><a href="/games/edit/{{$game->id}}">{{ App\Game::resultString($game->id) }} </a></td>
<td>&nbsp;{{$game->team1 . " : " . $game->team2}}&nbsp;</td>
<td>&nbsp;{{App\User::toGermanDate($game->kickoff)}}&nbsp;</td>
<td><a href="/games/edit/{{$game->id}}">{{ App\Game::resultString($game->id) }} &nbsp; </a></td>
</tr>
@endforeach

View file

@ -20,6 +20,7 @@
<table class="table-bordered">
<tr class="table-bordered">
<td class="table-bordered">Spiel</td>
<td class="table-bordered">Anstoss</td>
<td class="table-bordered">Ergebnis</td>
<td class="table-bordered">Tipp</td>
@ -30,11 +31,13 @@
@foreach($round->games as $game)
<tr class="table-bordered">
<td class="table-bordered" style="width:600px;"><label class="text" href="/games/edit/{{ $game->id }}">{{ $game->team1 }} : {{ $game->team2 }}</label>&nbsp;</td>
<td class="table-bordered" style="width:350px;">{{ App\Game::has_result($game->id)==true ? $game->score1 . ' : ' . $game->score2 : 'Anstoss: ' . $game->kickoff }}</td>
<td class="table-bordered" style="width:600px;"><label class="text" > {{ App\User::toGermanDate($game->kickoff) }}</label></td>
<td class="table-bordered" style="width:350px;">{{ App\Game::has_result($game->id)==true ? $game->score1 . ' : ' . $game->score2 : ' Tippen ' }}</td>
<td class="table-bordered" style="width:75px;">
@if(App\Round::hasLockedGame($game->id)==true)
@if(App\Round::hasLockedGame($round->id)==true)
<span>{{ App\Tipp::resultString(App\Tipp::getTipp( $user->id,$game->id)->id) }} </span>
@else
<a href="/tipps/edit/{{App\Tipp::getTipp($user->id,$game->id)->id}}">{{ App\Tipp::getTipp($user->id,$game->id)->score1== -1 ? 'Tippen': App\Tipp::resultString(App\Tipp::getTipp($user->id,$game->id)->id) }} </a>

View file

@ -3,49 +3,18 @@
@section('content')
<div style="float:left;left:10%">
<div>Runde1</div>
<div>Runde2</div>
<div>Runde3</div>
<div>Runde4</div>
<div>Runde5</div>
<div>Runde6</div>
<div>Runde7</div>
<div>Runde8</div>
<div>Runde9</div>
<div>Runde10</div>
<div>Runde11</div>
<div>Runde12</div>
<div>Runde13</div>
<div>Runde14</div>
<div>Runde15</div>
<div>Runde16</div>
<div>Runde17</div>
<div>Runde18</div>
<div>Runde19</div>
<div>Runde20</div>
<div>Runde21</div>
<div>Runde22</div>
<div>Runde23</div>
<div>Runde24</div>
<div>Runde25</div>
<div>Runde26</div>
<div>Runde27</div>
<div>Runde28</div>
<div>Runde29</div>
<div>Runde30</div>
<div>Runde31</div>
<div>Runde32</div>
<div>Runde33</div>
<div>Runde34</div>
<div>Runde35</div>
<div>Runde36</div>
<div>Runde37</div>
<div>Runde38</div>
<div>Runde39</div>
<div>Runde40</div>
@foreach($all_rounds as $r)
@if (App\Round::hasLockedGame($r->id) )
<div>
@if ($r->id == $round->id)
<label>{{$r->name}}</label>
@else
<a href="/users/ranking/{{$r->id}}">{{$r->name}}</a>
@endif
</div>
@endif
@endforeach
</div>
<div style="float:left; position:relative;left:47%">
@ -71,7 +40,32 @@
<p>&nbsp;</p>
<table class="table-bordered">
<table>
<th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Spieler</span>
</div>
</th>
<th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Punkte Gesamt</span>
</div>
</th>
<th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Punkte Tag</span>
</div>
</th>
<th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Spiel 1 - Heim-Mannschaft</span>
</div>
</th>
<th style="height:140px;white-space: nowrap;">
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;">
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Spiel 1 - Gast-Mannschaft</span>
</div>
</th>
<tr class="table-bordered">
<td class="table-bordered" align="center" style="width:200px;">Name</td>
<td class="table-bordered" align="center">&nbsp;Total&nbsp;</td>

View file

@ -25,6 +25,7 @@ Route::get('/','UsersController@main')->name('home');
Route::get('/seasons','SeasonsController@index');
Route::get('/seasons/create','SeasonsController@create');
Route::post('/seasons/store','SeasonsController@store');
Route::get('/seasons/setcurrent/{new_season_id}','SeasonsController@setcurrent');
Route::get('/rounds','RoundsController@index');
Route::get('/rounds/create','RoundsController@create');
@ -40,7 +41,8 @@ Route::post('/games/store', 'GamesController@store');
Route::get('/users','UsersController@index');
Route::get('/users/edit/{user_id}','UsersController@edit');
Route::post('/users/store','UsersController@store');
Route::get('/users/ranking','UsersController@ranking');
Route::get('/users/ranking/{round_id}','UsersController@ranking');
Route::get('/tipps','TippsController@index');
Route::get('/tipps/edit/{tipp_id}','TippsController@edit');