bug fix in clients show view

This commit is contained in:
Kwesi Banson Jnr
2026-08-27 16:02:42 +00:00
parent f3d79367df
commit ff7f1e35e6
3 changed files with 2578 additions and 2 deletions

View File

@@ -247,10 +247,26 @@
<div class="card-body">
<!-- JSON Emails/Phones -->
@php
function renderBadges($items, $type = 'email') {
if(gettype($items) == 'string') return '<span class="text-muted small">'.$items.'</span>';
elseif(count($items) === 0) return '<span class="text-muted small">N/A</span>';
// If it's a JSON string, decode it into an array first
if (is_string($items)) {
$decoded = json_decode($items, true);
if (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) {
$items = $decoded;
} else {
// If it's just a plain text string, return it directly
return '<span class="text-muted small">'.$items.'</span>';
}
}
// Now safely check if it's an array and has elements
if (!is_array($items) || count($items) === 0) {
return '<span class="text-muted small">N/A</span>';
}
$html = '';
foreach($items as $item) {
$icon = $type == 'email' ? 'bi-envelope' : 'bi-telephone';

View File

@@ -85,3 +85,19 @@
@endif
</div>
@php
function renderBadges($items, $type = 'email') {
if(gettype($items) == 'string') return '<span class="text-muted small">'.$items.'</span>';
elseif(count($items) === 0) return '<span class="text-muted small">N/A</span>';
$html = '';
foreach($items as $item) {
$icon = $type == 'email' ? 'bi-envelope' : 'bi-telephone';
$html .= '<span class="badge bg-light text-dark border me-1 mb-1"><i class="bi '.$icon.' text-secondary me-1"></i>'.$item.'</span>';
}
return $html;
}
@endphp

File diff suppressed because one or more lines are too long