@foreach($testimonial as $item)
@php
$videoUrl = trim($item->youtube_url ?? '');
$youtubeId = null;
$driveId = null;
if (!empty($videoUrl)) {
// YouTube extract
if (preg_match('~(?:youtube\.com/(?:watch\?v=|embed/)|youtu\.be/)([A-Za-z0-9_-]{11})~', $videoUrl, $matches)) {
$youtubeId = $matches[1];
}
// Google Drive extract (file/d/ID OR open?id=ID)
if (preg_match('~drive\.google\.com/(?:file/d/|open\?id=)([^/?&]+)~', $videoUrl, $matches)) {
$driveId = $matches[1];
}
// fallback (only ID pasted)
if (!$driveId && preg_match('~^[A-Za-z0-9_-]{20,}$~', $videoUrl)) {
$driveId = $videoUrl;
}
}
@endphp
{{-- VIDEO --}}
@if($item->type == 'video')
{{-- YouTube --}}
@if($youtubeId)
{{-- Google Drive --}}
@elseif($driveId)
{{-- Direct Video --}}
@elseif(!empty($videoUrl))
@endif
@endif
{{-- PHOTO --}}
@if($item->type == 'photo' && !empty($item->photo))
@endif
{{-- TITLE --}}
{{ $item->title }}
@endforeach