laravel - php how to group data in table by days

one text

Solution:

Once you get the data then use groupBy() on the collection you get.

Example:

The groupBy method groups the collection's items by a given key:

$collection = collect([
   ['account_id' => 'account-x10', 'product' => 'Chair'],
   ['account_id' => 'account-x10', 'product' => 'Bookcase'],
   ['account_id' => 'account-x11', 'product' => 'Desk'],
]);

$grouped = $collection->groupBy('account_id');

$grouped->toArray();

/*
     [
        'account-x10' => [
            ['account_id' => 'account-x10', 'product' => 'Chair'],
            ['account_id' => 'account-x10', 'product' => 'Bookcase'],
        ],
        'account-x11' => [
            ['account_id' => 'account-x11', 'product' => 'Desk'],
        ],
     ]
 */

Source