在PHP中传递弹出模式中的适当变量

I have a popup modal for editing the rows created by fetching data from database. I am creating a popup modal for edit purpose. While clicking the edit button, only the data of the top-most row shows up. 'modaleditsubtask' is my edit modal. and It should show up once I click the edit button. And in within this popup modal, value of the respective row should show up, not the one at the top. I couldn't figure it out what went wrong in the code.

 @extends('layouts.app')

    @section('content')
    <div class="container" id="default_container_style">
      <div class="col-sm-offset-1 col-sm-10">
        <div class="panel panel-default">
          <div class="panel-heading">
            @foreach ($tasks as $tasks) 
            {{$tasks->name}}
          </div>

          {{$tasks->task_description}}

          <div class="panel-body table-responsive">
            <table class="table table-striped task-table ">

                <thead>
                    <tr>
                       <th>Name</th>
                       <th></th>

                       <th></th>
                       <th></th>
                   </tr>
               </thead>
               <tbody>
                @foreach ($subtask_pending as $subtask)

                <tr>
                    <td> {{$subtask->name}} </td>

                <td>
                  <button type="submit" data-toggle="modal" class=" subtaskeditclass btn btn-warning btn-xs" data-target="#modaleditsubtask">
                    <i class="fa fa-btn fa-edit"></i>Edit
                  </button>

                </td>
                <td>
                 <form action="/subtaskdelete/{{ $subtask->id }}" method="POST" style="display: inline-block;">
                  {{ csrf_field() }}
                  {{ method_field('DELETE') }}

                  <button type="submit" id="delete-task-{{$subtask->id }}" class="btn btn-danger btn-xs">
                    <i class="fa fa-btn fa-trash"></i>Delete
                  </button>
                </form>
              </td>

            </tr>
            <form action="/subtask/edit/{{$subtask->id}}" method="POST" class="form-horizontal">

             <div class="modal fade" id="modaleditsubtask" role="dialog">
              <div class="modal-dialog">
                <div class="modal-content">
                  <div class="modal-header" id="popupwindow_subtask">
                    <b class="modal-title" >Edit Name</b>      
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>                                
                  </div>
                  {{ csrf_field() }}
                  {{ method_field('PATCH') }}
                  <div class=subtask1_row_style>
                  <div class="row">
                    <div class="col-sm-3">New Name</div>
                    <div class="col-sm-9"><input type="text" name="name" id="task-name" class="form-control" value="{{$subtask->name}}">         
                    </div>                                      
                  </div> 
                  </div>                                   
                  <div class="modal-footer">
                  <button type="submit" id="{{ $subtask->id }}" class="btn btn-info">
                      <i class="fa fa-btn fa-edit"></i>Edit
                    </button>
                  </div>
                </div>
              </div>
            </div> 
          </div>
        </form>
        @endforeach
        @endforeach
      </tbody>
    </table>
  </div>
  @endsection