Greetings!
I'm studying Laravel 5.4 to create an online store.
At the moment, my first app is an online store.
The product should have a photo gallery.
Photos are uploaded to the specified folder.
Question:
How to save file names in the database in one column?
Thank you in advance!
Form
<div class="form-group">
<label for="imageInput">File input</label>
<input required="" data-preview="#preview" name="input_img[]" type="file" id="imageInput" multiple>
</div>
Controller:
$paths = [];
foreach($request->input_img as $imag) {
$image = $imag->getClientOriginalName();
$actual_name = pathinfo($image,PATHINFO_FILENAME);
$original_name = $actual_name;
$extension = pathinfo($image, PATHINFO_EXTENSION);
$i = 1;
while(file_exists('images/products/'.$actual_name.".".$extension))
{
$actual_name = (string)$original_name.$i;
$image = $actual_name.".".$extension;
$i++;
}
$imag->move(Config::get('app.upload_path') . 'images/products', $image);
$dir=public_path('images/products/thumbnails/');
if( ! \File::isDirectory($dir) ) {
\File::makeDirectory($dir, 493, true);
}
}
$product->image = $paths;
$product->save();
Error
(1/1) ErrorException
Array to string conversion
in AdminProductController.php line 95
at HandleExceptions->handleError(8, 'Array to string conversion