Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What filters do you use? #63

Open
renky opened this issue Feb 12, 2024 · 6 comments
Open

What filters do you use? #63

renky opened this issue Feb 12, 2024 · 6 comments

Comments

@renky
Copy link
Contributor

renky commented Feb 12, 2024

Hi everybody

I'd like to collect some ideas about new filters. It would be very interesting how you all use the filters and what individual filters you create, and if it makes sense to add them as new Filter types or even as a default filter...

Waiting for your feedback.

@mrABR
Copy link

mrABR commented Feb 22, 2024

Not exactly a filter but I currently have the need to do a %LIKE% search word by word (I'm overriding the current behaviour to do this) but this would be a great feature IMO, since the search is used to lookup on several properties. Could have some options, such as "strict" like where it would search "%something like this%" or a "loose" one where it would search "%something%" "%like%" "%this%"

Just a thought! Package looks good as it is

@renky
Copy link
Contributor Author

renky commented Feb 23, 2024

Thats a very interesting idea - the only thing I wonder: is this still filtering? or is it searching? I think filtering should be fast and performant, able to work with indexes...
Maybe your idea is something for the SearchMode - there could be an additional Mode, where it does exactly yours (currently the search is only able to look for ends-with, starts with, equal and contains... but always the full word...

I could imagine some extensions:

  1. Search Mode "loose contains" (name must be found) - where it does what you wrote: "%something%" "%like%" "%this%"
  2. Search Mode Fulltext - where it uses the mysql fulltext-search - not like but with match against - this could be much more performant than the other solution... but case 1 is still valid for small databases without option of fulltext-search.

Finally what could also be an improvement: currently the search is running against all searchable fields... maybe it could be possible to set the fields with the scope - something like: yeah, title, description and name are searchable, but this time I only want to search in title... and even more: i want to search in title for x and in description for y - x shall be in like-mode, y in fulltext-search mode...

This is kind of filtering, but naming is better, since it really searches...

would this solve your usecase? I already have an own usecase for it... currently in my software I only offer one single search-field... it could be possible to add a input-search-field to each column of the table... with that solution...

@mrABR
Copy link

mrABR commented Mar 1, 2024

I think it's more of a searching than filtering, you're right. In my head it's hard to make that distinction sometimes.

I think the use cases that you wrote explain it better than I ever would! I like the idea, specially the limitation ofsearching through some of searchable fields.

It would fit my use case for sure! I don't often use packages but I was setting up a pet project with your package and recently found the need to evolve it into something a little bigger ehehe.

I've got a shitty availability outside working hours but If you want I can maybe open a PR with a draft of it whenever I have the time

@Akhmami
Copy link

Akhmami commented Apr 20, 2024

What about the model relation filter? does this package support it? i want to use it but not sure about it.

@renky
Copy link
Contributor Author

renky commented Apr 21, 2024

@Akhmami it depends on the relation - since v2 I integrated a belongsTo and belongsToMany Filter that makes it more convenient to work with Standard-Situations, where you have a relation with e.G. a title-Column, that shall be shown in a select-input - see more here:
https://www.lacodix.de/docs/laravel-model-filter/v2/filter-types/belongs_to
https://www.lacodix.de/docs/laravel-model-filter/v2/filter-types/belongs_to_many

Is this what you need?

@renky
Copy link
Contributor Author

renky commented Jun 17, 2024

@mrABR I just introduced v3 of the package that will introduce new Search-Modes that exactly fit your idea
All searchmodes:

    case EQUAL;
    case LIKE;
    case LIKE_CASE_SENSITIVE;
    case STARTS_WITH;
    case STARTS_WITH_CASE_SENSITIVE;
    case ENDS_WITH;
    case ENDS_WITH_CASE_SENSITIVE;
    case CONTAINS_ANY;
    case CONTAINS_ANY_CASE_SENSITIVE;
    case CONTAINS_ALL;
    case CONTAINS_ALL_CASE_SENSITIVE;

For your need you can use the Contains modes - either any or all depending on your needs.

I had to introduce a v3 due to breaking changes. See upgrade-docs for more information:
https://www.lacodix.de/docs/laravel-model-filter/v3/upgrade

For most people it will be a drop-in-replacement, but if anybody has overwritten the filters() or searchable() methods on the traits, it will break now... and additionally the search-case-sensitivity might have changed, because until v2 it depended on the used database-engine (Postgres was always sensitive, mysql almost not, ans sqlite never).

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

No branches or pull requests

3 participants