Remove quotes.
<a href="#" class="qty-up" wire:click="increment({{ $item['product_id'] }},{{ $item }})">
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi All,
I have a livewire component for my cart functionality. In that I have to pass an array as second parameter to increment function. how can I achieve that?
Cart component
class Cart extends Component
{
public $cart;
public $item;
public function mount(array $item): void
{
$this->cart = CartFacade::get();
$this->item = $item;
}
public function render()
{
return view('livewire.cart');
}
public function increment(int $productId, array $item)
{
.....
}
}
cart blade
<tr class="cart_item">
....
<td class="product-quantity" data-title="Quantity">
<div class="detail-qty info-qty border radius6 text-center">
....
<span class="qty-val">{{ $item['cart_count'] }}</span>
<a href="#" class="qty-up" wire:click="increment({{ $item['product_id'] }},'{{ $item }}')"><i
class="fa fa-angle-up" aria-hidden="true"></i></a>
</div>
</td>
....
</tr>
This is my code. It returning an error htmlspecialchars() because of the second parameter is an array.
you need to examine the structure of $item, not pointlessly sending it from the view
Please or to participate in this conversation.