Laravel 拣选清单的简单电子商务逻辑

Laravel simple ecommerce logic for picking list

我正在努力创建一个简单的逻辑..我有订单集合......有些订单中有相同的产品..但数量不同..我想创建这些订单的拣货清单.. 例如..

我当前的代码:

@php
$x = $allorders->pluck('SKU')->all();
@endphp
@foreach ($x as $z)
    @foreach ($allorders->where('SKU', $z)->pluck('quantity_ordered') as $grouporder)
        {{$z}} : {{$grouporder}} <br>
    @endforeach
@endforeach

输出是这样的:

相反,我该如何显示它: 所以我的选择清单会显示:

select SKU, sum(quantity_ordered), min(title) from product_details group by SKU

这对我有用..谢谢 :)