Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$dontVersionable works only in SNAPSHOT mode #80

Closed
robsonek opened this issue Jul 8, 2024 · 1 comment
Closed

$dontVersionable works only in SNAPSHOT mode #80

robsonek opened this issue Jul 8, 2024 · 1 comment

Comments

@robsonek
Copy link
Contributor

robsonek commented Jul 8, 2024

Why don't you remove fields from $dontVersionable in DIFF mode like in SNAPSHOT mode?

public function getVersionableAttributes(array $replacements = []): array
{
    return match ($this->getVersionStrategy()) {
        VersionStrategy::DIFF => $this->getDiffAttributes($replacements),
        VersionStrategy::SNAPSHOT => $this->getSnapshotAttributes($replacements),
    };
}

protected function getDiffAttributes(array $replacements = []): array
{
    return array_merge($this->getDirty(), $replacements);
}

protected function getSnapshotAttributes(array $replacements = []): array
{
    $versionable = $this->getVersionable();
    $dontVersionable = $this->getDontVersionable();

    $attributes = count($versionable) > 0 ? $this->only($versionable) : $this->attributesToArray();

    return Arr::except(array_merge($attributes, $replacements), $dontVersionable);
}
@overtrue
Copy link
Owner

overtrue commented Jul 9, 2024

It seems like a bug, I've fixed it in 059d042

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants