Rangliste almost done
This commit is contained in:
parent
12651fc2e8
commit
43fd8c8cbf
579 changed files with 172489 additions and 127 deletions
|
|
@ -3,14 +3,52 @@
|
|||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Game;
|
||||
|
||||
class Round extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'name','season_id'
|
||||
'name', 'season_id'
|
||||
];
|
||||
|
||||
public function games() {
|
||||
public function games()
|
||||
{
|
||||
return $this->hasMany('App\Game');
|
||||
}
|
||||
|
||||
|
||||
// true, wenn irgend ein Game locked ist.
|
||||
public static function hasLockedGame($round_id)
|
||||
{
|
||||
$games = Game::where('round_id', $round_id)->get();
|
||||
foreach ($games as $game) {
|
||||
if (Game::locked($game->id)==true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function isCompleted($round_id) {
|
||||
$round = Round::where('id','=',$round_id)->first();
|
||||
$games = Game::where('round_id','=',$round->id)->get();
|
||||
$completed = true;
|
||||
foreach($games as $game) {
|
||||
if ($game->score1==-1 || $game->score2==-1) { $completed=false; }
|
||||
}
|
||||
return $completed;
|
||||
}
|
||||
|
||||
public static function getLastCompleteRoundId() {
|
||||
$season = Season::getCurrent();
|
||||
$rounds=Round::where('season_id','=',$season->id)->orderBy('id')->get();
|
||||
$lastCompleteRound=-1;
|
||||
foreach ($rounds as $round) {
|
||||
if (Round::isCompleted($round->id) == true) {
|
||||
$lastCompleteRound = $round->id;
|
||||
}
|
||||
}
|
||||
return $lastCompleteRound;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue