@if($posts->isNotEmpty()) @foreach($posts as $post) @php // Find the translation for the current locale. $translation = $post->translations->firstWhere('locale', $locale); // If no translation is found for the current locale, use the fallback. if (!$translation) { $translation = $post->translations->firstWhere('locale', 'like', $fallbackLocale); } @endphp @if ($translation)
@if (isset($translation->title)) {{ $translation->title }} @endif @if (isset($translation->excerpt) && strlen(trim(strip_tags($translation->excerpt))) > 0) {{ $translation->excerpt }} @endif
@endif @endforeach @endif