rtconner / laravel-tagging

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

Duplicated models #198

Closed Famaxis closed 3 years ago

Famaxis commented 3 years ago

Thanks for the package, it's simple and useful. And I have a question. When I need only five tags, there are appear ten models.

89867

As said in documentation, I use Post::with('tagged'), and here is blade file:

@foreach($resource->tagged as $tagged)
            <a class="paper-btn btn-small"
                   href="{{ route('front.posts.fetch', $tagged->tag_slug) }}">{{ $tagged->tag_name }}
            </a>
@endforeach

When I changed tagged to tags, there was no difference. Did I do something wrong, or is it meant to work that way?

rtconner commented 3 years ago

Sticking with just ->tagged will be faster. Probably avoid directly using the tag object (unless you need it) as it does an extra query. Is really there to force uniqueness on the tag strings.

rtconner commented 3 years ago

Hrm, I should probably update docs to suggest "tagged" though.