From 7fb839efed7a74be4e88af25d564f43a3b19b767 Mon Sep 17 00:00:00 2001 From: rahmatrafli1 Date: Tue, 10 Dec 2024 16:48:01 +0700 Subject: [PATCH] fix: handle empty jenis_aset_id array in KJPP data display This commit addresses the issue where an empty jenis_aset_id array would cause an error in the KJPP data display. It adds a check to ensure the array is not empty before iterating through it, and displays a "-" message if the array is empty. The changes made are: 1. Added a check for !empty(json_decode($kjpp->jenis_aset_id, true)) inside the @if condition. 2. This ensures that the array is not empty before attempting to loop through it. 3. If the array is empty, a "-" message is displayed instead. This fix ensures a more robust and user-friendly display of the KJPP data, handling both populated and empty jenis_aset_id arrays gracefully. --- resources/views/kjpp/show.blade.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/views/kjpp/show.blade.php b/resources/views/kjpp/show.blade.php index 2ca826d..b0bb344 100644 --- a/resources/views/kjpp/show.blade.php +++ b/resources/views/kjpp/show.blade.php @@ -250,7 +250,7 @@ Pengalaman (Jenis Aset)
- @if (isset($kjpp->jenis_aset_id)) + @if (isset($kjpp->jenis_aset_id) && !empty(json_decode($kjpp->jenis_aset_id, true))) @foreach (json_decode($kjpp->jenis_aset_id, true) as $aset_code) @php $jenis_aset = $jenis_jaminan->firstWhere('code', $aset_code); @@ -263,8 +263,8 @@ @endif @endforeach @else - - No asset type selected. + + - @endif