Learn yii2, faced with the task of uploading photos for products.
There are 2 tables(exaggerated):
`product` - id | name (ID and name of commodity)
`product_photo` - id | product_id | image of the entry(ID, item ID, link to image)
The question is how to add the uploaded photos to the product? Idea so far:
In the model of the product Product.php add a property $images. In the derivation of the model of the goods (or edit in the admin) - to display an additional input for multiple download:
<?= $form--->field($model, 'images')->fileInput(['multiple' => true, 'accept' => 'image/*']) ?>
When sending, the model of the product, use to connect the ProductPhoto model. And while processing these files, add a record in DB using this model.
That's right, I think? Or is there a more elegant solution?