several cosmetic updates

This commit is contained in:
Torsten 2017-08-04 16:51:28 +02:00
parent 5a90bb2c8a
commit 8c368524fe
8 changed files with 56 additions and 24 deletions

View file

@ -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) {

View file

@ -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();

View file

@ -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("/"); }

View file

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