X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FModels%2FParticipant.php;h=38ecfdadf458a413ce71043a22ff69cb9a655ca1;hb=12f64085fd212a9744db01790cefad53c970e8d9;hp=91b946d887fe726b2e066faf77d40991b8682485;hpb=d32516335ea2534e15256c948e9c38d3de40794b;p=alttp.git diff --git a/app/Models/Participant.php b/app/Models/Participant.php index 91b946d..38ecfda 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); @@ -96,6 +108,11 @@ class Participant extends Model 'roles' => 'array', ]; + protected $fillable = [ + 'tournament_id', + 'user_id', + ]; + protected $with = [ 'user', ];