View
@if($item->hasAnyRole(['patient', 'employee', 'agent']))
Edit
@php
$canImpersonate = false;
$currentUser = Auth::user();
// Staff can only impersonate patients, employees, and agents
if ($currentUser->hasRole('staff') && $item->hasAnyRole(['patient', 'employee', 'agent'])) {
$canImpersonate = true;
}
// Cannot impersonate yourself
if ($currentUser->id === $item->id) {
$canImpersonate = false;
}
@endphp
@if ($canImpersonate)
@endif
@endif