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

retrieve slug from slugs table if the $slugAttribute field was not changed #2688

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from

Conversation

zeezo887
Copy link
Collaborator

@zeezo887 zeezo887 commented Nov 1, 2024

Description

The changes made here was to use the previous slug value if the $slugAttribute field was not changed. By doing this, we won't have duplicate slug entries when a model is not updated via the repository.

/**
 * Returns changed value of slugAttribute field or previous slug value
 */
private function getSlugValue($slugAttribute, $locale): mixed
{
    return $this->wasChanged($slugAttribute)
        ? $this->$slugAttribute
        : $this->slugs()->where('locale', $locale)
            ->where('active', true)->value('slug');
}

Related Issues

Fixes #2681

@Tofandel
Copy link
Contributor

Tofandel commented Nov 19, 2024

Is the disableLocaleSlug even needed before? This seems to be done already in updateOrNewSlug and I'm sure it's interfering with getOldSlug->active

*/
private function getSlugValue($slugAttribute, $locale): mixed
{
return $this->wasChanged($slugAttribute)
Copy link
Contributor

@Tofandel Tofandel Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix doesn't work for slugs from translations, because then translations are never detected as changed and it will return the slug before change

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

Successfully merging this pull request may close these issues.

All module slugs get reset on reorder.
2 participants