X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FModels%2FUser.php;h=ff45c6177c234acddda70e6b62493863fb48d151;hb=43da6b2ec78774e7b045a09c68af39717b5f5dbc;hp=e5bb4f174b49b5f2a96446627ab0148421f7f725;hpb=a748d5724c8acff6e3bb3fe6c20aa5968b65d58a;p=alttp.git diff --git a/app/Models/User.php b/app/Models/User.php index e5bb4f1..ff45c61 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -16,6 +16,24 @@ class User extends Authenticatable return $this->role === 'admin'; } + public function isApplicant(Tournament $tournament) { + foreach ($tournament->applications as $applicant) { + if ($applicant->user_id == $this->id) { + return true; + } + } + return false; + } + + public function isDeniedApplicant(Tournament $tournament) { + foreach ($tournament->applications as $applicant) { + if ($applicant->user_id == $this->id) { + return $applicant->denied; + } + } + return false; + } + public function isParticipant(Tournament $tournament) { foreach ($tournament->participants as $participant) { if ($participant->user_id == $this->id) { @@ -56,6 +74,14 @@ class User extends Authenticatable return false; } + public function hasFinished(Round $round) { + foreach ($round->results as $result) { + if ($result->user_id != $this->id) continue; + return $result->has_finished; + } + return false; + } + public function participation() { return $this->hasMany(Participant::class);