Array list - key to identify the exact element in the html

I have a list where I show the values as follows:

 > <a href="#" wire:click="edit({{ $idTariff }})" data-toggle="modal" data-target="#tarifarioModal">
>             <span class="badge badge-warning" wire:model="tariffPrice.{{ $idTariff }}">{{ $tariffPrice }}</span>
>         </a>

When I update a single list value, the entire list is updated. How to use a key to identify the exact element in the html?

In my controller class I have the following:

class TariffGeneral extends Component
{

public $idTariff;
public $tariffPrice;

public function newPrice($newPrice): void
{
    $this->tariffPrice.$this->idTariff = $newPrice;  --->> ????? How to do something like that ??
}

}

Use your model for that.

public function newPrice($newPrice): void
{
   $model = Tariff::find(idTariff );
   $model->tariffPrice = $newPrice;
   $model->save();
}

then in blade use foreach to list and:

@foreach($list as $item)
<a href="#" wire:click="edit({{ $item->idTariff }})" data-toggle="modal" data-target="#tarifarioModal">
      <span class="badge badge-warning">{{ $item->tariffPrice }}</span>
</a>
@endforeach

but I’m a little confuse about what you’re trying to do in link click

Hello my friend. Thank you so much for always helping. The problem was not so simple, it is difficult to explain here, especially with my horrible English. But I managed to solve it. Thanks!

I’m glad to hear that. By my side I’m able to help you…incluso si tienes que hacerlo en Español que es mi lengua materna hermano jejejeje. Saludos desde Cuba

1 Like