src/Traits/HasRoles.php
public function setRolesById($roles)
    {
        $roles = is_array($roles)? $roles : [$roles];
        return $this->roles()->sync($roles);
    }
public function setRolesById($roles)
    {
        $roles = is_array($roles)? $roles : [$roles];
        return $this->roles()->sync($roles);
    }
Reassign roles from an id or an array of role Ids

@param int|array $roles
@return void