I am trying to multiple images insert with Laravel 5.1 using one controller method.
Here is my tried Code:
$images = Input::file('product_images');
foreach ($images as $image) {
$productImage = new ProductImage();
$filename = Input::get('imalatci_id') . '_product' . '_' . date('Y_m_d_H_i_s') . '_' . $image->getClientOriginalName();
Image::make($image->getRealPath())->resize(500, 400)->save('images/products/' . $filename);
$productImage->product_id = $productId;
$productImage->path = 'images/products/' . $filename;
$productImage->save();
}
This code inserts single row to table.
How could gain multiple inserting?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire