@php // Cross-page navigation for the two sides of the asset register: the list of // what the company owns, and the monthly walk that proves it is still there. // Mirrors : each tab is a real route with its own full-page // Livewire component, and wire:navigate gives it the feel of one workspace. // A tab the user cannot reach is hidden rather than 403'd, same as the sidebar. $user = Auth::user(); $team = $user?->currentTeam; $allows = fn (string $perm): bool => (bool) ($team && $user->hasTeamPermission($team, $perm)); // How many items on this month's sheet are still unanswered, for the badge. // Only shown to somebody who can actually do something about it, and only // while a count is genuinely outstanding. $outstanding = null; if ($team && $allows('assets.update')) { $due = app(App\Services\AssetCountDueService::class); $period = $due->outstandingPeriod($team); if ($period !== null) { $sheet = app(App\Services\AssetVerificationService::class)->find($team, $period); $outstanding = $sheet === null ? App\Models\Asset::query() ->where('team_id', $team->id) ->whereNotIn('status', App\Services\AssetVerificationService::EXCLUDED_STATUSES) ->count() : $sheet->lineCount() - $sheet->checkedCount(); } } $tabs = array_values(array_filter([ ['route' => 'assets.index', 'pattern' => 'assets.index', 'label' => __('Register'), 'icon' => 'wrench-screwdriver', 'badge' => null, 'show' => $allows('assets.read')], ['route' => 'assets.count', 'pattern' => 'assets.count', 'label' => __('Monthly count'), 'icon' => 'clipboard-document-check', 'badge' => $outstanding ?: null, 'show' => $allows('assets.read')], ], fn ($t) => $t['show'])); @endphp
merge(['class' => 'no-scrollbar flex items-center gap-1 overflow-x-auto rounded-2xl bg-slate-100/80 p-1 ring-1 ring-slate-200/70']) }}> @foreach ($tabs as $tab) @php $active = request()->routeIs($tab['pattern']); @endphp $active, 'text-slate-500 hover:bg-white/70 hover:text-slate-800' => ! $active, ]) @if ($active) aria-current="page" @endif > {{ $tab['label'] }} @if ($tab['badge']) {{ $tab['badge'] > 99 ? '99+' : $tab['badge'] }} @endif @endforeach