我正在尝试向数据库提交数据。我已将路线更改为“获取”或“发布”,但出现此错误:
我正在尝试向数据库提交数据。我已将路线更改为“获取”或“发布”,但出现此错误:
POST http://localhost/sip/ess/public/attendance/savepresence 500 (Internal Server Error)
我的代码有什么问题?是路由还是控制器?
路线
Route::post('savepresence', 'Attendance@savepresence')->name('attendance.savepresence');
控制器
public function savepresence(Request $req)
{
$row = Attendance::find($req->input('ap_id'));
$rowEmp = Employee::find($row->emp_id);
//SO 26-02-2023 Att RAW In
$ar_time_in = substr($req->input('ap_in'),11,8);
$ar_time_in_old = substr($row->ap_in,11,8);
if (!empty($req->input('ap_in')) && $ar_time_in != $ar_time_in_old){
Attendance_raw_tmp::create([
'emp_id' => $row->emp_id,
'ar_date_tmp' => $thisDate,
'ar_id_tmp' => $rowEmp->emp_code,
'ar_time_tmp' => $ar_time_in,
'ar_lat' => '-6.3013773',
'ar_long' => '106.8429748',
'ar_client_tmp' => $req->input('ar_client_tmp'),
'ar_notes_tmp' => $req->input('ar_notes_tmp'),
'ar_opid' => $this->_user->user_id
]);
}
//SO 26-07-2022 Att RAW Out
$ar_time_out = substr($req->input('ap_out'),11,8);
$ar_time_out_old = substr($row->ap_out,11,8);
if (!empty($req->input('ap_out')) && $ar_time_out != $ar_time_out_old){
Attendance_raw_tmp::create([
'emp_id' => $row->emp_id,
'ar_date_tmp' => $thisDate,
'ar_id_tmp' => $rowEmp->emp_code,
'ar_time_tmp' => $ar_time_out_old,
'ar_lat' => '-6.3013773',
'ar_long' => '106.8429748',
'ar_client_tmp' => $req->input('ar_client_tmp'),
'ar_notes_tmp' => $req->input('ar_notes_tmp'),
'ar_opid' => $this->_user->user_id
]);
}
return redirect()->route('attendance.index')->with('notif', [
'type' => 'success',
'message' => 'Update Attendance Submission has been saved.'
]);
}
查看
<div class="container attendancereview-form">
<form action="{{ route('attendance.savepresence') }}" method="post" id="attendancereview-form" class="form-horizontal">
@csrf
<input type="hidden" name="ap_id" value="{{ $row->ap_id }}">
<input type="hidden" name="emp_id" value="{{ $row->emp_id }}">
<div class="row">
<div class="col-md-12">
<div class="form-group mb-4 row">
<label for="ap_date" class="col-sm-3 col-form-label text-md-right">Date</label>
<div class="col-sm-9">
<input class="form-control" name="ap_date" type="text" autocomplete="off" value="{{ $row->ap_date }}" placeholder="yyyy-mm-dd hh:mm:ss" disabled>
</div>
</div>
<div class="form-group mb-4 row">
<label for="ap_in" class="col-sm-3 col-form-label text-md-right">Time In </label>
<div class="col-sm-9">
<input class="form-control" name="ap_in" type="text" autocomplete="off" value="{{ $row->ap_in }}" placeholder="yyyy-mm-dd hh:mm:ss">
<font color="red">example : {{ $row->ap_date }} 08:00:00 </font>
</div>
</div>
<div class="form-group mb-4 row">
<label for="ap_out" class="col-sm-3 col-form-label text-md-right">Time Out </label>
<div class="col-sm-9">
<input class="form-control" name="ap_out" type="text" autocomplete="off" value="{{ $row->ap_out }}" placeholder="yyyy-mm-dd hh:mm:ss">
<font color="red">example : {{ $row->ap_date }} 17:00:00 </font>
</div>
</div>
<div class="form-group mb-4 row">
<label for="client" class="col-sm-3 col-form-label text-md-right">Client </label>
<div class="col-sm-9">
<input class="form-control" name="ar_client_tmp" type="text" autocomplete="off" value="">
</div>
</div>
<div class="form-group mb-4 row">
<label for="notes" class="col-sm-3 col-form-label text-md-right">Notes </label>
<div class="col-sm-9">
<input class="form-control" name="ar_notes_tmp" type="text" autocomplete="off" value="">
</div>
</div>
</div>
</div>
</form>
</div>
请帮帮我?