title: laravel cards data dynamically to 1 modal
body: <p>I have a card that gets data from the database and with a @foreach I'm looping it to create cards every time.</p>
  <pre><code>
  @foreach($cards as $c)
                  &lt;div class=&quot;card_fold&quot;&gt;
                      &lt;button class=&quot;btn btn-danger top-left btn-fab btn-fab-mini btn-round &quot;&gt;
                          &lt;i class=&quot;material-icons&quot;&gt;clear&lt;/i&gt;
                      &lt;/button&gt;
  
                      &lt;button id=&quot;create&quot; class=&quot;btn btn-default top-right btn-fab btn-fab-mini btn-round &quot; data-toggle=&quot;modal&quot;
                          data-target=&quot;#imageModal&quot;&gt;
                          &lt;i class=&quot;material-icons&quot;&gt;create&lt;/i&gt;
                      &lt;/button&gt;
  
                      &lt;div class=&quot;card_fold__image-holder&quot;&gt;
                          &lt;img class=&quot;card_fold__image cover imgHolder&quot; src=&quot;uploads/avatars/{{$c-&gt;img_src}}&quot; alt=&quot;wave&quot; /&gt;
                      &lt;/div&gt;
                      &lt;div class=&quot;card_fold-title&quot;&gt;
                          &lt;a href=&quot;#&quot; class=&quot;toggle-info btn btn-primary&quot;&gt;
                              &lt;span class=&quot;left&quot;&gt;&lt;/span&gt;
                              &lt;span class=&quot;right&quot;&gt;&lt;/span&gt;
                          &lt;/a&gt;
                          &lt;h2&gt;
                              &lt;input type=&quot;hidden&quot; id=&quot;getId&quot; value=&quot;{{$c-&gt;id}}&quot; /&gt;
                              &lt;div id=&quot;nameEnglish&quot;&gt;{{$c-&gt;englishName}}&lt;/div&gt;
                              &lt;div id=&quot;nameAnime&quot;&gt; {{$c-&gt;animeName}}&lt;/div&gt;
                              
                              &lt;small id=&quot;age&quot;&gt;AGE {{$c-&gt;age}}&lt;/small&gt;
                          &lt;/h2&gt;
                      &lt;/div&gt;
                      &lt;div class=&quot;card_fold-flap flap1&quot;&gt;
                          &lt;div class=&quot;card_fold-description&quot; id=&quot;content&quot;&gt;
                              {{$c-&gt;content}}
                          &lt;/div&gt;
                          &lt;div class=&quot;card_fold-flap flap2&quot;&gt;
                              &lt;div class=&quot;card_fold-actions&quot;&gt;
  
                                  &lt;a href=&quot;#&quot; class=&quot;btn btn-primary&quot;&gt;Read more&lt;/a&gt;
                                  &lt;div id=&quot;Large-content&quot; style=&quot;display: none;&quot;&gt;
                                      {{$c-&gt;largeContent}}
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  @endforeach
  
  </code></pre>
  <p>the idea is to have 1 modal connected to all the cards dynamically.</p>
  <pre><code>&lt;div class=&quot;modal fade&quot; id=&quot;imageModal&quot; tabindex=&quot;-1&quot; role=&quot;dialog&quot; aria-labelledby=&quot;exampleModalLabel&quot;
          aria-hidden=&quot;true&quot;&gt;
          &lt;div class=&quot;modal-dialog&quot; role=&quot;document&quot;&gt;
              &lt;div class=&quot;modal-content&quot;&gt;
                  &lt;div class=&quot;modal-header&quot;&gt;
                      &lt;h5 class=&quot;modal-title&quot; id=&quot;exampleModalLabel&quot;&gt;Edit image&lt;/h5&gt;
                      &lt;button type=&quot;button&quot; class=&quot;close&quot; data-dismiss=&quot;modal&quot; aria-label=&quot;Close&quot;&gt;
                          &lt;span aria-hidden=&quot;true&quot;&gt;&amp;times;&lt;/span&gt;
                      &lt;/button&gt;
                  &lt;/div&gt;
                  &lt;form action=&quot;/editor&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&gt;
                      @csrf
                      &lt;div class=&quot;modal-body&quot;&gt;
                          &lt;div class=&quot;card &quot; style=&quot;width: 28rem;&quot;&gt;
                              &lt;img id=&quot;output&quot; src=&quot;uploads/avatars/{{ Auth::user()-&gt;avatar }}&quot; class=&quot;card-img-top &quot;
                                  style=&quot;max-height: 28rem; object-fit: cover;&quot; rel=&quot;nofollow&quot;&gt;
                              &lt;div class=&quot;card-body&quot;&gt;
                                  &lt;label for=&quot;avatar&quot; class=&quot; btn btn-primary&quot; style=&quot;min-width: 100%;&quot;&gt;
                                      Select a file
                                  &lt;/label&gt;
                                  &lt;input name=&quot;avatar&quot; id=&quot;avatar&quot; type=&quot;file&quot; onchange=&quot;loadImg(event)&quot; /&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
  
                          &lt;div class=&quot;form-group&quot;&gt;
                                  &lt;label for=&quot;modal-input-english-name&quot;&gt;English Name&lt;/label&gt;
                                  &lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;modal-input-english-name&quot; placeholder=&quot;...&quot;&gt;
                              &lt;/div&gt;
  
                              &lt;div class=&quot;form-group&quot;&gt;
                                  &lt;label for=&quot;modal-input-anime-name&quot;&gt;Anime Name&lt;/label&gt;
                                  &lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;modal-input-anime-name&quot; placeholder=&quot;...&quot;&gt;
                              &lt;/div&gt;
  
                              &lt;div class=&quot;form-group&quot;&gt;
                                  &lt;label for=&quot;modal-input-age&quot;&gt;Charachter Age&lt;/label&gt;
                                  &lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;modal-input-age&quot; placeholder=&quot;...&quot;&gt;
                              &lt;/div&gt;
  
                              &lt;div class=&quot;form-group&quot;&gt;
                                  &lt;label for=&quot;exampleFormControlInput1&quot;&gt;Content&lt;/label&gt;
                                  &lt;textarea class=&quot;form-control&quot; id=&quot;modal-input-content&quot; rows=&quot;2&quot;&gt;&lt;/textarea&gt;
                              &lt;/div&gt;
  
                              &lt;div class=&quot;form-group&quot;&gt;
                                  &lt;label for=&quot;exampleFormControlTextarea1&quot;&gt;Read More Content&lt;/label&gt;
                                  &lt;textarea class=&quot;form-control&quot; id=&quot;modal-input-large-content&quot; rows=&quot;3&quot;&gt;&lt;/textarea&gt;
                              &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class=&quot;modal-footer&quot;&gt;
                          &lt;button type=&quot;button&quot; class=&quot;btn btn-secondary&quot; data-dismiss=&quot;modal&quot;&gt;Close&lt;/button&gt;
                          &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary&quot;&gt;Save changes&lt;/button&gt;
                      &lt;/div&gt;
  
                      
                  &lt;/form&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  <p>Right now all the id's are the same and I'm trying to figure out a way to distinguish the cards from each other. This is the jquery I'm using right now which only works for the first cards since they all have the same id. in some way I need to dynamically add something so I can distinguish between what data to get.</p>
  <pre><code>$('#imageModal').on('shown.bs.modal', function() { 
              
              var img_src = $(&quot;.card_fold__image-holder&quot;).find(&quot;img&quot;).attr(&quot;src&quot;);
              var nameEnglish = document.getElementById(&quot;nameEnglish&quot;);
              var nameAnime = document.getElementById(&quot;nameAnime&quot;);
              var age = document.getElementById(&quot;age&quot;);
              var content = document.getElementById(&quot;content&quot;);
              var largeContent = document.getElementById(&quot;Large-content&quot;);
              
              $(&quot;#modal-input-english-name&quot;).val(nameEnglish.innerHTML );
              $(&quot;#modal-input-anime-name&quot;).val(nameAnime.innerHTML );
              $(&quot;#modal-input-age&quot;).val(age.innerHTML );
              $(&quot;#modal-input-content&quot;).val(content.innerHTML );
              $(&quot;#modal-input-large-content&quot;).val(largeContent.innerHTML );
              $(&quot;#output&quot;).attr(&quot;src&quot;, img_src);
          });
  </code></pre>