0
How would be a way to minimize this image insertion code in the database?
// controller/GaleriasController.php
public function addGaleria {
$galeria = new Galeria;
$galeria->descricao = "galeria 1";
$galeria->img1 = Input::file('img1');
$name = Input::file('img1')->getClientOriginalName();
Input::file('img1')->move('/arquivos', $name);
$galeria->img2 = Input::file('img2');
$name = Input::file('img2')->getClientOriginalName();
Input::file('img2')->move('/arquivos', $name);
$galeria->img3 = Input::file('img3');
$name = Input::file('img3')->getClientOriginalName();
Input::file('img3')->move('/arquivos', $name);
$galeria->save();
}
You are saving the image in the database and directory correctly, only if I had 10 tables with 10 image fields each...
I already tried to create an insertion array only I could not :(
are you saving images in the database, or just the image description? Store images in the database in general, is not a good option
– Emerson Rocha
i saved the image in the directory and the name of the image in the bd, to even thinking of renaming the images with the temporary name that the Laravel creates to avoid images with the same name...
– henrique
"Improvement" sounds better than "Improvement". I think.
– user622