]> git.localhorst.tv Git - alttp.git/blobdiff - app/Models/User.php
application admin UI
[alttp.git] / app / Models / User.php
index e5bb4f174b49b5f2a96446627ab0148421f7f725..ff45c6177c234acddda70e6b62493863fb48d151 100644 (file)
@@ -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);