]> git.localhorst.tv Git - alttp.git/blobdiff - app/Models/User.php
server calculated scoring
[alttp.git] / app / Models / User.php
index 535af2e07e828232ba2e9e2843ad507d1222d481..4f56ac17f93b8af4ef2aff0c8478ee913ee19fd1 100644 (file)
@@ -14,13 +14,31 @@ 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);
        }