Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.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_Eloquent - Fatal编程技术网

Php Laravel更新如何更新索引中的数据

Php Laravel更新如何更新索引中的数据,php,laravel,eloquent,Php,Laravel,Eloquent,问题是我想跳过那个编辑页面。它也很好用。但我想在索引视图中编辑我的数据 我尝试了此操作,但出现了此错误 {!! Form::model($choice, ['method' => 'PATCH','route' => ['choices.update', $choice->id]]) !!} <input class="form-control" value="@foreach ($choices as $choice){{ $choice->question_

问题是我想跳过那个编辑页面。它也很好用。但我想在索引视图中编辑我的数据

我尝试了此操作,但出现了此错误

{!! Form::model($choice, ['method' => 'PATCH','route' => ['choices.update', $choice->id]]) !!}
  <input class="form-control" value="@foreach ($choices as $choice){{ $choice->question_number }}@endforeach" type="number" name="number"></input>
{!! Form::submit('Update Task', ['class' => 'btn btn-primary']) !!}
{!! Form::close() !!}

获取对象属性时,必须始终检查对象是否存在

@if (!empty($duplicate->topic))
    <td><a href="{{ route('choices.edit', $duplicate->topic->id) }}" class="btn btn-default">Edit</a></td>
@endIf

$choice
更改为另一个名称,例如
$\u choice
,为避免混淆上面使用的
$choice

请在单击编辑时使用模式。我忘了莫代尔。你能提供一个很好的例子吗?为什么你在modalI中应用foreach的值,你认为你已经在
{{{$choice->question\u number}}
中得到了这个问题的编号……你是否检查了$choice,$duplicate->topic empty??
{!! Form::model($choice, ['method' => 'PATCH','route' => ['choices.update', $choice->id]]) !!}
    <input class="form-control" type="number" name="number"></input>
{!! Form::submit('Update Task', ['class' => 'btn btn-primary']) !!}
{!! Form::close() !!}
public function update(Request $request,Choice $choice){
     Choice::where('id', $choice->id)->update([
        'question_number' => $request->input('number')
        ]);
  return redirect()->route('choices.index');
}
@if (!empty($duplicate->topic))
    <td><a href="{{ route('choices.edit', $duplicate->topic->id) }}" class="btn btn-default">Edit</a></td>
@endIf
@if (!empty($choice))
    {!! Form::model($choice, ['method' => 'PATCH','route' => ['choices.update', $choice->id]]) !!}
        <input class="form-control" type="number" name="number"></input>
    {!! Form::submit('Update Task', ['class' => 'btn btn-primary']) !!}
    {!! Form::close() !!}
@endIf
@foreach ($choices as $choice){{ $choice->question_number }}@endforeach