lundi 24 juin 2019

How to archive group items in year, month and day

I want to sort orders made by customers in this format:

year|month|day

I have succeeded in sorting it by:

Year|Month

But I am having issues sorting it by year|month|day.

  $periods = orders::onlyTrashed()
                ->get()
                ->groupBy(function($date) {
          return \Carbon\Carbon::parse($date->created_at)->format('Y');
            })
                ->map(function ($item) {
                  return $item
                  ->sortByDesc('created_at')
                  ->groupBy(function($item) {
                    return \Carbon\Carbon::parse($item->created_at)->format('F');

                    });

                });


  return view("order.archieve", compact("periods"));



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire