I am new in using Livewire for my cart in my e-commerce Laravel 7 project. I want to show the product image of each item in the cart. I have @foreach ($cartItems as $item) on my table data. When I try this code
<img src="{{asset('storage/'.$item->cover_img)}}">
to try to show the images saved to my storage path, I get an error like the image above. But when I try:
<img src="{{asset('storage/'.$item['cover_img'])}}">
I'm getting an ErrorException Undefined index: cover_img. All the other $item is working and getting the needed data except the image. On my other blades without livewire <img src="{{asset('storage/'.$item->cover_img)}}> works fine.
How do I do this properly in livewire? Any advice would be appreciated. Thanks in advance!
When I do a {{dd($item)}}, this is what I get:

This solved my problem:
<img src="{{ asset('storage/'.$item['associatedModel']['cover_img']) }} " />
Thanks!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With