@php
$hasSubComponents = $component->details->whereNotNull('sub_component')->count() > 0;
@endphp
@if(!$hasSubComponents && $component->details->whereNull('sub_component')->count() > 0)
Inspection Checklist
| Description |
Pre Condition |
Post Condition |
Priority |
Remarks |
Image |
@foreach($component->details->whereNull('sub_component') as $detail)
| {{ $detail->description ?? 'N/A' }} |
{{ $detail->pre_condition ?? 'N/A' }}
|
{{ $detail->post_condition ?? 'N/A' }}
|
{{ $detail->priority ?? 'N/A' }}
|
{{ $detail->remark ?: '—' }} |
@if($detail->hasMedia('component_images'))
Component Images
@foreach($detail->getMedia('component_images') as $media)
@if($media->getCustomProperty('component_id') == $detail->id)
@endif
@endforeach
@endif
|
@endforeach
@endif
@php
$subComponents = $component->details
->filter(function($item) {
return !empty($item->sub_component);
})
->groupBy('sub_component');
@endphp
@if($subComponents->count() > 0)
Sub-Components
@foreach($subComponents as $subName => $items)
| Description |
Pre Condition |
Post Condition |
Priority |
@foreach($items as $item)
| {{ $item->description }} |
{{ $item->pre_condition }}
|
{{ $item->post_condition }}
|
{{ $item->priority }}
|
@endforeach
@endforeach
@endif
@if($component->otherData->count() > 0)
Component Specifications
| Component |
Specification |
Value |
@foreach($component->otherData->groupBy('name_component') as $groupName => $items)
@php
// Calculate total rows needed for this component
$rowCount = 0;
foreach ($items as $item) {
$value = $item->value;
if (is_array($value)) {
$specData = $value;
} elseif (is_string($value)) {
$specData = json_decode($value, true) ?? ['value' => $value];
} elseif (is_object($value)) {
$specData = (array)$value;
} else {
$specData = ['value' => $value];
}
$specData = is_iterable($specData) ? $specData : ['value' => $specData];
$rowCount += count(array_filter($specData, function($v) {
return !empty($v) || $v === 0 || $v === '0';
}));
}
$isFirstRow = true;
@endphp
@foreach($items as $item)
@php
// Convert value to consistent array format
$value = $item->value;
if (is_array($value)) {
$specData = $value;
} elseif (is_string($value)) {
$specData = json_decode($value, true) ?? ['value' => $value];
} elseif (is_object($value)) {
$specData = (array)$value;
} else {
$specData = ['value' => $value];
}
// Ensure we have an iterable array
$specData = is_iterable($specData) ? $specData : ['value' => $specData];
@endphp
@foreach($specData as $key => $value)
@if(!empty($value) || $value === 0 || $value === '0')
@if($isFirstRow)
|
{{ $groupName }}
|
@php $isFirstRow = false; @endphp
@endif
@php
$fieldLabels = [
'construction' => 'Construction',
'diameter_length' => 'Diameter Length',
'date_installed' => 'Installation Date',
'first_layer_size' => 'First Layer Size',
'second_layer_size' => 'Second Layer Size',
];
$displayKey = is_int($key) ? 'value' : $key;
@endphp
{{ $fieldLabels[$displayKey] ?? ucwords(str_replace('_', ' ', $displayKey)) }}
|
@if($displayKey == 'date_installed')
{{ date('d M Y', strtotime($value)) }}
@elseif(is_numeric($value))
{{ number_format($value, 2) }}
@else
{{ $value }}
@endif
|
@endif
@endforeach
@endforeach
@endforeach
@endif
@if($component->otherDetails->count() > 0)
Additional Findings
| Description |
Condition |
Priority |
Remarks |
Value |
@foreach($component->otherDetails as $detail)
| {{ $detail->description ?? 'N/A' }} |
{{ $detail->condition ?? 'N/A' }}
|
{{ $detail->priority ?? 'N/A' }}
|
{{ $detail->remark ?: '—' }} |
{{ $detail->volt ?: '—' }} |
@endforeach
@endif