X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FModels%2FRound.php;h=b6c9d023917f4076775dd3f5d8f55321bb57c745;hb=b5ab4afc3b152a0b39dc4c617a660653758a9f77;hp=3c191bc17efb200d65b1263371dec4599d93b508;hpb=6fe6cd1272c87bf7f89aa9ba59362e98c790c564;p=alttp.git diff --git a/app/Models/Round.php b/app/Models/Round.php index 3c191bc..b6c9d02 100644 --- a/app/Models/Round.php +++ b/app/Models/Round.php @@ -10,6 +10,16 @@ class Round extends Model use HasFactory; + public function isComplete() { + if (count($this->tournament->participants) == 0) return false; + if (count($this->results) == 0) return false; + foreach ($this->tournament->getRunners() as $participant) { + $result = $participant->findResult($this); + if (!$result || !$result->has_finished) return false; + } + return true; + } + public function updatePlacement() { $runners = []; foreach ($this->tournament->participants as $p) { @@ -53,6 +63,13 @@ class Round extends Model } + public function hideResults() { + foreach ($this->results as $result) { + $result->makeHidden(['forfeit', 'placement', 'score', 'time']); + } + } + + public function results() { return $this->hasMany(Result::class); } @@ -73,6 +90,7 @@ class Round extends Model ]; protected $fillable = [ + 'game', 'number', 'no_record', 'tournament_id',