'', '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; }; ?>
{{ $item->getDisplayName() }}
{{ $item->getHumanFileSize() }}
| Name | Typ | Quelle | Größe | Sammlung | 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)
|
{{ $item->getDisplayName() }} |
|
|
{{ $item->getHumanFileSize() }} |
@if ($item->collection)
|
{{ $item->created_at->format('d.m.Y') }} |
|
|
||||||
Datei: {{ $editMedia->filename }}
Typ:
Quelle:
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 @endifAngelegt: {{ $editMedia->created_at->format('d.m.Y H:i') }}