@php
// Función para convertir enlaces a formato embebido
function convertirLinkVideo($link)
{
if (empty($link)) {
return false;
}
if (strpos($link, 'youtube.com') !== false || strpos($link, 'youtu.be') !== false) {
parse_str(parse_url($link, PHP_URL_QUERY), $query);
$videoId = $query['v'] ?? null;
if (!$videoId && strpos($link, 'youtu.be') !== false) {
$videoId = basename(parse_url($link, PHP_URL_PATH));
}
return $videoId ? "https://www.youtube.com/embed/{$videoId}" : false;
}
if (strpos($link, 'drive.google.com') !== false) {
preg_match('/\/file\/d\/([a-zA-Z0-9_-]+)\//', $link, $matches);
return isset($matches[1]) ? "https://drive.google.com/file/d/{$matches[1]}/preview" : false;
}
return false;
}
$videoEmbedLink = convertirLinkVideo($data->INF_URL_VIDEO);
@endphp
@if ($videoEmbedLink)
@else
Formato de video no compatible o enlace inválido.
@endif