bug fix 2 in clients show view
This commit is contained in:
@@ -249,32 +249,40 @@
|
||||
<!-- JSON Emails/Phones -->
|
||||
|
||||
|
||||
@php
|
||||
function renderBadges($items, $type = 'email') {
|
||||
// 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';
|
||||
$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;
|
||||
@php
|
||||
function renderBadges($items, $type = 'email') {
|
||||
// If it's empty or null, return N/A immediately
|
||||
if (empty($items)) {
|
||||
return '<span class="text-muted small">N/A</span>';
|
||||
}
|
||||
@endphp
|
||||
|
||||
// If it's a JSON string, decode it
|
||||
if (is_string($items)) {
|
||||
$decoded = json_decode($items, true);
|
||||
if (json_last_error() === JSON_ERROR_NONE) {
|
||||
$items = $decoded;
|
||||
} else {
|
||||
// If it's just a regular comma-separated string or single value, turn it into a 1-item array
|
||||
$items = [$items];
|
||||
}
|
||||
}
|
||||
|
||||
// If after decoding/conversion it's still not an array or is empty, bail out safely
|
||||
if (!is_array($items) || count($items) === 0) {
|
||||
return '<span class="text-muted small">N/A</span>';
|
||||
}
|
||||
|
||||
$html = '';
|
||||
foreach($items as $item) {
|
||||
if (!empty($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>'.trim($item).'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
return $html !== '' ? $html : '<span class="text-muted small">N/A</span>';
|
||||
}
|
||||
@endphp
|
||||
|
||||
<div class="mb-3">
|
||||
<div class="text-muted small mb-1">Finance Emails</div>
|
||||
|
||||
Reference in New Issue
Block a user