'datetime', 'check_out_at' => 'datetime', ]; public static function doesOverlap(Carbon $from, Carbon $to, int|null $excludeId) { $countA = UserAttendance::where('id', '!=', $excludeId)->where('user_id', Auth::user()->id)->where('check_in_at', '<', $from)->where('check_out_at', '>', $from)->count(); $countB = UserAttendance::where('id', '!=', $excludeId)->where('user_id', Auth::user()->id)->where('check_in_at', '<', $to)->where('check_out_at', '>', $to)->count(); return $countA + $countB > 0; } }