diff --git a/app/Http/Controllers/Api/TeacherApiController.php b/app/Http/Controllers/Api/TeacherApiController.php index b600e2f7..1372c459 100644 --- a/app/Http/Controllers/Api/TeacherApiController.php +++ b/app/Http/Controllers/Api/TeacherApiController.php @@ -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), ]); }