Answer the question
In order to leave comments, you need to log in
How to add multiple pictures to a post?
Can you please tell me how can I attach several pictures to the news? What will be the structure of the database? And how is it generally better to implement an admin panel so that the user can easily choose photos from himself and immediately upload them to the news? What tools can...
Answer the question
In order to leave comments, you need to log in
Good afternoon.
I would make a separate table for images, separately for news and a link table where the id of the news and images will be stored.
How to upload multiple files you will find here
This article will also help you.
ps Working with linked data
HasMany for news and hasOne for pictures:
News table:
id
name
text
.....
Images table:
id
filename
news_id
.....
In pursuit of slo_nik and Andrey , I can give 1 more option, store them in json in one cell in the news table. In general, this is not very correct, but if the number of pictures for the news is somehow limited and there cannot be a dozen, a hundred, etc. That might be a viable method.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question