How to get data values from collection using group by on laravel

I want to remove [ ] before data collect

This is the data output

"data": [
        [
            {
                "id": 2,
                "runtime_batch": 24528,
                "smallstoptime_batch": 250,
                "downtime_batch": 200,
            },
            {
                "id": 2,
                "runtime_batch": 2074,
                "smallstoptime_batch": 0,
                "downtime_batch": 1,
            }
        ],
        [
            {
                "id": 3,
                "runtime_batch": 185,
                "smallstoptime_batch": 252,
                "downtime_batch": 1409,
            },
            {
                "id": 3,
                "runtime_batch": 2127,
                "smallstoptime_batch": 377,
                "downtime_batch": 22452,
            }
        ]
    ]

and this is the script using collection

$linedata = GetMyData::select('id', 'runtime_batch', 'smallstoptime_batch', 'downtime_batch', 'output', 'output_final')->get();

foreach($linedata as $ld) {

$ld->runtime_batch = round(($ld->runtime_batch+$ld->smallstoptime_batch)/($ld->runtime_batch+$ld->smallstoptime_batch+$ld->downtime_batch)*100, 2);
$ld->downtime_batch = round($ld->output/$ld->output_final*100, 2);
$ld->smallstoptime_batch = round($ld->output_final/($ld->runtime_batch+$ld->smallstoptime_batch)*100, 2);
}

$groupingline = collect($linedata)->groupBy('id')->values()->all();

I want to group by after, because the data its not result after get and i want to calculate on foreach, after it i want grouping by id. But the result its not i wanted.

get();

Or do you have a another script? its very help me..
Thanks for your help, because i stuck in this script 🙁