Level 104
What have you tried?
User::selectRaw('DATE_FORMAT(created_at, "%Y-%m-%d"), count(*) as count')
->groupByRaw(DATE_FORMAT(created_at, "%Y-%m-%d"))
->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
How can I group by date and count users? I want someone like this based on created_at
2022-12-09 : 15
2022-12-10 : 18
What have you tried?
User::selectRaw('DATE_FORMAT(created_at, "%Y-%m-%d"), count(*) as count')
->groupByRaw(DATE_FORMAT(created_at, "%Y-%m-%d"))
->get();
Please or to participate in this conversation.