From blade component I can give valule product_id
<input wire:model="qty.{{$row->product_id}}" value="{{$row->qty}}" max="{{$row->stock}}">
but how I can display qty from database and when increase qty then wire model will work and updated, what I can should do???
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');
}
}
}
}