twill icon indicating copy to clipboard operation
twill copied to clipboard

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

Open zeezo887 opened this issue 1 year ago • 1 comments

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

zeezo887 avatar Nov 01 '24 18:11 zeezo887

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

Tofandel avatar Nov 19 '24 11:11 Tofandel