Update History
@php
$updates = [];
if($will->updated_at) {
$updates[] = [
'timestamp' => $will->updated_at,
'action' => 'Will Updated',
'description' => 'Will document was modified',
'changed_by' => 'Client',
'icon' => 'fa-file-alt',
'color' => 'blue'
];
}
if($client->familyMembers->count() > 0) {
foreach($client->familyMembers as $member) {
if($member->updated_at && $member->updated_at->greaterThan(now()->subDays(30))) {
$updates[] = [
'timestamp' => $member->updated_at,
'action' => 'Family Member Updated',
'description' => $member->full_name . ' (' . ucfirst($member->relationship) . ') information was updated',
'changed_by' => 'Client',
'icon' => 'fa-users',
'color' => 'green'
];
}
}
}
if($client->assets->count() > 0) {
foreach($client->assets as $asset) {
if($asset->updated_at && $asset->updated_at->greaterThan(now()->subDays(30))) {
$updates[] = [
'timestamp' => $asset->updated_at,
'action' => 'Asset Updated',
'description' => $asset->description . ' (RM ' . number_format($asset->value, 2) . ')',
'changed_by' => 'Client',
'icon' => 'fa-coins',
'color' => 'purple'
];
}
}
}
if($client->liabilities->count() > 0) {
foreach($client->liabilities as $liability) {
if($liability->updated_at && $liability->updated_at->greaterThan(now()->subDays(30))) {
$updates[] = [
'timestamp' => $liability->updated_at,
'action' => 'Liability Updated',
'description' => $liability->creditor . ' (RM ' . number_format($liability->amount, 2) . ')',
'changed_by' => 'Client',
'icon' => 'fa-credit-card',
'color' => 'red'
];
}
}
}
$updates[] = [
'timestamp' => $will->created_at,
'action' => 'Will Created',
'description' => 'Will document #' . $will->id . ' was created',
'changed_by' => 'System',
'icon' => 'fa-plus-circle',
'color' => 'gray'
];
usort($updates, function($a, $b) {
return $b['timestamp']->getTimestamp() - $a['timestamp']->getTimestamp();
});
@endphp
@if(count($updates) > 0)
@foreach($updates as $update)
{{ $update['action'] }}
{{ $update['description'] }}
{{ $update['timestamp']->format('M d, Y • H:i A') }}
{{ $update['changed_by'] }}
@endforeach
@else
@endif