@extends('layouts.portal') @php $trustCreatorDetails = is_string($trust->trust_creator) ? json_decode($trust->trust_creator, true) ?? [] : ($trust->trust_creator ?? []); $trustCreatorName = $trustCreatorDetails['full_name'] ?? $trustCreatorDetails['name'] ?? $trust->client->full_name ?? '_________________________'; $trustCreatorIC = $trustCreatorDetails['ic'] ?? $trustCreatorDetails['ic_number'] ?? $trust->client->ic_number ?? '_________________________'; $trustCreatorAddress = $trustCreatorDetails['address'] ?? $trust->client->address ?? '_________________________'; $trustees = $trust->trustees->map(fn($t) => ['full_name' => $t->full_name, 'ic' => $t->ic_or_reg_no, 'address' => $t->address, 'phone' => $t->phone])->toArray(); if (empty($trustees)) $trustees = is_string($trust->administrators_details ?? '') ? json_decode($trust->administrators_details, true) ?? [] : ($trust->administrators_details ?? []); $beneficiaries = $trust->beneficiaries->map(fn($b) => [ 'full_name' => $b->full_name, 'type' => $b->beneficiary_type, 'ic' => $b->ic_or_reg_no, 'phone' => $b->phone, 'email' => $b->email, 'address' => $b->address, 'dob' => $b->dob, 'registration_since' => $b->registration_since, 'gender' => $b->gender, 'business_nature' => $b->business_nature, 'nationality' => $b->nationality, 'contact_person_name' => $b->contact_person_name, ])->toArray(); if (empty($beneficiaries)) $beneficiaries = is_string($trust->beneficiaries_details ?? '') ? json_decode($trust->beneficiaries_details, true) ?? [] : ($trust->beneficiaries_details ?? []); $assets = $trust->assets->map(fn($a) => [ 'description' => $a->description, 'category' => $a->asset_category, 'value' => $a->current_value, 'type' => $a->asset_type, 'account_no' => $a->account_or_registration_no, 'address' => $a->address, 'transfer_timing' => $a->transfer_timing, 'transfer_conditions' => $a->transfer_conditions, ])->toArray(); if (empty($assets)) $assets = is_string($trust->assets_details ?? '') ? json_decode($trust->assets_details, true) ?? [] : ($trust->assets_details ?? []); $allowances = $trust->allowances->map(fn($a) => [ 'beneficiary' => $a->beneficiary ? $a->beneficiary->full_name : 'N/A', 'amount' => $a->amount, 'frequency' => $a->frequency, 'start_date' => $a->start_date, 'end_date' => $a->end_date, 'currency' => $a->currency, 'conditions' => $a->conditions, ])->toArray(); $gifts = $trust->gifts->map(fn($g) => ['description' => $g->description, 'value' => $g->value])->toArray(); $caretakers = $trust->caretakers->map(fn($c) => [ 'full_name' => $c->full_name, 'role' => $c->role ?? $c->caretaker_type, 'ic' => $c->ic_or_reg_no, 'phone' => $c->phone, 'email' => $c->email ?? '', 'address' => $c->address ?? '', 'dob' => $c->dob ?? '', 'registration_since' => $c->registration_since ?? '', 'gender' => $c->gender ?? '', 'business_nature' => $c->business_nature ?? '', 'nationality' => $c->nationality ?? '', 'contact_person_name' => $c->contact_person_name ?? '', ])->toArray(); $guardianAllowances = $trust->guardianAllowances->map(fn($ga) => ['name' => $ga->name, 'amount' => $ga->monthly_amount, 'frequency' => $ga->frequency, 'start_date' => $ga->start_date])->toArray(); $administratorAllowances = $trust->administratorAllowances->map(fn($aa) => ['name' => $aa->name, 'amount' => $aa->monthly_amount, 'frequency' => $aa->frequency])->toArray(); $donations = $trust->donations->map(fn($d) => ['organization' => $d->organization_name, 'amount' => $d->donation_amount, 'purpose' => $d->donation_purpose])->toArray(); $totalAssetValue = collect($assets)->sum('value'); $createdByDetails = $trust->createdBy; @endphp @section('title', 'View Trust Deed') @section('page_title', 'Trust Deed Document') @section('page_subtitle', 'Formal Trust Deed') @section('sidebar') @include('client.partials.sidebar', ['active' => 'trust']) @endsection @push('styles') @endpush @section('content')

Trust Deed Document #{{ $trust->id }}

{{ ucfirst(str_replace('_', ' ', $trust->status)) }}
{{ $trust->client ? $trust->client->first_name . ' ' . $trust->client->last_name : 'Unknown Client' }} {{ $trust->created_at->format('M d, Y') }}
Back
{{ $trust->status === 'draft' ? 'DRAFT' : 'FINAL' }}
{!! $renderedDocument !!}
@endsection