@php $whoType = strtolower(trim((string) ($whoType ?? 'authority'))); $whoValue = trim((string) ($whoValue ?? '')); $whoCat = is_array($whoCat ?? null) ? $whoCat : []; $canEdit = (bool) ($canEdit ?? false); $disabled = $canEdit ? '' : 'disabled'; $options = []; if ($whoType === 'authority') { foreach (($whoCat['authorities'] ?? []) as $k => $label) { $options[(string) $k] = (string) $label; } } elseif ($whoType === 'permission') { foreach (($whoCat['permissions'] ?? []) as $k => $label) { $options[(string) $k] = (string) $label; } } elseif ($whoType === 'role') { foreach (($whoCat['roles'] ?? []) as $role) { if (! is_array($role)) { continue; } $slug = (string) ($role['slug'] ?? ''); if ($slug === '') { continue; } $options[$slug] = (string) ($role['label'] ?? $slug); } } elseif ($whoType === 'designation') { foreach (($whoCat['designations'] ?? []) as $d) { if (! is_array($d)) { continue; } $id = (string) ($d['id'] ?? ''); if ($id === '') { continue; } $options[$id] = (string) ($d['label'] ?? ('#'.$id)); } } elseif ($whoType === 'user') { foreach (($whoCat['users'] ?? []) as $u) { if (! is_array($u)) { continue; } $id = (string) ($u['id'] ?? ''); if ($id === '') { continue; } $options[$id] = (string) ($u['label'] ?? ('User #'.$id)); } } if ($whoValue !== '' && $whoType !== 'creator' && ! array_key_exists($whoValue, $options)) { $options[$whoValue] = $whoValue.' (saved)'; } @endphp @if ($whoType === 'creator') Form creator — no value @else @endif