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

syedhasy's avatar

version

hey i need to get the count of users based on the latest version of application for example i am having 4.2.1 and 4.3.1 one user is updated from 4.2.1 to 4.3.1 so that user count will not list the count of 4.2.1 any suggestion?

0 likes
11 replies
Sinnbeck's avatar

Do you mean just the count of those and nothing else?

$userCount = User::where('app_version', '4.3.1')->count();
syedhasy's avatar

@Sinnbeck for example the output will be 4.1.1 = 1000 4.2.1 = 2000 4.3.1 = 3000 here if one user is updated from 4.1.1 to 4.2.1 to 4.3.1 means the user count only list on 4.3.1 not on other below version

Sinnbeck's avatar

@syedhasy ok

$users = User::query() 
    ->selectRaw('COUNT(*) as num_users, version')
    ->groupBy('version')
    ->get();
 
1 like
Tray2's avatar

@syedhasy How are we supposed to help you when you don't show any code at all, and we have no clue what your database look like?

Sinnbeck's avatar

@syedhasy the chances of Jeffrey answering your questions are very slim. He is way too busy making content for the site :)

1 like

Please or to participate in this conversation.