Skip to content

Commit

Permalink
Update TeacherApiController.php
Browse files Browse the repository at this point in the history
  • Loading branch information
ArdianS18 committed Nov 20, 2024
1 parent 5f9994f commit 9cda8c4
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions app/Http/Controllers/Api/TeacherApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,16 @@ public function teacher_attendance(User $user)
$employee = $this->employee->getByUser($user->id);
$todayAttendance = $this->attendance->userToday('App\Models\Employee', $employee->id);

$data = [
$history_attendance = $this->attendance->whereUser($employee->id, 'App\Models\Employee');

return response()->json(['status' => 'success', 'message' => "Berhasil mengambil data",'code' => 200,
'day' => $todayAttendance->created_at == null ? '-' : Carbon::parse($todayAttendance->created_at)->translatedFormat('l'),
'date' => $todayAttendance->created_at == null ? '-' : Carbon::parse($todayAttendance->created_at)->translatedFormat('d'),
'month' => $todayAttendance->created_at == null ? '-' : Carbon::parse($todayAttendance->created_at)->translatedFormat('M'),
'date_complate' => $todayAttendance->created_at == null ? '-' : Carbon::parse($todayAttendance->created_at)->translatedFormat('l, j F Y'),
'check_in' => $todayAttendance->checkin == null ? '-' : Carbon::parse($todayAttendance->checkin)->format('H:i'),
'check_out' => $todayAttendance->checkout == null ? '-' : Carbon::parse($todayAttendance->checkout)->format('H:i'),
'check_in' => $todayAttendance->checkin == null ? '-' : \Carbon\Carbon::parse($todayAttendance->checkin)->format('H:i'),
'check_out' => $todayAttendance->checkout == null ? '-' : \Carbon\Carbon::parse($todayAttendance->checkout)->format('H:i'),
'status' => $todayAttendance->status == null ? '-' : $todayAttendance->status->label(),
];

$history_attendance = $this->attendance->whereUser($employee->id, 'App\Models\Employee');

return response()->json(['status' => 'success', 'message' => "Berhasil mengambil data",'code' => 200,
// 'day' => $todayAttendance->created_at == null ? '-' : Carbon::parse($todayAttendance->created_at)->translatedFormat('l'),
// 'date' => $todayAttendance->created_at == null ? '-' : Carbon::parse($todayAttendance->created_at)->translatedFormat('d'),
// 'month' => $todayAttendance->created_at == null ? '-' : Carbon::parse($todayAttendance->created_at)->translatedFormat('M'),
// 'date_complate' => $todayAttendance->created_at == null ? '-' : Carbon::parse($todayAttendance->created_at)->translatedFormat('l, j F Y'),
// 'check_in' => $todayAttendance->checkin == null ? '-' : \Carbon\Carbon::parse($todayAttendance->checkin)->format('H:i'),
// 'check_out' => $todayAttendance->checkout == null ? '-' : \Carbon\Carbon::parse($todayAttendance->checkout)->format('H:i'),
// 'status' => $todayAttendance->status == null ? '-' : $todayAttendance->status->label(),
'attendance_single' => $data,
'attendance_history' => HistoryAttendanceResource::collection($history_attendance),
]);
}
Expand Down

0 comments on commit 9cda8c4

Please sign in to comment.