php - groupby 的 laravel 会话密钥
问题描述
嗨,我需要会话的 $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 在评论中回答
推荐阅读
- azure - Azure 应用服务错误 HTTP 错误 502.5 - ANCM 进程外启动失败
- css - 在初始加载时隐藏传单角度图
- java - 为什么我在 Selenium 中的同一个 WebElement 上得到不同的结果?
- php - 使用 cron 执行 shell 命令的奇怪 PHP 行为
- javascript - 如何删除 redux-form 中的特定字段值
- postgresql - 分区后插入主表的数据
- excel - 基于具有重复值的另一列合并和居中单元格
- javascript - 类型错误:调用 this.$q.electron.clipboard 时无法读取未定义的属性“剪贴板”
- sas - 如何用数据集中的SAS中的另一行值替换值
- java - 点燃扫描查询问题