I need a querybuilder query that calculates how many different people the user is messaging without counting the repetitive data.
Example:
conver_user_id = 165, conver_user_seller_id = 156
conver_user_id = 165, conver_user_seller_id = 156
conver_user_id = 165, conver_user_seller_id = 156
conver_user_id = 165, conver_user_seller_id = 158
conver_user_id = 165, conver_user_seller_id = 158
the result i want : Total count: 2
I will be glad if you help me thank you
2
Answers
Assuming you have the user when the query is executed, as you ask "the user is messaging". Using group by, to select the unique conversations, then counting it.
You can use the
distinct
method on the query builder to achieve the desired result.