diff --git a/app/Services/WeatherService.php b/app/Services/WeatherService.php index 72932b60..403d3684 100644 --- a/app/Services/WeatherService.php +++ b/app/Services/WeatherService.php @@ -74,15 +74,17 @@ private function buildForecast(): array $midTmn = $midTa["taMin{$i}"] ?? null; $midTmx = $midTa["taMax{$i}"] ?? null; $midWf = $midLand["wf{$i}Am"] ?? ($midLand["wf{$i}"] ?? ''); + $midPop = max($midLand["rnSt{$i}Am"] ?? 0, $midLand["rnSt{$i}Pm"] ?? 0, $midLand["rnSt{$i}"] ?? 0); if ($shortData) { - // 단기예보 우선, 기온이 없으면 중기로 보충 + // 단기예보 우선, 기온/강수확률 없으면 중기로 보충 $forecasts[] = [ 'date' => $date, 'tmn' => $shortData['tmn'] ?? $midTmn, 'tmx' => $shortData['tmx'] ?? $midTmx, 'icon' => $shortData['icon'] ?? (! empty($midWf) ? $this->midWeatherToIcon($midWf) : null), 'weather_text' => $shortData['weather_text'] ?: $midWf, + 'pop' => $shortData['pop'] ?? $midPop, ]; } else { $forecasts[] = [ @@ -91,6 +93,7 @@ private function buildForecast(): array 'tmx' => $midTmx, 'icon' => ! empty($midWf) ? $this->midWeatherToIcon($midWf) : null, 'weather_text' => $midWf, + 'pop' => $midPop, ]; } } @@ -157,7 +160,7 @@ private function fetchShortForecast(): array $value = $item['fcstValue']; if (! isset($grouped[$fcstDate])) { - $grouped[$fcstDate] = ['date' => $fcstDate, 'tmn' => null, 'tmx' => null, 'sky' => null, 'pty' => null]; + $grouped[$fcstDate] = ['date' => $fcstDate, 'tmn' => null, 'tmx' => null, 'sky' => null, 'pty' => null, 'pop' => 0]; } match ($category) { @@ -165,6 +168,7 @@ private function fetchShortForecast(): array 'TMX' => $grouped[$fcstDate]['tmx'] = (int) $value, 'SKY' => $grouped[$fcstDate]['sky'] ??= (int) $value, 'PTY' => $grouped[$fcstDate]['pty'] ??= (int) $value, + 'POP' => $grouped[$fcstDate]['pop'] = max($grouped[$fcstDate]['pop'], (int) $value), default => null, }; } @@ -178,6 +182,7 @@ private function fetchShortForecast(): array 'tmx' => $data['tmx'], 'icon' => $icon, 'weather_text' => $this->iconToText($icon), + 'pop' => $data['pop'], ]; } diff --git a/resources/views/dashboard/partials/weather.blade.php b/resources/views/dashboard/partials/weather.blade.php index 2e5e986c..b828fcef 100644 --- a/resources/views/dashboard/partials/weather.blade.php +++ b/resources/views/dashboard/partials/weather.blade.php @@ -30,6 +30,7 @@ $weatherText = $fc['weather_text'] ?? ''; $tmn = $fc['tmn']; $tmx = $fc['tmx']; + $pop = $fc['pop'] ?? 0; $hasData = ($tmn !== null || $tmx !== null || $icon !== null); // 바 위치 계산 (%) @@ -57,7 +58,7 @@ @if($hasData) {{-- 날씨 아이콘 --}} -
+
@if($icon) @include('dashboard.partials.weather-icon', ['icon' => $icon]) @else @@ -65,10 +66,19 @@ @endif
- {{-- 날씨 텍스트 --}} -
- {{ $weatherText ?: '-' }} -
+ {{-- 강수확률 --}} + @if($pop > 0) +
+ {{-- 우산 아이콘 --}} + + + + + {{ $pop }}% +
+ @else +
+ @endif {{-- 기온 바 그래프 --}} @if($tmx !== null && $tmn !== null) @@ -100,7 +110,7 @@
@else {{-- 데이터 없는 날 --}} -
+