@foreach ($components as $component) @php $type = $component['type'] ?? ''; @endphp @if($type === 'columns' && isset($component['columns']) && is_array($component['columns'])) {{-- Handle columns layout: each column has its own components --}} @foreach ($component['columns'] as $column) @if(isset($column['components']) && is_array($column['components'])) @include('backend.form_builder.pdf.components', ['components' => $column['components']]) @endif @endforeach @elseif($type === 'table' && isset($component['rows']) && is_array($component['rows'])) {{-- Handle table layout: rows > cells > components --}} @foreach ($component['rows'] as $row) @foreach ($row as $cell) @if(isset($cell['components']) && is_array($cell['components'])) @include('backend.form_builder.pdf.components', ['components' => $cell['components']]) @endif @endforeach @endforeach @elseif($type === 'container' && isset($component['components']) && is_array($component['components'])) {{-- Container: submission data is nested under the container key --}} @php $containerKey = $component['key'] ?? ''; $containerData = $submissionData[$containerKey] ?? []; @endphp @if(!empty($containerData) && is_array($containerData)) @include('backend.form_builder.pdf.components', [ 'components' => $component['components'], 'submissionData' => $containerData, ]) @endif @elseif($type === 'tabs' && isset($component['components']) && is_array($component['components'])) {{-- Tabs: each tab has its own components array --}} @foreach ($component['components'] as $tab) @if(isset($tab['components']) && is_array($tab['components'])) @include('backend.form_builder.pdf.components', ['components' => $tab['components']]) @endif @endforeach @elseif(isset($component['components']) && is_array($component['components'])) {{-- Recursively handle nested components (panels, fieldsets, wells, etc.) --}} @include('backend.form_builder.pdf.components', ['components' => $component['components']]) @else @php $key = $component['key'] ?? ''; $value = $submissionData[$key] ?? ''; $type = $component['type'] ?? ''; $label = $component['label'] ?? ucfirst($key); $isButton = $type === 'button'; @endphp @if (!empty($key) && isset($submissionData[$key]) && !$isButton)
| {{ $col['label'] ?? $col['key'] }} | @endforeach
|---|
| @if($colType === 'checkbox' || ($colType === 'select' && ($col['multiple'] ?? false))) @php $colValues = is_array($colVal) ? $colVal : [$colVal]; $colLabels = []; foreach ($colValues as $val) { $colLabels[] = Helper::getFormioLabelFromValue($val, $col); } echo implode(', ', $colLabels); @endphp @elseif($colType === 'selectboxes') @php $selectedCol = is_array($colVal) || is_object($colVal) ? array_keys(array_filter((array)$colVal)) : []; $colLabels = []; foreach ($selectedCol as $val) { $colLabels[] = Helper::getFormioLabelFromValue($val, $col); } echo implode(', ', $colLabels); @endphp @elseif($colType === 'textarea') {!! nl2br(e($colVal)) !!} @else {!! $colVal !!} @endif | @endforeach
| {{ $col['label'] ?? $col['key'] }} | @endforeach
|---|
|
@if($colType === 'checkbox' || ($colType === 'select' && ($col['multiple'] ?? false)))
@php
$colValues = is_array($colVal) ? $colVal : [$colVal];
$colLabels = [];
foreach ($colValues as $val) {
$colLabels[] = Helper::getFormioLabelFromValue($val, $col);
}
echo implode(', ', $colLabels);
@endphp
@elseif($colType === 'selectboxes')
@php
$selectedCol = is_array($colVal) || is_object($colVal)
? array_keys(array_filter((array)$colVal))
: [];
$colLabels = [];
foreach ($selectedCol as $val) {
$colLabels[] = Helper::getFormioLabelFromValue($val, $col);
}
echo implode(', ', $colLabels);
@endphp
@elseif($colType === 'textarea')
{!! nl2br(e($colVal)) !!}
@elseif($colType === 'file' && is_array($colVal))
@foreach ($colVal as $colFile)
{{ $colFile['name'] ?? 'File' }} @endforeach @else {!! is_array($colVal) ? e(json_encode($colVal)) : $colVal !!} @endif |
@endforeach