diff --git a/src/app/Http/Controllers/SirenController.php b/src/app/Http/Controllers/SirenController.php index b274efc4..6a1ad119 100644 --- a/src/app/Http/Controllers/SirenController.php +++ b/src/app/Http/Controllers/SirenController.php @@ -18,7 +18,12 @@ class SirenController extends Controller station.name, station.district, latest_siren.active_time, - latest_siren.level + latest_siren.level, + COALESCE( + latest_siren.active_time, + (SELECT MAX(r.timestamp) FROM rainfall r WHERE r.stationid = station.stationid), + (SELECT MAX(w.datetime) FROM waterlevel w WHERE w.stationid = station.stationid) + ) AS last_updated FROM station LEFT JOIN LATERAL ( SELECT s.active_time, s.level diff --git a/src/resources/views/layout/siren/home.blade.php b/src/resources/views/layout/siren/home.blade.php index 641eb9bd..971bb871 100644 --- a/src/resources/views/layout/siren/home.blade.php +++ b/src/resources/views/layout/siren/home.blade.php @@ -9,7 +9,7 @@ - @if ($sirenData->isNotEmpty()) +@if ($sirenData->isNotEmpty())
| {{$row ->name}} | - -{{$row ->active_time}} | + +{{ $row->last_updated ? \Carbon\Carbon::parse($row->last_updated)->format('d/m/Y H:i:s') : '-' }} | @@ -53,10 +55,9 @@ @endforeach - + |