I'm sorry to be a bother but I'm in this crap all day in a simple thing and I'm failing to see why. I'm trying to make a loop to insert in the database multiple data images. If you want to insert an image is working everything right but if I want to insert two or three it inserts only one. To insert two or three with the same table ID related I need to loop the problem I do a return $ C to count the number of images and it returns me always 1. Ando here back to back and this will always give the same. I have something wrong?
$c = count($request->file('image'));
$fileName = $request->file('image');
for ( $i=0; $i< $c; ++$i) {
$imagensportfolio = new ImagensPortfolio();
$file = array_get($imgportfolio,'image');
$destinationPath = 'image/portfolio/';
$extension = $request->file('image')->getClientOriginalExtension();
$fileName = rand(1111,9999) . '.' . $extension;
$imagensportfolio->image= $fileName[$i];
return $c;
Image::make($file)->resize(700, 400)->save($destinationPath.$fileName);
$portfolio->save();
$imagensportfolio->Portfolio()->associate($portfolio);
$imagensportfolio->save();
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire