title: Updating an object with Laravel
body: <p>I want to update the value of "<strong>Designation</strong>" but when I click on the first item, the form is automatically populated with the LAST value that was inserted and not with the one I clicked on, <br> for instance if I wanted to update the value of "<strong>FM2</strong>" I will get "<strong>tst</strong>"  in the form :<br> </p>
  
  <p><img src="https://i.stack.imgur.com/wJguo.png" alt="Displaying the values"></p>
  
  <p><img src="https://i.stack.imgur.com/Ja39P.png" alt="When I click to update &quot;FM2&quot; value"></p>
  
  <p>This is the view code : </p>
  
  <pre><code>    @extends('dashboard.layout')
  
  @section('title' , 'Manage Sockets')
  @section('pageHeader', 'Sockets')
  
  @section('content')
  
      &lt;div class="card"&gt;
  
          &lt;div class="table-responsive"&gt;
              &lt;table id="data-table-basic" class="table table-striped"&gt;
                  &lt;thead&gt;
                  &lt;tr&gt;
                      &lt;th data-column-id="id" data-type="numeric"&gt;ID&lt;/th&gt;
                      &lt;th data-column-id="sender"&gt;Designation&lt;/th&gt;
                      &lt;th data-column-id="received" data-order="desc"&gt;Updated on&lt;/th&gt;
                      &lt;th data-column-id="operations" data-order="desc"&gt;Operations&lt;/th&gt;
                  &lt;/tr&gt;
                  &lt;/thead&gt;
                  &lt;tbody&gt;
                      @foreach($sockets as $socket)
                          &lt;tr&gt;
                              &lt;td&gt;{{$socket-&gt;id}}&lt;/td&gt;
                              &lt;td&gt;{{$socket-&gt;designation}}&lt;/td&gt;
                              &lt;td&gt;{{$socket-&gt;updated_at}}&lt;/td&gt;
                              &lt;td&gt;
                                  &lt;a href="{{action('SocketController@delete', ['id' =&gt;$socket-&gt;id ])}}" class="btn bgm-cyan waves-effect"&gt;&lt;i class="zmdi zmdi-close"&gt;&lt;/i&gt;&lt;/a&gt;
                                  &lt;a data-toggle="modal" href="#modalDefault"  class="btn bgm-orange waves-effect"&gt;&lt;i class="zmdi zmdi-edit"&gt;&lt;/i&gt;&lt;/a&gt;
                              &lt;/td&gt;
  
                          &lt;/tr&gt;
                      @endforeach
                  &lt;/tbody&gt;
              &lt;/table&gt;
  
          &lt;/div&gt;
  
      &lt;/div&gt;
      &lt;div class="modal fade" id="modalDefault" tabindex="-1" role="dialog" aria-hidden="true"&gt;
          &lt;div class="modal-dialog"&gt;
              &lt;div class="modal-content"&gt;
                  &lt;div class="modal-header"&gt;
                      &lt;h4 class="modal-title"&gt;Update A Socket&lt;/h4&gt;
                  &lt;/div&gt;
                  &lt;div class="modal-body"&gt;
                      {!! Form::model($socket,['route' =&gt;['socketupdate',$socket-&gt;id],'method'=&gt;'POST']) !!}
                      &lt;div class="row"&gt;
                          &lt;div class=" col-sm-offset-1 col-sm-10" &gt;
                              &lt;!-- text input for designation --&gt;
                              &lt;div class="form-group fg-float"&gt;
                                  &lt;div class="fg-line"&gt;
                                      {!! Form::label('designation', 'designation:',['class' =&gt; 'fg-label']) !!}
                                      {!! Form::text('designation',null,['class' =&gt; 'form-control fg-input input-sm']) !!}
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="row" &gt;
                          &lt;div class="col-sm-12" &gt;
                              &lt;button class="btn bgm-blue center-block" style="display: flex" type="submit" &gt;Submit&lt;/button&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      {!! Form::close() !!}
                  &lt;/div&gt;
                  &lt;div class="modal-footer"&gt;
                      &lt;button data-dismiss="modal" class="btn bgm-cyan btn-icon waves-effect waves-circle waves-float"&gt;&lt;i class="zmdi zmdi-close"&gt;&lt;/i&gt;&lt;/button&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
  
      &lt;button class="btn bgm-lightgreen btn-icon waves-effect waves-circle waves-float"&gt;
          &lt;i class="zmdi zmdi-plus"&gt;&lt;/i&gt;
      &lt;/button&gt;
      @include('forms.socket')
  
  @endsection
  
  @section('additional_scripts')
      &lt;script type="text/javascript"&gt;
          $(document).ready(function(){
              $('body').on('click', '#btn-color-targets &gt; .btn', function(){
                  var color = $(this).data('target-color');
                  $('#modalColor').attr('data-modal-color', color);
              });
          });
      &lt;/script&gt;
  
  @endsection
  </code></pre>
  
  <p>how can I fix this?</p>