@php use Illuminate\Support\Carbon; $sharedView = $sharedView ?? false; $scanNotificationEnabled = $scanNotificationEnabled ?? true; $person = $profile['person'] ?? []; $medical = $profile['medical'] ?? null; $visible = $profile['visible'] ?? null; $visibleData = is_array($visible) ? $visible : null; $location = $profile['location'] ?? null; $images = collect($profile['images'] ?? []) ->filter(fn ($img) => is_array($img) && !empty($img['url'])) ->unique('url') ->values() ->all(); $personName = $person['name'] ?? __('public_profile_messages.people.fallback_name'); $title = $sharedView ? __('public_profile_messages.people.shared_title') : "{$personName} | " . __('public_profile_messages.people.title_suffix'); $mainImage = $images[0]['url'] ?? null; $lightboxImages = array_values(array_map( fn($img) => ['url' => $img['url'], 'alt' => $personName], $images )); $galleryPreviewImages = array_slice($images, 0, 5); $initial = strtoupper(substr($personName, 0, 1)); $createdAt = !empty($person['created_at']) ? Carbon::parse($person['created_at']) : null; $updatedAt = !empty($person['updated_at']) ? Carbon::parse($person['updated_at']) : null; $medicalUpdatedAt = is_array($medical) && !empty($medical['updated_at']) ? Carbon::parse($medical['updated_at']) : null; $birthday = !empty($person['birthday']) ? Carbon::parse($person['birthday']) : null; $ageLabel = null; $shareUrl = route('shared.show', ['code' => bin2hex("people:{$code}")]); $statusLabel = $scanNotificationEnabled ? __('public_profile_messages.status.protected') : __('public_profile_messages.status.shared'); $statusClass = ($scanNotificationEnabled || $sharedView) ? 'peopleprofile-status' : 'peopleprofile-status peopleprofile-status-muted'; $medicalUpdatedLabel = $medicalUpdatedAt ? strtoupper($medicalUpdatedAt->format('M Y')) : strtoupper(($updatedAt ?? now())->format('M Y')); $primaryContactPhone = $person['phone'] ?? null; $secondaryContactName = $person['secondary_contact_name'] ?? null; $secondaryContactPhone = $person['secondary_phone'] ?? null; $secondaryContactIsPrimary = ($person['is_primary'] ?? false) === true; $isVisible = fn (string $field) => $visibleData === null || !array_key_exists($field, $visibleData) || !empty($visibleData[$field]); $showCountry = $isVisible('country'); $showCity = $isVisible('city'); $showAddress = $isVisible('address'); $showSex = $isVisible('sex'); $showPhone = $isVisible('phone'); $showBirthday = $isVisible('birthday'); $showCareType = $isVisible('care_type'); $isLost = $visibleData !== null && ($visibleData['lost'] ?? false) === true; $primaryContactRelationship = $secondaryContactIsPrimary ? ($person['secondary_contact_relationship'] ?? null) : ($person['contact_relationship'] ?? null); $primaryContactPhone = $secondaryContactIsPrimary ? $secondaryContactPhone : ($showPhone ? $primaryContactPhone : null); $medicalData = is_array($medical) ? $medical : []; $conditions = collect(preg_split('/[\r\n,;]+/', (string) ($medicalData['conditions'] ?? ''))) ->map(fn ($item) => trim($item)) ->filter() ->values(); $medications = collect(preg_split('/[\r\n,;]+/', (string) ($medicalData['medicines'] ?? ''))) ->map(fn ($item) => trim($item)) ->filter() ->values(); $hasBlood = array_key_exists('blood', $medicalData) && trim((string) $medicalData['blood']) !== ''; $hasDonor = array_key_exists('donor', $medicalData) && $medicalData['donor'] !== null; $hasSex = $showSex && !empty($person['sex']); $hasMedicalStats = $hasBlood || $hasDonor || $hasSex; $hasMedicalProfileDetails = !empty($medicalData['allergies']) || !empty($medicalData['emergency']) || !empty($medicalData['indications']) || $conditions->isNotEmpty() || $medications->isNotEmpty() || $hasMedicalStats; $hasLocationDetails = ($showCity && !empty($person['city'])) || ($showAddress && !empty($person['address'])) || ($showCareType && !empty($person['care_type'])) || ($location && !empty($location['location'])); $hasPrimaryContactDetails = !empty($primaryContactRelationship) || !empty($primaryContactPhone) || ! $sharedView; $hasSecondaryContactDetails = ! $secondaryContactIsPrimary && (!empty($secondaryContactName) || !empty($secondaryContactPhone) || !empty($person['secondary_contact_relationship'])); $activityLog = []; if ($birthday) { $ageInterval = $birthday->diff(now()); $years = $ageInterval->y; $months = $ageInterval->m; $ageParts = []; if ($years > 0) { $ageParts[] = trans_choice('public_profile_messages.time.years', $years, ['count' => $years]); } if ($months > 0) { $ageParts[] = trans_choice('public_profile_messages.time.months', $months, ['count' => $months]); } if ($ageParts === []) { $ageParts[] = __('public_profile_messages.time.under_one_month'); } $ageLabel = implode(' ', $ageParts); } if ($createdAt) { $activityLog[] = [ 'title' => __('public_profile_messages.activity.title_created'), 'subtitle' => $createdAt->diffForHumans() . ' • ' . __('public_profile_messages.activity.public_profile_active'), ]; } if ($updatedAt && (!$createdAt || !$updatedAt->equalTo($createdAt))) { $activityLog[] = [ 'title' => __('public_profile_messages.activity.title_updated'), 'subtitle' => $updatedAt->diffForHumans() . ' • ' . __('public_profile_messages.activity.information_reviewed'), ]; } if ($medicalUpdatedAt) { $activityLog[] = [ 'title' => __('public_profile_messages.activity.title_medical_updated'), 'subtitle' => $medicalUpdatedAt->diffForHumans() . ' • ' . __('public_profile_messages.activity.medical_data_refreshed'), ]; } if (empty($activityLog)) { $activityLog[] = [ 'title' => __('public_profile_messages.activity.title_public_id_active'), 'subtitle' => $sharedView ? __('public_profile_messages.activity.public_profile_active') . ' • ' . __('public_profile_messages.activity.ready_to_share') : __('public_profile_messages.activity.identifier_ready', ['identifier' => $code]), ]; } @endphp @extends('layouts.app') @section('title', $title) @push('styles') @include('partials.public-profile.people.styles') @endpush @section('content') @include('partials.public-profile.people.content') @endsection @include('partials.public-profile.people.script-stack')