this is my class:
public $products, $product;
public function getData($id)
{
$this->product = Product::find($id);
}
public function render()
{
$this->products = Product::latest()->get();
return view('livewire.cabin');
}
and this is my livewire cabin view:
<section >
<div>afetr click on ech image: {{ $product->code }}</div>
<div class="slideCabin">
@foreach($products as $product)
<div>
<a wire:click="getData({{ $product->id }})">
<img class="slideCabin-img" src="/images/allproducts/{{ $product->cover }}" >
</a>
</div>
@endforeach
</div>
</section>
why after clicking each image I can’t see each product property as {{ $product->code}}