Jordan-Bianco / Ecommerce

Ecommerce built using Laravel 9, Vue 3 and Inertia.js
11 stars 3 forks source link

I can't see the images... Help! #1

Open drfcozapata opened 1 year ago

drfcozapata commented 1 year ago

Hi Jordan!

Bro, I need your help if possible. I'm not very skilled yet in Laravel as I would like and I'm learning Inertia as well.... I want to use your ir ecommerce to learn how to do the integration with Mercado Pago as a payment gateway, but I'm not progressing because the info is not showing up.

I cloned your repo, updated dependencies, etc. Everything works perfect except for the images, which I can't get them to display. If I remove the html from the images, everything else is displayed; when I put it in, it just shows a blank page.

I generated a base of 12 products and the product information displays fine, but I can't for the life of me get the image information to load correctly in the table.

Could you give me a linear example of what to put in imageable_type (I assumed and put jpg), imageable_id (I put numbers from 1 to 12, url (it is supposed to be the name of the image; for example: boots1.jpg) and is_preview (no idea what can go here; I also put images from 1 to 12). I did not put any of the string values in quotes.

image

I would really appreciate your help.

OliveLeb commented 8 months ago

Hello, I don't know if you figured it out since it's been 3 month now. imageable_type here do not refer to the image itself but to the model which the image is link on. It is called a polymorphic relationship
This way you can link your images to différents type of model $product->image()->save($image)
Here the imageable_type would be App\Models\Product and imageable_id, the id of the product.

is_preview is a boolean either 1 or 0 assuming you are using something like mysql. Quickly looking at the code shows us that we have to set to 1 (true) for the image to be displayed. And make sure you put your images in the right place