How would one 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, but if I had 10 tables with 10 image fields each ...
I've tried to create an insert array only that I could not: (