如何将多个选定的表行传递给Laravel中的模式框

时间:2019-02-24 17:17:13

标签: laravel-5.6

请帮助我。我有一个表,我想选择多个行并同时为它们分配一个值,例如Sector。我正在使用模式框将值分配给选定的表行。我的问题是如何将这些选定行的ID传递给模式框。

谢谢您的帮助。

Screenshots 我的看法

<script>   
    $('#success').on("show.bs.modal", function (e) {
        
    });
</script>
<table class="table table-hover table-xl mb-0">
    <thead>
        <tr>
            <th><input type="checkbox" class="input-chk" id="check-all"></th>
            <th class="border-top-0">Name</th>
            <th class="border-top-0"> Location</th>
            <th class="border-top-0">MEPB Status</th>
            <th class="border-top-0">MDA Status</th>
            <th class="border-top-0">Primary MDA</th>
            <th class="border-top-0">Secondary MDA</th>
            <th class="border-top-0">Project Cost</th>
            <th class="border-top-0" >Executive</th>
            <th class="border-top-0" >Legislature</th>
        </tr>
    </thead>
    <tbody>
        @foreach($needs as $c)
            <tr>
                <td><input type="checkbox" class="input-chk check" name="ids[]" value="{{ $c->id }}"></td>
                <td><a href="{{ route('mepb-community-needs.show',$c->id)}}"><strong>{!! $c->community_project !!}</strong></a></td>
                <td>{!! $c->location !!}</td>
                <td class="">{!! $c->mepb !!}
                </td>
                <td>
                   {!! $c->mda !!}
                </td>
                <td>
                    {!! $c->primary_mda !!}
                </td>
                <td>{!! $c->secondary_mda !!}
                <td>{!! $c->cost !!}
                </td>
                <td> - </td>
                <td> - </td>
            </tr>
        @endforeach
    </tbody>
</table>
<!-- Modal -->
<div class="modal fade text-left" id="success" tabindex="-1" role="dialog" aria-labelledby="myModalLabel9" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header bg-success white">
        <h4 class="modal-title white" id="myModalLabel9"><i class="la la-tree"></i> Assign Mda and Sector</h4>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <form action="{{ route('mepb-community-needs.approve')}}" method="POST" >
            @CSRF
            <input type="hidden" name="ids" value="">
            <div class="form-group">
                <label for="">Primary MDA</label>
                <select name="primary_mda" id="primary_mda" class="form-control select2">
                    @foreach(\App\Mda::all() as $mda)
                        <option value="{{ $mda->id }}">{{ $mda->name }}</option>
                    @endforeach
                </select>
            </div>
            <div class="form-group">
                <label for="">Secondary MDA</label>
                <select name="secondary_mda" id="secondary_mda" class="form-control select2">
                    @foreach(\App\Mda::all() as $mda)
                        <option value="{{ $mda->id }}">{{ $mda->name }}</option>
                    @endforeach
                </select>
            </div>
            <div class="form-group">
                <label for="">Sector</label>
                <select name="sector_id" id="sectorr" class="form-control select2">
                    @foreach(\App\Sector::all() as $sector)
                        <option value="{{ $sector->id }}">{{ $sector->name }}</option>
                    @endforeach
                </select>
            </div>
            <div class="form-group">
                <label for="">Sub Sector</label>
                <select name="subsector_id" id="subsectorr" class="form-control select2">
                    @foreach(\App\Subsector::all() as $sector)
                        <option value="{{ $sector->id }}">{{ $sector->name }}</option>
                    @endforeach
                </select>
            </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn grey btn-outline-secondary" data-dismiss="modal">Cancel</button>
        <button type="submit" class="btn btn-outline-success">Update</button>
      </div>
    </div>
    </form>
  </div>
</div>

0 个答案:

没有答案