@php use Illuminate\Support\Carbon; $sharedView = $sharedView ?? false; $scanNotificationEnabled = $scanNotificationEnabled ?? true; $pet = $profile['pet'] ?? []; $medical = $profile['medical'] ?? null; $visible = $profile['visible'] ?? null; $visibleData = is_array($visible) ? $visible : null; $images = collect($profile['images'] ?? []) ->filter(fn ($img) => is_array($img) && !empty($img['url'])) ->unique('url') ->values() ->all(); $petName = $pet['name'] ?? __('public_profile_messages.pet.fallback_name'); $title = $sharedView ? __('public_profile_messages.pet.shared_title') : "{$petName} | " . __('public_profile_messages.pet.title_suffix'); $mainImage = $images[0]['url'] ?? null; $initial = strtoupper(substr($petName, 0, 1)); $birthdate = !empty($pet['birthdate']) ? Carbon::parse($pet['birthdate']) : null; $createdAt = !empty($pet['created_at']) ? Carbon::parse($pet['created_at']) : null; $updatedAt = !empty($pet['updated_at']) ? Carbon::parse($pet['updated_at']) : null; $medicalUpdatedAt = is_array($medical) && !empty($medical['updated_at']) ? Carbon::parse($medical['updated_at']) : null; $ageLabel = null; $shareUrl = route('shared.show', ['code' => bin2hex("pet:{$code}")]); $profileUrl = route('pet.show', ['code' => $code]); $lightboxImages = array_values(array_map( fn($img) => ['url' => $img['url'], 'alt' => $petName], $images )); $galleryPreviewImages = array_slice($images, 0, 5); $statusLabel = $scanNotificationEnabled ? __('public_profile_messages.status.protected') : __('public_profile_messages.status.shared'); $statusClass = $scanNotificationEnabled ? 'petrecovery-status' : 'petrecovery-status petrecovery-status-muted'; $medicalData = is_array($medical) ? $medical : []; $petSex = null; $isSterilized = null; $hasChip = null; $medicalUpdatedLabel = $medicalUpdatedAt ? strtoupper($medicalUpdatedAt->format('M Y')) : strtoupper(($updatedAt ?? now())->format('M Y')); $primaryContactName = collect([$pet['user_name'] ?? null, $pet['owner_name'] ?? null, $pet['primary_contact_name'] ?? null, $pet['responsible_name'] ?? null, $pet['contact_name'] ?? null, data_get($pet, 'user.name')])->first(fn ($name) => is_string($name) && trim($name) !== '') ?? __('public_profile_messages.pet.primary_contact'); $secondaryContactName = $pet['secondary_contact_name'] ?? null; $primaryContactPhone = $pet['phone'] ?? null; $secondaryContactPhone = $pet['secondary_phone'] ?? null; $isVisible = fn (string $field) => $visibleData === null || !array_key_exists($field, $visibleData) || !empty($visibleData[$field]); $showPhone = $isVisible('phone'); $showSecondaryPhone = $isVisible('secondary_phone'); $showSecondaryContactName = $isVisible('secondary_contact_name'); $showBirthdate = $isVisible('birthdate'); $showBreed = $isVisible('breed'); $showWeight = $isVisible('weight'); $showChipSerialNumber = $isVisible('chip_serial_number'); $primaryContactPhone = $showPhone ? $primaryContactPhone : null; $secondaryContactPhone = $showSecondaryPhone ? $secondaryContactPhone : null; $secondaryContactName = $showSecondaryContactName ? $secondaryContactName : null; $isLost = $visibleData !== null && ($visibleData['lost'] ?? false) === true; $hasBreed = $showBreed && !empty($pet['breed']); $hasAge = $showBirthdate && ($ageLabel !== null || $birthdate !== null); $vaccineItems = array_key_exists('vaccines', $medicalData) ? collect(preg_split('/\s*\|\s*/', (string) $medicalData['vaccines'], -1, PREG_SPLIT_NO_EMPTY)) ->map(fn ($vaccine) => trim($vaccine)) ->filter() ->values() ->all() : []; $hasVaccines = count($vaccineItems) > 0; $hasChipSerialNumber = $showChipSerialNumber && !empty($medicalData['chip_serial_number']); $hasPetSexStatus = (array_key_exists('sex', $medicalData) && $medicalData['sex'] !== null) || (array_key_exists('sterilized', $medicalData) && $medicalData['sterilized'] !== null); $hasPetMedicalDetails = !empty($medicalData['conditions']) || !empty($medicalData['medicines']) || $hasVaccines || $hasPetSexStatus || (array_key_exists('chip', $medicalData) && $medicalData['chip'] !== null) || $hasChipSerialNumber || ($showWeight && !empty($pet['weight'])); $activityLog = []; if ($birthdate) { $ageInterval = $birthdate->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 (array_key_exists('sex', $medicalData) && $medicalData['sex'] !== null) { $petSex = $medicalData['sex'] ? __('public_profile_messages.pet.male') : __('public_profile_messages.pet.female'); } if (array_key_exists('sterilized', $medicalData) && $medicalData['sterilized'] !== null) { $isSterilized = $medicalData['sterilized'] ? __('public_profile_messages.pet.neutered') : __('public_profile_messages.pet.not_sterilized'); } if (array_key_exists('chip', $medicalData) && $medicalData['chip'] !== null) { $hasChip = $medicalData['chip'] ? __('public_profile_messages.pet.registered') : __('public_profile_messages.common.no'); } 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.owner_information_reviewed'), ]; } if ($medicalUpdatedAt) { $activityLog[] = [ 'title' => __('public_profile_messages.activity.title_medical_updated'), 'subtitle' => $medicalUpdatedAt->diffForHumans() . ' • ' . __('public_profile_messages.activity.public_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.pet.styles') @endpush @section('content') @include('partials.public-profile.pet.content') @endsection @include('partials.public-profile.pet.script-stack')