- 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>
70 lines
1.6 KiB
PHP
70 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Support\Str;
|
|
|
|
class EventMedia extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\EventMediaFactory> */
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'uuid',
|
|
'user_id',
|
|
'event_id',
|
|
'collection',
|
|
'type',
|
|
'name',
|
|
'caption',
|
|
'mime_type',
|
|
'disk',
|
|
'path',
|
|
'thumbnail_path',
|
|
'preview_path',
|
|
'size',
|
|
'duration_ms',
|
|
'width',
|
|
'height',
|
|
'thumbnail_width',
|
|
'thumbnail_height',
|
|
'preview_width',
|
|
'preview_height',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'size' => 'integer',
|
|
'duration_ms' => 'integer',
|
|
'width' => 'integer',
|
|
'height' => 'integer',
|
|
'thumbnail_width' => 'integer',
|
|
'thumbnail_height' => 'integer',
|
|
'preview_width' => 'integer',
|
|
'preview_height' => 'integer',
|
|
];
|
|
}
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::creating(function (EventMedia $media): void {
|
|
if (! $media->uuid) {
|
|
$media->uuid = (string) Str::uuid();
|
|
}
|
|
});
|
|
}
|
|
|
|
public function event(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Event::class);
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
}
|