rtconner / laravel-tagging

Tag support for Laravel Eloquent models - Taggable Trait
MIT License
882 stars 168 forks source link

Different Slug than Name #168

Closed JoeyStacks closed 5 years ago

JoeyStacks commented 5 years ago

Hey I'm wondering if there is a way to associate models with existing tags. I'm running into issues tagging models with tag names that don't follow the convention of having a slug thats the "slugified" version of the name. Our company doesn't follow a strict pattern for the relationship between these field. For instance we have a tag with name Violet or Purple but the slug is violet_purple. Its not feasible to alter the slugs at this point and attempting to tag a model with this tag results in a new tag being created ie name => Violet or Purple, slug => violet_or_purple. Any recommendations?

Firtzberg commented 5 years ago

You should be able to override the normalizer in you configuration with a function having the mapping. https://github.com/rtconner/laravel-tagging/blob/laravel-5/src/Model/Tag.php#L45

rtconner commented 5 years ago

Yes, what @Firtzberg said. Modify config/tagging.php to have the normalizer work in whatever fashion is compatible with your current data set.

https://github.com/rtconner/laravel-tagging/blob/laravel-5/config/tagging.php#L9