Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

fredbsc's avatar
Level 15

Some complex filtering

Hi All! First of all, please excuse my poor english. I’m looking for a clean way to filter down some socio demographic data with dozends (or maybe hundreds) of filter criteria (input boxes, multiple selects, select boxes, radio buttons, etc).

For some easy example:

Users gender (all/f/m), etc age by groups (up to 19, 20 to 29, 30 …, and some predefined groups like 49+, 18+), etc … dozends of them.

AND a little bit more complex:

“user has mail” (where we have a model called contact_type with user_id, contact type, contact_data: user_id:2; cantact_type:email; contact_data: mbłex.org / user_id:2; contact_type: mobile; contact_data: +43983796 / and so on)

or

“user has mobile” and “mobile number starts with +43” (austria)

AND a little bit more complex:

user has cable tv (where user can be member of more than one household and each household can have multiple methods to receive tv signal)

I know how to query each of this examples via eloquent. But how do I combine maybe hundreds of this queries?

Finaly I ask for, maybe:

Adults 39 years plus, living in Vienna, New York or Milan, with cable tv and email. Femal 49+ OR Male 39+, living in austria, switzerland, germany and has email

I tried severals ideas but it allways gets messy very quick. What is a clean way to solve this?

Thanks for any help ond/or ideas?

fred

0 likes
2 replies
fredbsc's avatar
Level 15

Thanks a lot! I know this video and I tinkerd around before. But what about:

xyz.com/?gender=female&age=20-29&age=30-39&age=40-49&HHCity=vienna

where female and age are in table ext_user which has relation to user and I can find HHCity via table hosehold (many2many whith user) and household_adress (many2many with household).

  • when & where to eagerload and/or join the tables (only if needed)
  • multiple choices on age? eagerload only the first time …

You know what I mean with “getting messy very quick”? Thanks for any ideas! fred

Please or to participate in this conversation.