I want before logging out, the check_out will be updated, so what needs to be done?
$user = Auth::guard('employees')->user();
if (!$user) {
\Log::error('User authentication succeeded but user object is null');
$this->throwFailureValidationException();
}
if (
($user instanceof FilamentUser) &&
(!$user->canAccessPanel(Filament::getCurrentPanel()))
) {
Auth::guard('employees')->logout();
$this->throwFailureValidationException();
}
session()->regenerate();
if (Auth::guard('employees')->check()) {
$this->handleAttendance($user, 'login');
}
return app(LoginResponse::class);
}
if ($action === 'login' && $attendance && $attendance->check_in === null) {
$scheduledClockIn = Carbon::parse($positionOffice->clock_in);
$oneHourBefore = $scheduledClockIn->copy()->subHour();
if ($attendance && $attendance->check_in === null) {
if ($currentTime <= $oneHourBefore->format('H:i:s')) {
$checkInTime = $oneHourBefore->format('H:i:s');
} else {
$checkInTime = Carbon::now()->format('H:i:s');
}
$attendance->update(['check_in' => $checkInTime]);
}
\Log::info('User login successfully', ['user_id' => $user->id]);
}
if ($action === 'logout' && $attendance && $attendance->check_in !== null && $attendance->check_out === null) {
if ($attendance && $attendance->check_in !== null) {
$attendance->update(['check_out' => Carbon::now()->format('H:i:s')]);
}
\Log::info('User log out successfully', ['user_id' => $user->id]);
}
0 Replies