我不明白为什么会出现此错误。我有一个正确的Asset.update声明路线
AssetController更新
public function update(Request $request, $id)
{
$asset = Asset::find($request->input('id'));
$asset->pc_id = $request->pc_id;
$asset->save();
Pcstorage::where('pc_id', $request->input('pc_id'))
->increment('in_use');
Pcstorage::where('pc_id', $request->input('pc_id'))
->decrement('on_hand');
return redirect()->route('asset.index');
}
我的编辑模式基本上就是添加pc_id并对其进行更新
<div class="modal fade" id="addPCModal" tabindex="-1" role="dialog" aria-labelledby="addPCModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addPCModalLabel">Add PC</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
@if(isset($asset))
{!! Form::model($assets, ['route' => ['asset.update', $asset->id], 'method' => 'PUT']) !!}
{!! Form::hidden('id', null, ['id' => 'add-asset-id']) !!}
{!! Form::label('PC:') !!}
{!! Form::select('pc_id', $computers, null, ['placeholder' => 'Select PC', 'class' => 'form-control']) !!}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" style="margin-top:20px" data-dismiss="modal">Cancel</button>
{!! Form::submit('Add PC', ['class' => 'btn btn-primary', 'style' => 'margin-top:20px']) !!}
</div>
{!! Form::close() !!}
@endif
</div>
</div>
</div>
我的路线是这个Route::resource('asset', 'AssetController');
当我检查路线列表时,我的asset.update是一个补丁/投放。但是我仍然无法更新以添加pc_id。