Learner\Repositories\Eloquent\UserRepository::attachRoleById PHP Method

attachRoleById() public method

Give user one or more roles.
public attachRoleById ( integer $userId, array $roleIds ) : User
$userId integer
$roleIds array
return Learner\Models\User
    public function attachRoleById($userId, $roleIds)
    {
        $user = $this->findWithTrashedById($userId);
        $user->roles()->sync($roleIds);
        return $this->model->withTrashed()->with(['roles'])->findOrFail($userId);
    }