@foreach($model->getSectionHistory() as $index => $section)
@php
$tabId = 'form-history-'.Str::slug($section->title);
$entries = collect();
// Entrada principal
$entries->push([
'type' => 'main',
'user' => $model->user()->first(),
'date' => $model->created_at,
'content' => $section->summary
]);
// Controles relacionados
foreach($controlHistories as $control) {
foreach($control->getControlSectionHistory() as $controlSection) {
if($section->section_type_id === $controlSection->section_type_id) {
$entries->push([
'type' => 'control',
'user' => $control->user()->first(),
'date' => $control->created_at,
'content' => $controlSection->summary,
'control_data' => $control
]);
}
}
}
@endphp
@foreach($entries as $entryIndex => $entry)
@php
$subTabId = Str::slug($section->title).'-'.Str::slug($entry['user']->name).'-'.$entryIndex;
@endphp
{{ __("detail-history.doctor") }} {{ $entry['user']->name }}
@if($entry['type'] === 'control')
{{ $especialities[$entry['control_data']->especiality] }}
@endif
@if($entry['type'] === 'control')
{{ __("com-form-history.idControl") }} {{ substr($entry['control_data']->id, -4) }}
@endif
{{ $entry['content'] }}
@endforeach
@endforeach