Laravel Modal keeps on deleting the last id in the database

  Uncategorised

Hi Im trying to make a delete confirmation using modal in laravel in my users table.
I noticed that the delete button is working but the delete button always deletes the last entry in the table and in the confirmation I put some <p>Are you sure you want to delete {{$row->name}}</p> but the name there is always from the last entry. here is my whole modal code

<!-- Delete Modal -->
  <div class="modal fade" id="userDelete"  tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="exampleModalLabel">Delete User</h5>
        </div>
        <div class="modal-body">
          <p>Are you sure you want to delete {{$row->name}}</p> 
        </div>
        <div class="modal-footer">
         {!!Form::open(['action' => ['[email protected]', $row->id], 'method' => 'POST','class'=>'pull-right'])!!}
          <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
          {{Form::submit('Delete',['class'=>'btn btn-danger'])}}
          {{Form::hidden('_method','DELETE')}}
          {!!Form::close()!!}
        </div>
      </div>
    </div>
  </div>

How can I fix it?

Source: Laravel 5 Questions

Leave a Reply