If you want array then use this
$outings = Outing::all()->groupBy(function ($item) {
return Carbon::parse($item['start'])->format('m/d/Y');
})->map(function($item){
return $item->all();
});
return response()->json($outings, 200);
If you want date as key then
$outings = Outing::all()->groupBy(function ($item) {
return Carbon::parse($item['start'])->format('m/d/Y');
});
return response()->json($outings->toArray(), 200);
Top comments (0)