Skip to content

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