@extends('layouts.portal') @section('title', 'Version #' . $version->version_number . ' - Will #' . $will->id) @section('page_title', 'Version #' . $version->version_number . ' Details') @section('page_subtitle', 'Will #' . $will->id . ' - ' . $will->client->full_name) @section('sidebar') @include('admin.partials.sidebar', ['active' => 'wills']) @endsection @section('content')

Version #{{ $version->version_number }} Details

Will ID: #{{ $will->id }} | {{ $will->client->full_name }} | {{ $version->getRoleLabel() }}

Back to Timeline

Version Number

{{ $version->version_number }}

Status

{{ ucfirst($version->status) }}

Role

{{ $version->getRoleLabel() }}

Payment Status at Change

Client Payment Status

{{ ucfirst($will->payment_status) }}

Updated By

@if($version->updatedByUser) {{ $version->updatedByUser->name }} @else System @endif

{{ $version->getRoleLabel() }}

Date & Time of Change

{{ $version->created_at->format('M d, Y') }}

{{ $version->created_at->format('g:i A') }}

@if($version->sections_json && count($version->sections_json) > 0)

Sections Updated

@foreach($version->sections_json as $section) {{ ucfirst(str_replace('_', ' ', $section)) }} @endforeach
@endif @if($version->changes_summary)

Changes Summary

{{ $version->changes_summary }}

@endif @php $allKeys = array_unique(array_merge( array_keys($version->previous_data ?? []), array_keys($version->new_data ?? []) )); $hasChanges = false; // Helper function to format display value function formatDisplayValue($value) { if (is_null($value)) { return 'Empty'; } if (is_bool($value)) { return $value ? 'Yes' : 'No'; } if (is_array($value)) { if (empty($value)) { return 'Empty'; } return '
' . htmlspecialchars(json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), ENT_QUOTES, 'UTF-8') . '
'; } if (is_object($value)) { return '
' . htmlspecialchars(json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), ENT_QUOTES, 'UTF-8') . '
'; } if (empty($value) && $value !== 0 && $value !== false) { return 'Empty'; } return htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); } @endphp @if(count($allKeys) > 0)

What Changed

@foreach($allKeys as $key) @php $prevValue = $version->previous_data[$key] ?? null; $newValue = $version->new_data[$key] ?? null; $hasChanged = $prevValue !== $newValue; if ($hasChanged) $hasChanges = true; @endphp

{{ ucfirst(str_replace(['_', 'liabilities'], [' ', 'Liabilities'], $key)) }}

@if($hasChanged) @if(is_array($prevValue) && is_array($newValue))

Before: {{ count($prevValue) }} item(s)

@if(count($prevValue) > 0)
@foreach($prevValue as $index => $item)
@if(is_array($item))

Item {{ $index + 1 }}

@foreach($item as $fieldName => $fieldValue)
{{ ucfirst(str_replace('_', ' ', $fieldName)) }}: @if(is_array($fieldValue)) Array ({{ count($fieldValue) }} items) @elseif(is_bool($fieldValue)) {{ $fieldValue ? 'Yes' : 'No' }} @elseif(empty($fieldValue) && $fieldValue !== 0 && $fieldValue !== false) — @else {{ $fieldValue }} @endif
@endforeach
@else {{ $item }} @endif
@endforeach
@else

No items

@endif

After: {{ count($newValue) }} item(s)

@if(count($newValue) > 0)
@foreach($newValue as $index => $item)
@if(is_array($item))

Item {{ $index + 1 }}

@foreach($item as $fieldName => $fieldValue)
{{ ucfirst(str_replace('_', ' ', $fieldName)) }}: @if(is_array($fieldValue)) Array ({{ count($fieldValue) }} items) @elseif(is_bool($fieldValue)) {{ $fieldValue ? 'Yes' : 'No' }} @elseif(empty($fieldValue) && $fieldValue !== 0 && $fieldValue !== false) — @else {{ $fieldValue }} @endif
@endforeach
@else {{ $item }} @endif
@endforeach
@else

No items

@endif
@else

Was

{!! formatDisplayValue($prevValue) !!}

Now

{!! formatDisplayValue($newValue) !!}
@endif @else

No change in this field

@endif
@endforeach
@endif
@endsection