46 lines
996 B
PHP
46 lines
996 B
PHP
<?php
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
}
|