]> git.localhorst.tv Git - alttp.git/blobdiff - app/Models/Participant.php
fix reevaluate command class name
[alttp.git] / app / Models / Participant.php
index 91b946d887fe726b2e066faf77d40991b8682485..6e8abbe2ea40d5b99ea5c1d91723e68417f28ef1 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);
@@ -94,6 +106,12 @@ class Participant extends Model
 
        protected $casts = [
                'roles' => 'array',
+               'user_id' => 'string',
+       ];
+
+       protected $fillable = [
+               'tournament_id',
+               'user_id',
        ];
 
        protected $with = [