cviebrock / eloquent-taggable

Easily add the ability to tag your Eloquent models in Laravel.
MIT License
537 stars 72 forks source link

Search #69

Closed pierrocknroll closed 5 years ago

pierrocknroll commented 6 years ago

Hello,

I'm wondering how to implement with efficienty a functionality to search through tags for an autocomplete field. For exemple localhost/tags?query=lorem searches all tags who start by lorem

I haven't seen such a thing in your readme.

Thanks !

cviebrock commented 6 years ago

Wouldn’t something like Tags::whereLike(‘name’, ‘lorem%’)->get() work?

On Jan 29, 2018, at 10:25 AM, pierrocknroll notifications@github.com wrote:

Hello,

I'm wondering how to implement with efficienty a functionality to search through tags for an autocomplete field. For exemple localhost/tags?query=lorem searches all tags who starts by lorem

I haven't seen such a thing in your readme.

Thanks !

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

pierrocknroll commented 6 years ago

Yeah, of course ! I rather thought about implemeting it with Scout. Or something like Model::allTags()->search('lorem') because I need to search through tags of a specific model

pierrocknroll commented 6 years ago

I try to do something like : Model::allTagModels()->where('name', 'LIKE', 'lorem%').

But your methods always return a Collection (with Tag::fromQuery($sql)). Is it possible to have a method who returns a QueryBuilder ? Or another way to add SQL to your queries.

I only need to search through tags of a specific model

Thanks

cviebrock commented 6 years ago

Yeah, it's not ideal, I agree. This package needs a bit of attention and probably a bit of a rewrite.

SaphiLC commented 5 years ago

any news on this?

cviebrock commented 5 years ago

No news on this. I'd have a lot of backwards-compatibility issues returning a QueryBuilder instead of a Collection, were I to change that without a major version change.

I've marked this ticket as enhancement so that when I do get around to rewriting it, I will keep this in mind.