]> git.localhorst.tv Git - alttp.git/blobdiff - app/Models/User.php
tournament admins
[alttp.git] / app / Models / User.php
index 7f03b4acdf6a24ea4dc2bcec5145cb66a2b31ea9..4f56ac17f93b8af4ef2aff0c8478ee913ee19fd1 100644 (file)
@@ -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.
         *