Untitled
unknown
plain_text
a month ago
2.2 kB
7
Indexable
@php // Retrieve free media posts associated with a specific update ID $freeMedia = DB::table('free_media_posts') ->leftJoin('media', 'free_media_posts.media_name', '=', 'media.file') ->where('free_media_posts.updates_id', $response->id) ->get(); @endphp @if ($freeMedia->isNotEmpty()) @foreach ($freeMedia as $media) @php // Determine the file path based on the file type if (Str::endsWith($media->media_name, ['.mp4', '.webm', '.ogg'])) { // For videos, generate a secure URL with a token and expiration time $expires = now()->addMinutes(60)->timestamp; // Token valid for 60 minutes $token = hash_hmac('sha256', "{$media->media_name}|{$expires}", config('app.key')); $filePath = url("video/{$token}/{$expires}/{$media->media_name}"); } else { // For images and other files, use the original file path $filePath = url("files/storage/{$response->id}/{$media->media_name}"); } @endphp @if (Str::endsWith($media->media_name, ['.mp4', '.webm', '.ogg'])) <!-- If the file is a video --> <a href="{{ $filePath }}" class="btn btn-secondary mt-2 glightbox" data-gallery="gallery-preview-{{ $response->id }}" data-type="video" > {{ __('Video sample 🎥') }} </a> @elseif (Str::endsWith($media->media_name, ['.jpg', '.png', '.jpeg', '.gif'])) <!-- If the file is an image --> <a href="{{ $filePath }}" class="btn btn-secondary mt-2 glightbox" data-gallery="gallery-preview-{{ $response->id }}" data-type="image" > {{ __('Sample image 🖼️') }} </a> @else <a href="{{ $filePath }}" class="btn btn-secondary mt-2 glightbox" data-gallery="gallery-preview-{{ $response->id }}" > {{ __('Sample file 📁') }} </a> @endif @endforeach @endif
Editor is loading...
Leave a Comment