title: update data dynamically using Modal in laravel
body: <p>Tomorrow I am presenting my code in sprint. Everything was working fine until a few hours ago. I have a modal which pops up when a user clicks on Edit. It <em>was</em> giving the values according to <code>id</code>.</p>
  
  <pre><code>&lt;div class="modal fade" id="myModal" role="dialog"&gt;
      &lt;div class="modal-dialog"&gt;
          &lt;!-- Modal content--&gt;
          &lt;div class="modal-content"&gt;
              &lt;div class="modal-header"&gt;
                  &lt;button type="button" class="close" data-dismiss="modal"&gt;&amp;times;&lt;/button&gt;
                  @foreach($Community as $editCommunity)
                  &lt;h4 class="modal-title"&gt;Edit: {!! $editCommunity-&gt;community_name !!}&lt;/h4&gt;
              &lt;/div&gt;
              &lt;div class="modal-body"&gt;
                  &lt;form class="form-group" action="/update/{{$editCommunity-&gt;id}}" method="post" id="editCommunityForm"&gt;
                      &lt;input type="hidden" name="_token" value="{{ csrf_token() }}"&gt;
                      &lt;input type="text" name="community_name" class="form-control" value="{{$editCommunity-&gt;community_name}}"&gt;
                  &lt;/form&gt;
                  @endforeach
                  &lt;button class="btn btn-custom dropdown-toggle waves-effect waves-light" type="submit" form="editCommunityForm"&gt;Update Community&lt;/button&gt;&lt;br /&gt;&lt;br /&gt;
              &lt;/div&gt;
              &lt;div class="modal-footer"&gt;
                  {{--&lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt;--}}
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I am very upset and confused and don't know what to do. </p>
  
  <p>Any help would highly be appreciated</p>
  
  <p><a href="https://i.stack.imgur.com/b8hvT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b8hvT.png" alt="See this image to get proper understanding"></a></p>
  
  <p><strong>Edit:</strong>
  After reading the comments; i have understood that only one <code>id</code> would be updated every time. How could i change the <code>id</code> dynamically and update data of that specific <code>id</code> and each time it should get only <code>clicked id</code>. </p>
  
  <p><strong>Controller Function to update:</strong> </p>
  
  <pre><code> public function updateCommunity($id, CommunityRequest $request) {
          $updateCommunity = Community::findOrFail($id);
          $updateCommunity-&gt;update($request-&gt;all());
          return back();
      }
  </code></pre>
  
  <p><strong>View Buttons:</strong></p>
  
  <pre><code>@foreach ($Community as $communities)
       &lt;tr&gt;
          &lt;td&gt;{{$communities-&gt;community_name}}&lt;/td&gt;
          &lt;td&gt; &lt;button type="button" class="btn btn-primary dropdown-toggle waves-effect waves-light" data-toggle="modal" data-target="#myModal"&gt;Edit&lt;/button&gt;
          | &lt;a href="{{ URL::to('delete', array($communities-&gt;id)) }}" class="btn btn-danger dropdown-toggle waves-effect waves-light"&gt;Delete&lt;/a&gt;&lt;/td&gt;
        &lt;/tr&gt;
    @endforeach
  </code></pre>