Rangliste almost done

This commit is contained in:
Torsten 2017-06-26 17:21:30 +02:00
parent 12651fc2e8
commit 43fd8c8cbf
579 changed files with 172489 additions and 127 deletions

View file

@ -3,10 +3,44 @@
namespace App;
use Illuminate\Database\Eloquent\Model;
use Log;
use Carbon;
class Game extends Model
{
protected $fillable = [
'id','round_id','team1','team2','score1','score2','kickoff'
];
// true, wenn Anstoss - 1hr > now()
public static function locked($game_id)
{
$game = Game::find($game_id);
$now = Carbon\Carbon::now();
$tipp_input_end = Carbon\Carbon::parse($game->kickoff)->addHour(-1);
return ($tipp_input_end <= $now);
}
public static function has_result($game_id) {
$game = Game::where('id',$game_id)->first();
$hasIt = $game->score1 > -1;
if ($hasIt==false) {
return false;
}
return true;
}
public static function resultString($game_id) {
$game = Game::where('id',$game_id)->first();
if (!Game::has_result($game_id)) { return "Anstoss: " . $game->kickoff;}
return $game->score1. " : " . $game->score2;
}
}