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

gowthamdeena's avatar

Unique row count based on the group by conditaion

Hi,

In my table name like visitor_count. here I store all visited user details. The table column likes user_ip, date, page, host. And finally, I want how many unique users visit on my website based on the IP address.

By getting a value in laravel query builder

0 likes
1 reply
manelgavalda's avatar

You can do it like this, for example:

DB::table('visitor_count')->get()->groupBy('user_ip')->count()

Please or to participate in this conversation.