我正在计算员工迟到的次数。如果他们在一定时间后签入/刷卡,则“延迟”会通过布尔值自动存储为true。
但是,如果一天中要多次刷卡,则“后期”数量会不断增加。是否有办法说明,如果今天已经有某个特定服务员的迟到记录,那么在第二天之前不要保存任何新记录?
如果存在类似于->碳的startOfNExtDay之类的东西,那可能很好。
这是我保存最新记录的图片和代码:
if($attendance) {
$attendance->checked_out_at = $current;
$attendance->time_spent_working = $attendance->checked_out_at->diffInSeconds($attendance->checked_in_at);
} else {
$attendance = new Attendance();
$attendance->name = $employee->name;
$attendance->employee_id = $employee->id;
$attendance->checked_in_at = $current;
if (($attendance->checked_in_at->startOfDay()->addHours(10)) < $attendance->checked_in_at) {
$attendance->late = true;
} else {
$attendance->late = false;
}
在视图中显示它:
<table class="table attendances_table">
<tr class="thead-bordered">
<th>Employee</th>
<th class="centered-text">Total time Worked</th>
<th class="centered-text">Times Being Late</th>
</tr>
@foreach($employees as $employee)
<tr>
<td>{{ $employee->name }}</td>
<td class="centered-text">{{ gmdate("H:i:s", $total_time[$employee->id]) }}</td>
<td class="centered-text">{{ $total_late[$employee->id] }}</td>
@endforeach
</tr>
</table>
谢谢!