Laravel 5.2 - Can't Update Multiple Images, Undefined offset: 0
<p>I'm trying to update the table field with multiple images form inside. The create form it's work fine, but the problem is when I'm trying to update it.</p>

<p>So here the controller of the update function:</p>

<pre><code> public function update(Request $request, $id)
{
    $update = new Product($request-&gt;all());
    $product=Product::find($id);

    $picture = ''; 
    $images = [];
    if ($request-&gt;hasFile('images')) {
    $files = $request-&gt;file('images');
    foreach($files as $file){
    $filename = $file-&gt;getClientOriginalName();
    $extension = $file-&gt;getClientOriginalExtension();
    $picture = date('His').$filename;
    $destinationPath = base_path() . '\public\images/';
    $file-&gt;move($destinationPath, $picture);
    $images[]=$picture;
    }
    }

    if (!empty($product['images'])) {
    $product['images'] = $images[0];
    $product['images2'] = $images[1];
    $product['images3'] = $images[2];
    $product['images4'] = $images[3];
    } else {
    unset($product['images']);
    }

    $product-&gt;update($update);
    return redirect('product');
}
</code></pre>

<p>If it's not clear enough, you can see the full ProductController on <a href="https://codeshare.io/dVBuZ" rel="nofollow noreferrer">codeshare.io</a></p>

<p>And the update form is <a href="https://codeshare.io/puPED" rel="nofollow noreferrer">codeshare.io</a>
As you can see, I'm using array to insert the image to database and the array has been defined on <code>$product['images4'] = $images[3];</code> </p>

<p>This is where the picture was placed.
<a href="https://i.stack.imgur.com/pXMvD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pXMvD.jpg" alt="This is where the picture was placed."></a></p>

<p>But it gave me error:</p>

<pre><code>ErrorException in ProductController.php line 149: Undefined offset: 0
</code></pre>

<p>Can you suggest a better code or explain me about the error? Thanks a lot ;)
Have a nice day.</p>