【发布时间】:2021-09-14 02:53:29
【问题描述】:
我可以从刀片组件中给出有价值的 product_id
<input wire:model="qty.{{$row->product_id}}" value="{{$row->qty}}" max="{{$row->stock}}">
但是我如何从数据库中显示数量,当增加数量时,线模型将工作并更新,我该怎么办???
public $qty;
public function render()
{
$this->userId=Auth::id();
if ($this->qty!=null){
foreach($this->qty as $key => $qty)
{
$cart=Cart::where('user_id',$this->userId)->where('product_id',$key)->first();
if ($cart){
$cart->update([
'qty' => $qty,
]);
$this->emit('refreshCart');
}
}
}
}
【问题讨论】: