嗨,我需要会话的$clave,因为我可以删除它会话。我该怎么做?谢谢
$carrito=Session::get('cart');
$grouped = Session::get('cart')->groupBy('vendedor');
foreach($carrito as $clave => $carro) {
echo $clave ; //I need to put these keys in the <a> to be able to delete the session of that item because when applying groupby it does not give me the session key.
}
@foreach($grouped as $id => $value)
@foreach($value as $key => $cartItem)
<a href="#" onclick="removeFromCartView(event, {{ $clave}})" class="text-right pl-4"><i class="la la-trash"></i></a>
@endforeach
@endforeach
我用->groupBy('vendedor', $preserveKeys = true)
解决了它
在评论中由@Carlos回答