@php
$contents = collect()
->merge($article->textContent)
->merge($article->images)
->merge($article->galleries)
->merge($article->videos)
->merge($article->buttons)
->merge($article->accordions)
->sortBy('order');
@endphp
@foreach ($contents as $content)
{{-- CONTENTS--}}
@php
$editRoutes = [
'TextContent' => 'filament.admin.resources.text-content.edit',
'Image' => 'filament.admin.resources.images.edit',
'Gallery' => 'filament.admin.resources.galleries.edit',
'Video' => 'filament.admin.resources.videos.edit',
'Button' => 'filament.admin.resources.buttons.edit',
'Accordion' => 'filament.admin.resources.accordions.edit',
];
$model = class_basename($content);
@endphp
@if(isset($editRoutes[$model]))
@php
$model = class_basename($content);
$returnUrl = request()->fullUrl();
@endphp
@endif
{{ class_basename($content) }}
{{ $content->title ?? '[No Title]' }}
Order: {{ $content->order }}
{{-- Optional: preview/summary --}}
@if ($content instanceof \App\Models\TextContent)
{!! \Illuminate\Support\Str::limit(strip_tags($content->content), 60) !!}
@elseif ($content instanceof \App\Models\Image)
@if (!empty($content->original_path))
 }})
@else
No image uploaded
@endif
@elseif ($content instanceof \App\Models\Gallery)
Gallery: {{ $content->title }} ({{ $content->images->count() }} images)
@elseif ($content instanceof \App\Models\Video)
@php
$platform = $content->platform ?? 'youtube';
$rawUrl = $content->embed_url ?? '';
$embedUrl = null;
if ($platform === 'youtube') {
if (preg_match('/(?:youtu\.be\/|youtube\.com\/watch\?v=|youtube\.com\/embed\/)([A-Za-z0-9_\-]{11})/', $rawUrl, $matches)) {
$embedUrl = 'https://www.youtube.com/embed/' . $matches[1];
}
}
if ($platform === 'vimeo') {
if (preg_match('/vimeo\.com\/(\d+)/', $rawUrl, $matches)) {
$embedUrl = 'https://player.vimeo.com/video/' . $matches[1];
} elseif (preg_match('/player\.vimeo\.com\/video\/(\d+)/', $rawUrl, $matches)) {
$embedUrl = $rawUrl;
}
}
@endphp
Video: {{ $content->title }} ({{ $content->platform }})
@if ($embedUrl)
@else
Invalid video link
@endif
@elseif ($content instanceof \App\Models\Button)
Button: {{ $content->text }} → {{ $content->url }}
@elseif ($content instanceof \App\Models\Accordion)
Accordion: {{ $content->title }}
@endif
@endforeach