我在试图关闭(改变状态)的实际对象时得到了这个错误
public function showclose(Request $request, $id) {
$cashregister = CashRegister::find($id);
if (!$request->ajax()) {
return view('backend.cashregister.close', compact('cashregister', 'id'));
} else {
return view('backend.cashregister.modal.close', compact('cashregister', 'id'));
}
}
public function close(Request $request, $id) {
$cashregister = CashRegister::find($id);
$cashregister->status = 0;
$cashregister->closedate = date('Y-m-d H:i:s');
$cashregister->save();
if (!$request->ajax()) {
return redirect()->route('cashregister.index')->with('success', _lang('Closed Box'));
} else {
return response()->json(['result' => 'success', 'action' => 'update', 'message' => _lang('Closed Box'), 'data' => $cashregister, 'table' => '#cashregister_table']);
}
}
Route::resource('cashregister','CashRegisterController');
Route::get('cashregister/showclose/{id}', 'CashRegisterController@showclose')->name('cashregister.showclose');
Route::post('cashregister/close/{id}', 'CashRegisterController@close')->name('cashregister.close');
<form method="post" class="ajax-screen-submit" autocomplete="off" action="{{ action('CashRegisterController@close', $id) }}" enctype="multipart/form-data">
{{ csrf_field()}}
<input name="_method" type="hidden" value="PATCH">
<div class="row px-2">
<table class="table table-bordered">
<tr><td>{{ _lang('Box Quantity') }}</td><td>{{ $cashregister->startingamount }}</td></tr>
<tr><td>{{ _lang('Open Date') }}</td><td>{{ $cashregister->created_at }}</td></tr>
<tr><td>{{ _lang('Final Amount') }}</td><td>{{ $cashregister->finalamount }}</td></tr>
<tr><td>{{ _lang('Close Date') }}</td><td>{{ $cashregister->closedate }}</td></tr>
<tr><td>{{ _lang('Status') }}</td><td class='status'>{!! xss_clean(user_status($cashregister->status)) !!}</td></tr>
</table>
<div class="form-group">
<div class="col-md-12">
<button type="submit" class="btn btn-danger "><i class="ti-lock"></i> {{ _lang('Update') }}</button>
</div>
</div>
</div>
我不能更新我想做的值,显示在实际状态和然后点击改变状态,但我得到了错误,尽管是后方法
编辑更改值以获取有效,但为什么不在更新后加载索引视图?知道吗?
1条答案
按热度按时间jmo0nnb31#
在路由文件中,更改以下行:
致: