WSI StructureGroup Pro Home Evaluation Report
Professional inspection summary
@php $tenantLogoUrl = is_array($tenantLogo ?? null) ? ($tenantLogo['original'] ?? null) : null; @endphp Logo
@php $primaryCustomer = $customers->first(); $evaluatorNames = $inspectors->pluck('name')->filter()->implode(', '); $structureEvaluated = optional($property)->property_type ?? 'N/A'; $evaluationIteration = data_get($inspectionSchedule, 'evaluation_iteration') ?? 'Initial Assessment'; $generalDescription = data_get($inspectionSchedule, 'general_description') ?? 'N/A'; @endphp
Home Information
Homeowner Contact Name: {{ $primaryCustomer['name'] ?? 'N/A' }}
Address: {{ $propertyAddress ?: 'N/A' }}
Email address: {{ $primaryCustomer['email'] ?? 'N/A' }}
Contact Phone: {{ $primaryCustomer['phone'] ?? 'N/A' }}
Structure being evaluated: {{ $structureEvaluated }}
Evaluation Iteration: {{ $evaluationIteration }}
General description, initial: {{ $generalDescription }}
Evaluation Details
Eval Date: {{ $scheduledDateTime ?: 'N/A' }}
File Number: {{ $schedule->appointment_id ?? 'N/A' }}
Evaluator: {{ $evaluatorNames ?: 'N/A' }}
Overview
{!! $introduction->description ?? '' !!}
Inspection Sections
@if($sections->isEmpty())
No inspection answers available.
@else @foreach($sections as $section) @php $sectionQuestions = collect($questionsBySection->get($section->id, [])); $categoryGroups = $sectionQuestions->groupBy(function ($question) { return data_get($question, 'item_type.type_name', 'General'); }); @endphp

{{ $section->title }}

@forelse($categoryGroups as $categoryName => $groupQuestions)
{{ $categoryName }}
@php $groupQuestions = collect($groupQuestions)->sortBy(function ($question) { $categoryOrder = data_get($question, 'question_category.sort_order', 0); $questionOrder = data_get($question, 'question.sort_order', 0); return sprintf('%05d-%05d', $categoryOrder, $questionOrder); })->values(); @endphp @php // Group questions by question_id so same question with different sides/options are together $questionGroups = collect($groupQuestions)->groupBy(function ($q) { return $q['question_id'] ?? 'no_id_' . spl_object_id((object)$q); }); @endphp @foreach($questionGroups as $questionId => $variants) @php // Collect recommendations & comments across all variants (deduplicated) $groupedRecommendations = []; $groupedComments = []; $groupedMedia = []; foreach ($variants as $v) { if (!empty($v['recommendations'])) { foreach ($v['recommendations'] as $rec) { $recText = is_array($rec) ? ($rec['recommendation_text'] ?? ($rec['recommendation']['recomendation_text'] ?? '')) : ($rec->recommendation_text ?? ($rec->recommendation->recomendation_text ?? '')); if (!empty($recText) && !in_array($recText, $groupedRecommendations)) { $groupedRecommendations[] = $recText; } } } if (!empty($v['comments'])) { foreach ($v['comments'] as $comment) { $commentText = is_array($comment) ? ($comment['comment'] ?? '') : ($comment->comment ?? ''); if (!empty($commentText) && !in_array($commentText, $groupedComments)) { $groupedComments[] = $commentText; } } } if (!empty($v['media'])) { foreach ($v['media'] as $media) { $mediaId = is_array($media) ? ($media['id'] ?? null) : ($media->id ?? null); if ($mediaId && !isset($groupedMedia[$mediaId])) { $groupedMedia[$mediaId] = $media; } } } } $groupedMedia = array_values($groupedMedia); @endphp @foreach($variants as $inspectionQuestion) @php $optionTitle = $inspectionQuestion['option']['option_title'] ?? 'N/A'; $optionType = $inspectionQuestion['option']['option_type'] ?? null; $optionLower = strtolower($optionTitle); $isCompliance = $optionType !== null ? (int) $optionType === 1 : $optionLower === 'compliance'; $isNonCompliance = $optionType !== null ? (int) $optionType === 0 : $optionLower === 'non-compliance'; $sideNames = []; if (!empty($inspectionQuestion['side_ids'])) { foreach ($inspectionQuestion['side_ids'] as $sideId) { if (!empty($sideMap[$sideId])) { $sideNames[] = $sideMap[$sideId]; } } } @endphp @endforeach {{-- Show recommendations, special notes, then media once per question group --}} @if(!empty($groupedRecommendations)) @endif @if(!empty($groupedComments)) @endif @if(!empty($groupedMedia)) @endif @endforeach
Evaluation Item Option Category Status Cause
{{ $inspectionQuestion['question']['type_name'] ?? 'Question' }} @if(!empty($sideNames)) ({{ implode(', ', $sideNames) }}) @endif @if(!empty($inspectionQuestion['question_category_id']) && !empty($inspectionQuestion['question_category']['category_name'])) - {{ $inspectionQuestion['question_category']['category_name'] }} @endif {{ data_get($inspectionQuestion, 'option.option_category.category_name', 'N/A') }} @if($isNonCompliance) fail @elseif($isCompliance) pass @else - @endif {{ $optionTitle }}
Recommendations:
@foreach($groupedRecommendations as $recText)
{{ $recText }}
@endforeach
Special Notes:
@foreach($groupedComments as $noteText)
{{ $noteText }}
@endforeach
Media:
@foreach($groupedMedia as $media) @php $mediaArray = is_array($media) ? $media : (method_exists($media, 'toArray') ? $media->toArray() : []); $mediaType = $mediaArray['media_type'] ?? null; $mediaUrl = $mediaArray['file_url'] ?? null; $mediaCaption = $mediaArray['caption'] ?? ($mediaArray['file']['file_name'] ?? 'Media item'); @endphp @if($mediaType === 'image' && $mediaUrl) @else @endif @endforeach
Media image @if(!empty($mediaCaption))
{{ $mediaCaption }}
@endif
{{ $mediaCaption }}
@empty
No questions for this section.
@endforelse
@endforeach @endif @if(!empty($closingStatement?->description))

Closing Statement

{!! $closingStatement->description !!}
@endif
@if(empty($forPdf))
Send Report
@endif