'', 'filterType' => 'all', 'filterSource' => 'all', 'filterCollection' => '', 'viewMode' => 'grid', 'editingId' => null, 'editTitle' => '', 'editAltText' => '', 'editCollection' => '', 'showDetail' => false, // Upload 'uploads' => [], // External URL form 'showUrlModal' => false, 'urlInput' => '', 'urlType' => 'video', 'urlTitle' => '', 'urlCollection' => '', 'urlValidated' => null, ]); $media = computed( fn () => DisplayMedia::query() ->when($this->filterType !== 'all', fn ($q) => match ($this->filterType) { 'image' => $q->images(), 'video' => $q->videos(), default => $q, }) ->when($this->filterSource !== 'all', fn ($q) => match ($this->filterSource) { 'upload' => $q->uploads(), 'external' => $q->externals(), default => $q, }) ->when($this->filterCollection, fn ($q) => $q->inCollection($this->filterCollection)) ->when($this->search, fn ($q) => $q->search($this->search)) ->orderByDesc('created_at') ->paginate(48), ); $updatedSearch = fn () => $this->resetPage(); $updatedFilterType = fn () => $this->resetPage(); $updatedFilterSource = fn () => $this->resetPage(); $updatedFilterCollection = fn () => $this->resetPage(); $collections = computed(fn () => DisplayMedia::query() ->whereNotNull('collection') ->where('collection', '!=', '') ->distinct() ->pluck('collection') ->sort() ->values() ->toArray()); $stats = computed(fn () => [ 'total' => DisplayMedia::count(), 'images' => DisplayMedia::images()->count(), 'videos' => DisplayMedia::videos()->count(), 'uploads' => DisplayMedia::uploads()->count(), 'externals' => DisplayMedia::externals()->count(), ]); // ======================================== // FILE UPLOAD // ======================================== $handleUploads = function () { $this->validate([ 'uploads' => 'nullable|array|max:10', 'uploads.*' => 'file|mimes:jpeg,jpg,png,gif,webp,svg,mp4,webm,mov|max:204800', ]); $service = app(DisplayMediaService::class); $count = 0; foreach ($this->uploads as $file) { $service->storeUpload($file); $count++; } $this->uploads = []; if ($count > 0) { Flux::toast(variant: 'success', heading: 'Hochgeladen', text: "{$count} Datei(en) erfolgreich hochgeladen."); } }; // ======================================== // EXTERNAL URL // ======================================== $openUrlModal = function () { $this->urlInput = ''; $this->urlType = 'video'; $this->urlTitle = ''; $this->urlCollection = ''; $this->urlValidated = null; $this->showUrlModal = true; }; $validateUrl = function () { $this->validate(['urlInput' => 'required|url|max:2048']); $service = app(DisplayMediaService::class); $this->urlValidated = $service->validateExternalUrl($this->urlInput); }; $saveExternalUrl = function () { $this->validate([ 'urlInput' => 'required|url|max:2048', 'urlType' => 'required|in:image,video', 'urlTitle' => 'nullable|string|max:255', ]); $service = app(DisplayMediaService::class); $service->createFromUrl( url: $this->urlInput, type: $this->urlType, title: $this->urlTitle ?: null, collection: $this->urlCollection ?: null, ); $this->showUrlModal = false; Flux::toast(variant: 'success', heading: 'Externe URL angelegt', text: 'Das Medium wurde als externe Referenz gespeichert.'); }; // ======================================== // DETAIL / EDIT // ======================================== $startEdit = function (int $id) { $media = DisplayMedia::find($id); if (! $media) { return; } $this->editingId = $id; $this->editTitle = $media->title ?? ''; $this->editAltText = $media->alt_text ?? ''; $this->editCollection = $media->collection ?? ''; $this->showDetail = true; }; $saveEdit = function () { $media = DisplayMedia::find($this->editingId); if (! $media) { return; } $media->update([ 'title' => $this->editTitle ?: null, 'alt_text' => $this->editAltText ?: null, 'collection' => $this->editCollection ?: null, ]); Flux::toast(variant: 'success', heading: 'Gespeichert', text: 'Medien-Details wurden aktualisiert.'); }; $deleteMedia = function (int $id) { $media = DisplayMedia::find($id); if (! $media) { return; } $filename = $media->getDisplayName(); $service = app(DisplayMediaService::class); $service->delete($media); $this->editingId = null; $this->showDetail = false; Flux::toast(variant: 'success', heading: 'Gelöscht', text: $filename . ' wurde entfernt.'); }; $closeDetail = function () { $this->showDetail = false; $this->editingId = null; }; ?>
Display-Mediathek Bilder, Videos und externe URLs für Store Displays verwalten.
{{ $this->stats['images'] }} Bilder {{ $this->stats['videos'] }} Videos {{ $this->stats['externals'] }} Extern
{{-- Upload + External URL --}}
@if (isset($uploads) && count($uploads) > 0)
@foreach ($uploads as $index => $upload) @endforeach
{{ count($uploads) }} Datei(en) hochladen @endif
Externe URL anlegen
{{-- Filters --}}
Alle Typen Bilder Videos Alle Quellen Uploads Extern @if (! empty($this->collections)) Alle Sammlungen @foreach ($this->collections as $col) {{ $col }} @endforeach @endif
{{-- Media Grid / List + Detail --}}
@if ($viewMode === 'grid')
@forelse ($this->media as $item)
@php $thumbSrc = $item->getThumbnailUrl() ?? ($item->isImage() && $item->isExternal() ? $item->external_url : null); $videoFrameSrc = (! $thumbSrc && $item->isVideo() && $item->isUpload()) ? $item->getUrl() : null; @endphp
@if ($thumbSrc) {{ $item->alt_text ?? $item->filename }} @elseif ($videoFrameSrc) @elseif ($item->isVideo())
Video
@else
Link
@endif @if ($item->isVideo() && ($thumbSrc || $videoFrameSrc))
@endif
@if ($item->isVideo()) @elseif ($item->isExternal()) @else @endif

{{ $item->getDisplayName() }}

{{ $item->getHumanFileSize() }}

@if ($item->collection)
{{ $item->collection }}
@endif
@empty
Noch keine Medien vorhanden. Laden Sie Dateien hoch oder legen Sie externe URLs an.
@endforelse
@else {{-- List View --}}
@forelse ($this->media as $item) @empty @endforelse
Name Datum
@php $rowThumb = $item->getThumbnailUrl() ?? ($item->isImage() && $item->isExternal() ? $item->external_url : null); $rowVideoFrame = (! $rowThumb && $item->isVideo() && $item->isUpload()) ? $item->getUrl() : null; @endphp
@if ($rowThumb) @elseif ($rowVideoFrame) @elseif ($item->isVideo()) @else @endif
{{ $item->getDisplayName() }} {{ $item->created_at->format('d.m.Y') }}
Noch keine Medien vorhanden.
@endif @if ($this->media->hasPages())
{{ $this->media->links() }}
@endif
{{-- Detail Sidebar --}} @if ($showDetail && $editingId) @php $editMedia = \App\Models\DisplayMedia::find($editingId); @endphp @if ($editMedia)
Details
{{-- Preview --}}
@if ($editMedia->isImage()) {{ $editMedia->filename }} @elseif ($editMedia->isVideo() && $editMedia->isUpload()) @elseif ($editMedia->isExternal())
Externe Ressource (Vorschau nicht einbettbar)
@endif
{{-- Metadata --}}

Datei: {{ $editMedia->filename }}

Typ: {{ $editMedia->isVideo() ? 'Video' : 'Bild' }}

Quelle: {{ $editMedia->isExternal() ? 'Extern' : 'Upload' }}

@if ($editMedia->isUpload())

Größe: {{ $editMedia->getHumanFileSize() }}

@if ($editMedia->mime_type)

MIME: {{ $editMedia->mime_type }}

@endif @if ($editMedia->metadata && isset($editMedia->metadata['width']))

Abmessungen: {{ $editMedia->metadata['width'] }}×{{ $editMedia->metadata['height'] }} px

@endif @endif

Angelegt: {{ $editMedia->created_at->format('d.m.Y H:i') }}

URL: {{ Str::limit($editMedia->getUrl(), 80) }}

{{-- Edit Form --}}
Speichern
Löschen
@endif @endif
{{-- External URL Modal --}}
Externe URL anlegen Binden Sie große Videos oder Medien von Google Drive, OneDrive oder anderen Quellen ein.
URL prüfen @if ($urlValidated === true) Erreichbar @elseif ($urlValidated === false) Nicht erreichbar – trotzdem speichern möglich @endif
Abbrechen Anlegen