jeudi 23 août 2018

Laravel sort by keys

I make an array with collections with code:

$hours = Voucher::where('created_at','>=', Carbon::now()->startOfMonth())->get()->groupBy(function($item)
{
  return $item->created_at->format('H');
});

dd($hours);

so I get data like this:

enter image description here

SO keys are hours (00-23).

How I can arrange it starting by 00, 01, 02, 03 ... ...



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire