Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无法在laravel';刃锉_Php_Laravel - Fatal编程技术网

Php 无法在laravel';刃锉

Php 无法在laravel';刃锉,php,laravel,Php,Laravel,我在拉维尔做一个项目。我在数据库中有多条记录,我已经使用foreach循环在laravel的刀片文件中显示了这些记录。每个记录都有挂起按钮。每当用户单击挂起按钮时,它就会打开一个html模式。我想在modal中使用该记录id,但它总是使用第一个记录id。我的刀片文件看起来像 @foreach($providerData as $newprovider) <h4>Name:{{$newprovider->name}}</h4> <button class="

我在拉维尔做一个项目。我在数据库中有多条记录,我已经使用foreach循环在laravel的刀片文件中显示了这些记录。每个记录都有挂起按钮。每当用户单击挂起按钮时,它就会打开一个html模式。我想在modal中使用该记录id,但它总是使用第一个记录id。我的刀片文件看起来像

 @foreach($providerData as $newprovider)
<h4>Name:{{$newprovider->name}}</h4>
 <button class="btn btn-default" data-toggle="modal" data-target="#Pendingnote">Pending</button>

{!! Form::model( $newprovider->id ,['method' => 'PATCH','action'=>['superadminController@pendingProvider', $newprovider->id]]) !!}

<div class="modal fade" id="Pendingnote" role="dialog">

    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Note {!! $newprovider->id !!}</h4>
            </div>
            <div class="modal-body">
                <input type="text" class="form-control" name="note" value="{{ old('note') }}">
            </div>
            <div class="modal-footer">
                {!! Form::submit('Add', ['class' => 'btn btn-default']) !!}
            </div>
        </div>
    </div>
    <input type="hidden" name="_token" value="{{ csrf_token() }}">
</div>    
{!! Form::close() !!}
@endforeach
@foreach($providerData作为$newprovider)
名称:{{$newprovider->Name}
悬而未决的
{!!Form::model($newprovider->id,['method'=>'PATCH','action'=>['superadminController@pendingProvider“,$newprovider->id]])
&时代;
注意{!!$newprovider->id!!}
{!!Form::submit('Add',['class'=>'btn-btn-default'])
{!!Form::close()!!}
@endforeach

无论单击哪个记录,它都会返回$newprovider->id作为第一个记录的id。我不知道哪里出错了。请提前帮助和感谢。

所有模式触发按钮都有
数据目标=“#Pendingnote”
,这意味着它们都会使用可以找到的id触发第一个模式

例如,您可以尝试删除
数据目标
属性,并使用一点jQuery触发模式,如:

$('button[data-toggle]').on('click', function () {
  $(this).next('form').find('.modal').modal('show');
});
无论如何,我建议将
表单
放在模态中。因此jQuery应该是:

$('button[data-toggle]').on('click', function () {
  $(this).next('.modal').modal('show');
});

最后,看看这个:

做这些事情以使情态动词起作用

将按钮编辑为:

<button class="btn btn-default" data-toggle="modal" data-target="#Pendingnote{{$newprovider->id}}">Pending</button>
<div class="modal fade" id="Pendingnote{{$newprovider->id}}" role="dialog">
挂起
并将模式容器设置为:

<button class="btn btn-default" data-toggle="modal" data-target="#Pendingnote{{$newprovider->id}}">Pending</button>
<div class="modal fade" id="Pendingnote{{$newprovider->id}}" role="dialog">

如何使用此函数调用.on(show.bs.modal)函数$('#Pendingnote{{{$newprovider->id}}}')。在('show.bs.modal',函数(事件){code here}上使用这个?