@foreach($pages as $p)
@php
$pageSlug = $p->getTranslation('slug', $locale, false)
?: $p->getTranslation('slug', 'fr', false)
?: $p->getTranslation('slug', 'en', false);
$pageTitle = $p->getTranslation('titre', $locale, false)
?: $p->getTranslation('titre', 'fr', false)
?: $p->getTranslation('titre', 'en', false);
$isTrainingPage = in_array($pageSlug, ['nos-cycles-de-formation', 'Our-training-programs']);
$children = $p->children ?? collect();
@endphp
@if($isTrainingPage && $children->count())
@foreach($children as $child)
@php
$childSlug = $child->getTranslation('slug', $locale, false)
?: $child->getTranslation('slug', 'fr', false)
?: $child->getTranslation('slug', 'en', false);
$childTitle = $child->getTranslation('titre', $locale, false)
?: $child->getTranslation('titre', 'fr', false)
?: $child->getTranslation('titre', 'en', false);
@endphp
@if($childSlug)
{{ $childTitle }}
@endif
@endforeach
@elseif($pageSlug)
{{ $pageTitle }}
@endif
@endforeach