czim/laravel-filter

Filter & count on multiple levels of categories (many-to-many)

Closed this issue · 1 comments

Hello,
Is this package suitable for filtering (and counting) on multiple levels of categories, for example:

  1. Books (100)
    1. Fiction (50)
    2. Non-fiction (50)
      1. Biographies (10)
      2. Study books (8)
      3. Etc.

Where the third level categories (e.g. biographies) are connected to the products and to the second level categories using pivot tables (many-to-many).

Applying the filters to the query is not the issue, however, counting the products in each category level is making it rather complex. I'm handling these in the countParameter() method as 3 different strategies, but the joins keep having conflicts with each other.

Does this sound familiar?
I hope you can point me in the right direction. Thanks in advance!

czim commented

I'm not familiar with this particular approach, so I don't have examples handy.

I have, however, run into some scenarios where more detailed handling of joins was needed. I did this by keeping track of joined tables and applying joins manually. This package can stay out of the way if you use your own logic, but it doesn't make the problem easier, so good luck!