@extends('layouts.main') @once @push('stylesheets') @endpush @endonce @php function padCount($count) { return str_pad((string) $count, 2, '0', STR_PAD_LEFT); } $activeTab = request('tab') ?? 'personal'; // Tabs with static labels $tabs = [ 'personal' => ['label' => 'Personal Info'], 'relations' => ['label' => 'Relations'], 'profile' => ['label' => 'Profile'], 'roles' => ['label' => 'Roles: ' . padCount($user->roles->count())], 'projects_manager' => ['label' => 'Projects Manager: ' . padCount(count($managing_projects))], 'units' => ['label' => 'Units: ' . padCount($user->units->count())], 'microservices' => ['label' => 'M/S: ' . padCount($user->microservices->count())], 'signatures' => ['label' => 'Signatures: ' . padCount($user->personal_signatures->count())], 'on_behalves' => ['label' => 'On Behalves: ' . padCount($user->my_behalfees->count())], 'notifications' => ['label' => 'Notifications'], 'groups' => ['label' => 'GROUPS'], 'ldap_services' => ['label' => 'LDAP SERVICES'], 'protocol_units' => ['label' => 'PROTOCOL UNITS'], ]; // Conditionally insert 'contracts' after 'profile' if ($user->work_relation_id === 2) { $tabs = collect($tabs) ->slice(0, 3) ->put('contracts', ['label' => "Contracts:". padCount($contract_counter)]) ->merge(collect($tabs)->slice(3)) ->all(); } $basepath = 'management-users.partials.edit-'; $partials = collect($tabs)->mapWithKeys(fn($_, $key) => [$key => $basepath . str_replace('_', '-', $key)])->all(); $tabToShow = $partials[$activeTab] ?? $partials['personal']; @endphp @section('content')