From 57229b3cc607bfafb5e6be7ebb7d0ab7ae1cc46f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Thu, 22 Jan 2026 20:48:43 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20API=20=EC=97=90=EB=9F=AC=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=ED=91=9C=EC=8B=9C=20=EB=B0=8F=20=EC=98=A4=EB=8A=98?= =?UTF-8?q?=EC=9D=98=20=EC=9D=B4=EC=8A=88=20=EC=8B=9C=EA=B0=84=20=ED=8F=AC?= =?UTF-8?q?=EB=A7=B7=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ApiResponse::error() 메시지에 상태 코드 포함 ([{code}] {message}) - TodayIssueService 시간 포맷을 상대시간에서 실제시간으로 변경 - 오늘: "14:30" - 어제: "어제 14:30" - 그 외: "1/22 14:30" Co-Authored-By: Claude Opus 4.5 --- app/Helpers/ApiResponse.php | 2 +- app/Services/TodayIssueService.php | 30 +++++++++++++----------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/app/Helpers/ApiResponse.php b/app/Helpers/ApiResponse.php index 230f262..d95b40e 100644 --- a/app/Helpers/ApiResponse.php +++ b/app/Helpers/ApiResponse.php @@ -147,7 +147,7 @@ public static function error( ): JsonResponse { return response()->json([ 'success' => false, - 'message' => $message, + 'message' => "[{$code}] {$message}", 'error' => [ 'code' => $code, 'details' => $error['details'] ?? null, diff --git a/app/Services/TodayIssueService.php b/app/Services/TodayIssueService.php index 7b61a69..92bf15e 100644 --- a/app/Services/TodayIssueService.php +++ b/app/Services/TodayIssueService.php @@ -193,7 +193,10 @@ public function cleanupExpiredIssues(): int } /** - * 상대 시간 포맷팅 + * 등록 시간 포맷팅 + * - 오늘: "14:30" + * - 어제: "어제 14:30" + * - 그 외: "1/22 14:30" */ private function formatRelativeTime(?Carbon $datetime): string { @@ -202,26 +205,19 @@ private function formatRelativeTime(?Carbon $datetime): string } $now = Carbon::now(); - $diffInMinutes = $now->diffInMinutes($datetime); - $diffInHours = $now->diffInHours($datetime); - $diffInDays = $now->diffInDays($datetime); + $time = $datetime->format('H:i'); - if ($diffInMinutes < 60) { - return __('message.today_issue.time_minutes_ago', ['minutes' => max(1, $diffInMinutes)]); + // 오늘 + if ($datetime->isToday()) { + return $time; } - if ($diffInHours < 24) { - return __('message.today_issue.time_hours_ago', ['hours' => $diffInHours]); + // 어제 + if ($datetime->isYesterday()) { + return __('message.today_issue.time_yesterday').' '.$time; } - if ($diffInDays == 1) { - return __('message.today_issue.time_yesterday'); - } - - if ($diffInDays < 7) { - return __('message.today_issue.time_days_ago', ['days' => $diffInDays]); - } - - return $datetime->format('Y-m-d'); + // 그 외 + return $datetime->format('n/j').' '.$time; } }