Answer the question
In order to leave comments, you need to log in
Is there a way to group (groupBy) users by registration dates?
An example of grouping by user status in Laravel. And how to group users by registration date - for example, January February March, etc.?
$users = DB::table('users')
->select(DB::raw('count(*) as user_count, status'))
->where('status', '<>', 1)
->groupBy('status')
->get();
Answer the question
In order to leave comments, you need to log in
Try like this -
$users = DB::table('users')
->select(DB::raw('count(*) as user_count, status'))
->where('status', '<>', 1)
->groupBy(function($user) {
return Carbon::parse($user->created_at)->format('m');
})->get();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question