title: laravel livewire files always gets uploaded in the last item of an array
body: <p>I am trying to build a facebook clone on livewire, and i wanted to assign each comment section its own model so that's why i created an empty array in my class,</p>
  <pre><code>public $new_comments = array();
  </code></pre>
  <p>then for each post i tried to assign to its comment section 2 models (one for the comment body and the second one for the picture) based on the post id</p>
  <pre><code>&lt;form class=&quot;form-group&quot; wire:submit.prevent=&quot;test&quot;&gt;
     &lt;input name=&quot;message&quot; required class=&quot;form-control&quot; placeholder=&quot;Write a comment...&quot; wire:model=&quot;new_comments.{{ $post-&gt;id }}.body&quot;&gt;&lt;/input&gt;
     &lt;label for=&quot;comment_image&quot; style=&quot;cursor: pointer&quot;&gt;&lt;i class=&quot;flaticon-photo-camera&quot;&gt;&lt;/i&gt;&lt;/label&gt;
     &lt;input type=&quot;submit&quot;&gt;&lt;/input&gt;
     &lt;input id=&quot;comment_image&quot; type=&quot;file&quot; wire:model=&quot;new_comments.{{ $post-&gt;id }}.image&quot; class=&quot;d-none&quot; accept=&quot;image/png, image/gif, image/jpeg&quot;&gt;
  &lt;/form&gt;
  @if ($new_comments[$post-&gt;id]['image'] ?? false)
     &lt;div class=&quot;d-flex justify-content-center&quot;&gt;
        &lt;img src=&quot;{{ $new_comments[$post-&gt;id]['image']-&gt;temporaryUrl() }}&quot; class=&quot;w-50&quot;&gt;
     &lt;/div&gt;
  @endif
  </code></pre>
  <p>but when i try uploading an image in the post number 1 for example, it always gets added in the last item of the array and i don't know why!</p>
  <p><a href="https://i.stack.imgur.com/Poqin.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Poqin.png" alt="enter image description here" /></a></p>
  <p>in this case i uploaded the image in the first post but magically its in the last item of the array</p>
  <p>(you can notice that the other model is working perfectly fine!)</p>
  <p>Can anyone help me with this problem? Thank you.</p>