'how to set value to input type="text" in laravel livewire inside "foreach"

I have this code in blade I try to set value of item quantity to input type="text" which inside @foreach ..... @endforeach for updating value each one alone.

@foreach ($Carts as $index => $Cart)
    <input type="text" wire:model="Quantity.{{ $index }}" value="{{ $Cart->items_qty }}"/>
@endforeach

Code in Component

public $BarcodeSearch, $Quantity;

public function render()
{
   return view('livewire.cashier',[
       'Carts' => Cart::all()
   ]);
}

How do I show the value in the fields? "Quantity"

The picture is for clarification



Solution 1:[1]

To display the Quantity of your component you should use : {{ $cashier->Quantity }}

You can't use it like this wire:model="Quantity.{{ $index }}" because this is not how model works.

Model is based on wire:model="PropertyToMonitor" or wire:model="ParentComponent.PropertyToMonitor". See documentation of model here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1