@endauth
{{ $sale_page->title }}
{{ $sale_page->description }}
{{-- Gallery --}}
@if ($image_count > 0)
@endif
@if ($videos)
{{-- Helper: server-side Vimeo aspect detection (cached) --}}
@php
if (!function_exists('vimeo_aspect_ratio')) {
function vimeo_aspect_ratio(string $videoId, ?string $videoHash = null): string
{
$cacheKey = 'vimeo_oembed_ar_' . $videoId . '_' . ($videoHash ?? 'nohash');
return cache()->remember($cacheKey, 86400, function () use (
$videoId,
$videoHash,
) {
try {
// Use the exact player URL (hash-aware) for oEmbed
$playerUrl =
'https://player.vimeo.com/video/' .
$videoId .
($videoHash ? '?h=' . $videoHash : '');
$oembedUrl =
'https://vimeo.com/api/oembed.json?url=' .
urlencode($playerUrl);
$resp = \Illuminate\Support\Facades\Http::timeout(5)
->retry(2, 100)
->get($oembedUrl);
if ($resp->ok()) {
$data = $resp->json();
if (!empty($data['width']) && !empty($data['height'])) {
return $data['height'] > $data['width'] ? '9/16' : '16/9';
}
}
} catch (\Throwable $e) {
// swallow and fall back
}
return '16/9'; // safe default
});
}
}
@endphp
{{-- Slides --}}
@foreach ($videos as $index => $video)
@php
$videoUrl = $video->video_link;
$videoId = null;
$videoHash = null;
$isVimeo = false;
$isShorts = false;
$aspectRatio = '16/9'; // default
$maxWidth = '800px'; // default
// --- YouTube detections ---
if (
preg_match(
'#(?:https?://)?(?:www\.)?youtube\.com/watch\?v=([a-zA-Z0-9_-]+)#',
$videoUrl,
$m,
)
) {
$videoId = $m[1];
} elseif (
preg_match(
'#(?:https?://)?(?:www\.)?youtube\.com/shorts/([a-zA-Z0-9_-]{11})#',
$videoUrl,
$m,
)
) {
$videoId = $m[1];
$isShorts = true;
} elseif (
preg_match(
'#(?:https?://)?(?:www\.)?youtu\.be/([a-zA-Z0-9_-]+)#',
$videoUrl,
$m,
)
) {
$videoId = $m[1];
} elseif (
preg_match(
'#(?:https?://)?(?:www\.)?m\.youtube\.com/v/([a-zA-Z0-9_-]+)#',
$videoUrl,
$m,
)
) {
$videoId = $m[1];
}
// --- Vimeo detection ---
elseif (
preg_match('#vimeo\.com/([0-9]+)(?:/([a-zA-Z0-9]+))?#', $videoUrl, $m)
) {
$videoId = $m[1];
$isVimeo = true;
// hash from /{videoId}/{hash}
if (!empty($m[2])) {
$videoHash = $m[2];
}
// also check for ?h= param
$query = parse_url($videoUrl, PHP_URL_QUERY);
if ($query) {
parse_str($query, $params);
if (!empty($params['h'])) {
$videoHash = $params['h'];
}
}
// server-side aspect detection via oEmbed (cached)
$aspectRatio = vimeo_aspect_ratio($videoId, $videoHash);
}
// Decide max width
if ($isVimeo && $aspectRatio === '9/16') {
$maxWidth = '450px';
} elseif ($isShorts) {
$aspectRatio = '9/16';
$maxWidth = '450px';
}
@endphp
@if ($isVimeo)
@else
@endif
{{ $video->product_name }}
Price: {{ $video->price }} | Stock: {{ $video->stock }}
{{ $video->description }}
@endforeach
@endif
{{-- Direction Links --}}
@if (in_array($user['user_type'], ['Basic', 'Gold', 'Platinum', 'Influencer', 'Sponsored']))
@if ($directions)
Driving Directions
@foreach ($directions as $direction)
@if ($direction['type'] == 'google_map')
@elseif($direction['type'] == 'apple_map')
@elseif($direction['type'] == 'waze')
@endif
@endforeach
@endif
@endif
{{-- @if ($payments)
Payment links
@foreach ($payments as $payment)
@if ($payment['type'] === 'credit')
@elseif($payment['type'] == 'zelle')
@elseif($payment['type'] == 'apple_pay')
@elseif($payment['type'] == 'venmo')
@elseif($payment['type'] == 'cashapp')
@elseif($payment['type'] == 'paypal_email')
@elseif($payment['type'] == 'paypal_link')
@endif
@endforeach
@endif --}}
{{-- @push('scripts')
@endpush --}}
@if ($ads_bottom->count() > 0)
@if ($ad_banner_w && $ad_banner_h)
@endif
@push('scripts')
@endpush
@endif