X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FModels%2FUser.php;h=4f56ac17f93b8af4ef2aff0c8478ee913ee19fd1;hb=eebc6384e56336b66ec250fc2aea3be6171d53ff;hp=7f03b4acdf6a24ea4dc2bcec5145cb66a2b31ea9;hpb=edd0e97bfdc544114f30bf4c13a929631c44a555;p=alttp.git diff --git a/app/Models/User.php b/app/Models/User.php index 7f03b4a..4f56ac1 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -14,13 +14,35 @@ class User extends Authenticatable public function isParticipant(Tournament $tournament) { foreach ($tournament->participants as $participant) { - if ($participant->user->id == $this->id) { + if ($participant->user_id == $this->id) { return true; } } return false; } + public function isRunner(Tournament $tournament) { + foreach ($tournament->participants as $participant) { + if ($participant->user_id == $this->id) { + return in_array('runner', $participant->roles); + } + } + return false; + } + + public function isTournamentAdmin(Tournament $tournament) { + foreach ($tournament->participants as $participant) { + if ($participant->user_id == $this->id) { + return in_array('admin', $participant->roles); + } + } + return false; + } + + public function participation() { + return $this->hasMany(Participant::class); + } + /** * The attributes that are mass assignable. *