@php use App\Http\Services\TalentBank\CandidateService; use App\Http\Services\TalentBank\CompanyService; use App\Models\TalentBank\Candidate; use App\Models\TalentBank\Company; use App\Support\SsoWebSession; $payload = session('sso.user_payload'); $requestUserPayload = request()->get('user'); $talentBankUser = request()->get('talentBankUser'); $ssoName = is_array($payload) ? ($payload['data']['name'] ?? null) : null; $requestUserName = is_array($requestUserPayload) ? data_get($requestUserPayload, 'data.name') : null; $modelUserName = is_object($talentBankUser) ? ($talentBankUser->name ?? $talentBankUser->trading_name ?? null) : null; $displayName = $ssoName ?: $requestUserName ?: $modelUserName ?: __('Minha conta'); $ssoDoc = is_array($payload) ? ($payload['data']['document'] ?? '') : ''; $docDigits = preg_replace('/\D/', '', (string) $ssoDoc); $isCompany = strlen($docDigits) >= 14; $perms = is_array($payload) ? ($payload['data']['permissions']['siati'] ?? []) : []; $canAdmin = is_array($perms) && (in_array('gestao-de-usuarios', $perms, true) || in_array('talent-bank-admin', $perms, true)); $hasSsoSession = SsoWebSession::hasToken(); $candidatePhotoPath = is_object($talentBankUser) ? ($talentBankUser->photo_path ?? null) : null; $companyLogoPath = is_object($talentBankUser) ? ($talentBankUser->logo ?? null) : null; $sessionPhotoPath = session('sso.profile_photo_path'); if ($hasSsoSession && $docDigits !== '' && ! ($talentBankUser instanceof Candidate || $talentBankUser instanceof Company)) { $talentBankUser = $isCompany ? Company::query()->where('cnpj', $docDigits)->first() : Candidate::query()->where('cpf', $docDigits)->first(); } $notificationRecipientType = null; if ($talentBankUser instanceof Company) { $notificationRecipientType = 'company'; } elseif ($talentBankUser instanceof Candidate) { $notificationRecipientType = 'candidate'; } if (! is_string($candidatePhotoPath) || trim($candidatePhotoPath) === '') { if (is_string($sessionPhotoPath) && trim($sessionPhotoPath) !== '') { $candidatePhotoPath = $sessionPhotoPath; } elseif ($hasSsoSession && $docDigits !== '') { if ($isCompany) { $companyFromDocument = $talentBankUser instanceof Company ? $talentBankUser : Company::query() ->select(['id', 'logo']) ->where('cnpj', $docDigits) ->first(); if ($companyFromDocument) { $companyLogoPath = $companyFromDocument->logo; } } else { $candidateFromDocument = $talentBankUser instanceof Candidate ? $talentBankUser : Candidate::query() ->select(['id', 'photo_path']) ->where('cpf', $docDigits) ->first(); if ($candidateFromDocument) { $candidatePhotoPath = $candidateFromDocument->photo_path; } } } } $profilePhotoUrl = null; if (is_string($candidatePhotoPath) && trim($candidatePhotoPath) !== '') { $profilePhotoUrl = CandidateService::photoPublicUrl($candidatePhotoPath); } elseif (is_string($companyLogoPath) && trim($companyLogoPath) !== '') { $profilePhotoUrl = CompanyService::logoPublicUrl($companyLogoPath); } @endphp @if ($hasSsoSession) @if ($notificationRecipientType) @include('components.notifications-bell', ['recipientType' => $notificationRecipientType]) @endif @if ($profilePhotoUrl) @else {{ strtoupper(\Illuminate\Support\Str::substr($displayName, 0, 1)) }} @endif {{ $displayName }} Logado como {{ $isCompany ? 'Empresa' : 'Candidato' }} @if ($canAdmin) Admin BT @endif @if ($isCompany) Área da empresa Notificações @else Meu perfil Meu currículo Notificações @endif Sair @endif routeIs('home')) aria-current="page" @endif> HOME routeIs('sobre')) aria-current="page" @endif> SOBRE routeIs('vagas')) aria-current="page" @endif> VAGAS routeIs('empresas')) aria-current="page" @endif> EMPRESAS routeIs('fale-conosco')) aria-current="page" @endif> FALE CONOSCO @unless ($hasSsoSession) {{ __('Acessar com a Conta Angra') }} @endunless