@if($sections->isEmpty()) @else @foreach($sections as $section) @php $sectionQuestions = $questionsBySection->get($section->id, collect()); $categoryGroups = $sectionQuestions->groupBy(function ($question) { return data_get($question, 'item_type.type_name', 'General'); }); @endphp @endforeach @endif @if(!empty($closingStatement?->description)) @endif
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
No inspection answers available.

{{ $section->title }}

@forelse($categoryGroups as $categoryName => $groupQuestions)
{{ $categoryName }}
@php $categoryComments = []; $categoryRecommendations = []; $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 @foreach($groupQuestions 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]; } } } $commentText = ''; if (!empty($inspectionQuestion['comments'])) { foreach ($inspectionQuestion['comments'] as $comment) { $commentText = is_array($comment) ? ($comment['comment'] ?? '') : ($comment->comment ?? ''); if (!empty($commentText)) { $categoryComments[] = [ 'question' => $inspectionQuestion['question']['type_name'] ?? 'Question', 'option_category' => data_get($inspectionQuestion, 'option.option_category.category_name', 'N/A'), 'text' => $commentText, ]; } } } if (!empty($inspectionQuestion['recommendations'])) { foreach ($inspectionQuestion['recommendations'] as $rec) { $recText = is_array($rec) ? ($rec['recommendation_text'] ?? ($rec['recommendation']['recomendation_text'] ?? '')) : ($rec->recommendation_text ?? ($rec->recommendation->recomendation_text ?? '')); if (!empty($recText)) { $categoryRecommendations[] = [ 'question' => $inspectionQuestion['question']['type_name'] ?? 'Question', 'option_category' => data_get($inspectionQuestion, 'option.option_category.category_name', 'N/A'), 'text' => $recText, ]; } } } @endphp @if(!empty($inspectionQuestion['media'])) @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) @elseif($isCompliance) @else @endif {{ $optionTitle }}
Media:
@foreach($inspectionQuestion['media'] 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)
Media image @if(!empty($mediaCaption))
{{ $mediaCaption }}
@endif
@else
{{ $mediaCaption }}
@endif @endforeach
@php $categoryComments = collect($categoryComments) ->filter() ->unique(function ($row) { return ($row['question'] ?? '') . '|' . ($row['option_category'] ?? '') . '|' . ($row['text'] ?? ''); }) ->values() ->all(); $categoryRecommendations = collect($categoryRecommendations) ->filter() ->unique(function ($row) { return ($row['question'] ?? '') . '|' . ($row['option_category'] ?? '') . '|' . ($row['text'] ?? ''); }) ->values() ->all(); @endphp @if(!empty($categoryRecommendations))
Recommendations
@foreach($categoryRecommendations as $recRow) @endforeach
Non Compliant Item Option Category Recommendation
{{ $recRow['question'] }} {{ $recRow['option_category'] }} {{ $recRow['text'] }}
@endif @if(!empty($categoryComments))
Special Notes
@foreach($categoryComments as $commentRow) @endforeach
Evaluation Item Option Category Comment
{{ $commentRow['question'] }} {{ $commentRow['option_category'] }} {{ $commentRow['text'] }}
@endif
@empty
No questions for this section.
@endforelse

Closing Statement

{!! $closingStatement->description !!}