DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for Laravel 9 - Use groupBy on Collections
Sandro Jhuliano Cagara
Sandro Jhuliano Cagara

Posted on

Laravel 9 - Use groupBy on Collections

If you want to group result by some condition which isn’t a direct column in your database, you can do that by providing a closure function.

$users = User::all()->groupBy(function($item) {
    return $item->created_at->format('Y-M-D');
});
Enter fullscreen mode Exit fullscreen mode

Oldest comments (0)

An Animated Guide to Node.js Event Lop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.