Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Laravel groupby date of created_at

StockHistory::query()
                ->where('cost_center_id',$cost_center_id)
                ->where('material_id',$material_id)
                ->get()
                ->groupBy(function($item)
                {
                        return $item->created_at->format('Y-m-d');

                })->map(function($item, $key){
                    return $item->sum('quantity');
                });
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Laravel #groupby #date
ADD COMMENT
Topic
Name
7+9 =