Hii @johnef_sh I think you can use Laravel's map() to add your custom key for the response like follows,
public function index() {
$poLists = ( new PurchaseOrder() )
->where( 'needed_quantity', '>', 0 )
->where( 'supplier_id', $this->guard()->user()->id )
->get()
->groupBy( function ( $item ) {
return [ $item->created_at->format( 'Y-m-d HH:mm:ss' ) ];
});
//This will create/transform your data
$lists = $poLists->map(function($obj){
$data = [
'date' => $obj
];
return $data;
});
return response()->json( $lists, 200 );
}