]> git.localhorst.tv Git - alttp.git/blobdiff - app/Models/Participant.php
round titles
[alttp.git] / app / Models / Participant.php
index 91b946d887fe726b2e066faf77d40991b8682485..38ecfdadf458a413ce71043a22ff69cb9a655ca1 100644 (file)
@@ -82,6 +82,18 @@ class Participant extends Model
                return in_array('admin', $this->roles);
        }
 
+       public function makeRunner() {
+               if (!is_array($this->roles)) {
+                       $this->roles = ['runner'];
+               } else if (!in_array('runner', $this->roles)) {
+                       $newRoles = array_values($this->roles);
+                       $newRoles[] = 'runner';
+                       $this->roles = $newRoles;
+               }
+               $this->save();
+               ParticipantChanged::dispatch($this);
+       }
+
 
        public function tournament() {
                return $this->belongsTo(Tournament::class);
@@ -96,6 +108,11 @@ class Participant extends Model
                'roles' => 'array',
        ];
 
+       protected $fillable = [
+               'tournament_id',
+               'user_id',
+       ];
+
        protected $with = [
                'user',
        ];