Users will be able to upload 1 or as many images as they want using multiple image input.
Images table
Columns: id, name, description, user_id, file_name
The home will display the images but not display the accompanying images, they will be displayed on the specific image page. If the user uploads 1 image, there won't be accompanying images.
Home page would be something like this:
@foreach($images as $image)
<a href='{{url("image/".$image->id)}}'>
<img src='{{url("storage/uploads/images/thumbnails/".$image->file_name)}}' alt='Random image'/>
</a>
@endforeach
For simplicity, in the case of multiple images upload the first image in the array will be the main image that will be displayed on home.blade.php
and will be saved in file_name
column in images
table.
On the specific image page, if the image does not have any accompanying images it should only have 1 image like this:
<img src='{{url("storage/uploads/images/specificImages/".$image->file_name)}}' alt='Random image' />
and if it has accompanying images it should display the main image and then the accompanying images.
Now my question is whether I should create a second table and model for the accompanying images or should I add a field in images
table like collection
that will contain an unique value that will be shared between images from same collection?