@php // Cross-page section navigation for the People workspace. Each tab is a real // route (its own full-page Livewire component); wire:navigate gives the // instant, tabbed-workspace feel. Mirrors . // // Permission-gating matches the sidebar: a tab the current user cannot reach // is hidden rather than 403'ing when clicked. Everyone keeps "My Pay" and // "Attendance"; the latter scopes itself — you see your own clock, and the // team tabs inside it appear only for whoever may read them. $user = Auth::user(); $team = $user?->currentTeam; $allows = fn (string $perm): bool => (bool) ($team && $user->hasTeamPermission($team, $perm)); $access = \App\Support\PeopleAccess::class; $tabs = array_values(array_filter([ [ // Always present: everyone owns their own personal details. 'route' => 'my-details', 'pattern' => 'my-details', 'label' => __('My Details'), 'icon' => 'user-circle', 'show' => (bool) $user, ], [ 'route' => 'employees.index', 'pattern' => 'employees.*', 'label' => __('Employees'), 'icon' => 'identification', 'show' => $access::canViewDirectory($user, $team), ], [ 'route' => 'attendance.index', 'pattern' => 'attendance.*', 'label' => __('Attendance'), 'icon' => 'clock', 'show' => $allows('attendance.read'), ], [ 'route' => 'hr.index', 'pattern' => 'hr.*', 'label' => __('HR Desk'), 'icon' => 'briefcase', // The desk is decisions-only now (the clock moved to Attendance), // so a read-only HR seat has nothing to open here. 'show' => $access::canManageHr($user, $team) || $access::canManageHrSettings($user, $team), ], [ // "Payroll" is a job you do; "My Pay" is a page you read. Which one // this is depends entirely on who is looking. 'route' => 'payroll.index', 'pattern' => 'payroll.*', 'label' => $access::canManagePay($user, $team) ? __('Payroll') : __('My Pay'), 'icon' => 'banknotes', 'show' => $allows('payroll.read') || $allows('commissions.read'), ], [ 'route' => 'loans.index', 'pattern' => 'loans.*', 'label' => __('Loans'), 'icon' => 'credit-card', 'show' => $allows('loans.read') || $allows('loans.apply'), ], ], fn ($t) => $t['show'])); @endphp @if (count($tabs) > 1)
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'] }} @endforeach
@endif