You can try flatten() method on a collection you can give depth level as argument flatten(2)
collect($linedata)->groupBy('id')->values()->flatten()->all();