@php $contacts = $patient->contacts->sortByDesc('is_primary'); $canManage = auth()->user()->can('patients.edit'); $flags = [ 'is_primary' => ['label' => 'Primary', 'color' => 'blue'], 'is_next_of_kin' => ['label' => 'Next of kin', 'color' => 'indigo'], 'is_emergency_contact' => ['label' => 'Emergency', 'color' => 'rose'], 'is_guarantor' => ['label' => 'Guarantor', 'color' => 'teal'], ]; @endphp
@if ($contacts->isEmpty()) @if ($canManage) @endif @else

{{ $contacts->count() }} contact{{ $contacts->count() === 1 ? '' : 's' }} on file.

@if ($canManage) @endif
@foreach ($contacts as $contact)

{{ $contact->name }}

{{ $contact->relationship_label }}

@foreach ($flags as $column => $flag) @if ($contact->{$column}) @endif @endforeach
Phone
{{ $contact->phone ?: '—' }} @if ($contact->alt_phone) {{ $contact->alt_phone }} @endif
Email
{{ $contact->email ?: '—' }}
National ID
{{ $contact->national_id ?: '—' }}
Address
{{ $contact->address ?: '—' }}
@if ($contact->notes)

{{ $contact->notes }}

@endif @if ($canManage)
@csrf @method('DELETE')
@endif
@endforeach
@endif @if ($canManage) {{-- -------------------------------------------------------- add contact --}}
@csrf

Add contact

@foreach ($contacts as $contact)
@csrf @method('PUT')

Edit {{ $contact->name }}

@endforeach @endif