code: public function setRolesById($roles)
      {
          $roles = is_array($roles)? $roles : [$roles];
          return $this->roles()->sync($roles);
      }
docs: Reassign roles from an id or an array of role Ids
  
  @param int|array $roles
  @return void