- Event-Medien tragen Typ (image/video/audio), Dauer und Notiz; Videos bekommen ein Poster, Audio wird per ffmpeg nach AAC (audio/mp4) gewandelt, Originale werden mit Range-Unterstützung gestreamt. - Upload nimmt eine Notiz (caption) direkt mit, PATCH ändert sie später. - Neue Event-Felder: Zeitraum (end_date), Kategorie, Personen, Meilenstein. Regeln zentral in EventFields, damit CRUD und Sync gleich prüfen. - Titel darf leer sein: ein Event entsteht mit dem ersten Eintrag. - Artisan-Befehl media:transcode-voice-notes wandelt alte WebM/Ogg-Notizen, die Safari nicht abspielen kann. - Login-Throttling, Settings-Validierung, Sync-Fehlercodes ohne Rohtext. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
41 lines
1.6 KiB
PHP
41 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class EventMediaResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
$base = "/event-media/{$this->id}";
|
|
$hasThumbnail = is_string($this->thumbnail_path) && $this->thumbnail_path !== '';
|
|
$hasPreview = $hasThumbnail || (is_string($this->preview_path) && $this->preview_path !== '');
|
|
|
|
return [
|
|
'id' => (string) $this->id,
|
|
'uuid' => $this->uuid,
|
|
'type' => $this->type ?? 'image',
|
|
'collection' => $this->collection,
|
|
'name' => $this->name,
|
|
'caption' => $this->caption ?? '',
|
|
'mimeType' => $this->mime_type,
|
|
'size' => $this->size,
|
|
'durationMs' => $this->duration_ms,
|
|
'width' => $this->width,
|
|
'height' => $this->height,
|
|
'thumbnailWidth' => $this->thumbnail_width,
|
|
'thumbnailHeight' => $this->thumbnail_height,
|
|
'previewWidth' => $this->preview_width,
|
|
'previewHeight' => $this->preview_height,
|
|
// Audio has no image variants; a video without an extracted
|
|
// poster frame has none either. The client shows a placeholder.
|
|
'src' => $hasThumbnail ? "{$base}/thumb" : null,
|
|
'thumbnailUrl' => $hasThumbnail ? "{$base}/thumb" : null,
|
|
'previewUrl' => $hasPreview ? "{$base}/preview" : null,
|
|
'originalUrl' => "{$base}/original",
|
|
'createdAt' => $this->created_at->getTimestampMs(),
|
|
];
|
|
}
|
|
}
|