@php use Filament\Actions\Action; use Illuminate\Support\Arr; $user = filament()->auth()->user(); $items = $this->getUserMenuItems(); $itemsBeforeAndAfterThemeSwitcher = collect($items) ->groupBy(fn (Action $item): bool => $item->getSort() < 0, preserveKeys: true) ->all(); $itemsBeforeThemeSwitcher = $itemsBeforeAndAfterThemeSwitcher[true] ?? collect(); $itemsAfterThemeSwitcher = $itemsBeforeAndAfterThemeSwitcher[false] ?? collect(); $hasProfileHeader = $itemsBeforeThemeSwitcher->has('profile') && blank(($item = Arr::first($itemsBeforeThemeSwitcher))->getUrl()) && (! $item->hasAction()); if ($itemsBeforeThemeSwitcher->has('profile')) { $itemsBeforeThemeSwitcher = $itemsBeforeThemeSwitcher->prepend($itemsBeforeThemeSwitcher->pull('profile'), 'profile'); } @endphp {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\View\PanelsRenderHook::USER_MENU_BEFORE) }} @if ($hasProfileHeader) @php $item = $itemsBeforeThemeSwitcher['profile']; $itemColor = $item->getColor(); $itemIcon = $item->getIcon(); unset($itemsBeforeThemeSwitcher['profile']); @endphp {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\View\PanelsRenderHook::USER_MENU_PROFILE_BEFORE) }} {{ $item->getLabel() }} {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\View\PanelsRenderHook::USER_MENU_PROFILE_AFTER) }} @endif @if ($itemsBeforeThemeSwitcher->isNotEmpty()) @foreach ($itemsBeforeThemeSwitcher as $key => $item) @if ($key === 'profile') {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\View\PanelsRenderHook::USER_MENU_PROFILE_BEFORE) }} {{ $item }} {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\View\PanelsRenderHook::USER_MENU_PROFILE_AFTER) }} @else {{ $item }} @endif @endforeach @endif @if (filament()->hasDarkMode() && (! filament()->hasDarkModeForced())) @endif @if ($itemsAfterThemeSwitcher->isNotEmpty()) @foreach ($itemsAfterThemeSwitcher as $key => $item) @if ($key === 'profile') {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\View\PanelsRenderHook::USER_MENU_PROFILE_BEFORE) }} {{ $item }} {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\View\PanelsRenderHook::USER_MENU_PROFILE_AFTER) }} @else {{ $item }} @endif @endforeach @endif {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\View\PanelsRenderHook::USER_MENU_AFTER) }}