X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FModels%2FParticipant.php;h=6e8abbe2ea40d5b99ea5c1d91723e68417f28ef1;hb=HEAD;hp=91b946d887fe726b2e066faf77d40991b8682485;hpb=d32516335ea2534e15256c948e9c38d3de40794b;p=alttp.git diff --git a/app/Models/Participant.php b/app/Models/Participant.php index 91b946d..6e8abbe 100644 --- a/app/Models/Participant.php +++ b/app/Models/Participant.php @@ -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 = [