thats-me/backend/app/Models/Event.php
Kevin Adametz b262a6771f Backend: Medien-Typen, Sprachnotizen, Event-Felder und Sync-Härtung
- 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>
2026-09-25 07:00:35 +00:00

56 lines
1.4 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\Database\Eloquent\Relations\HasMany;
class Event extends Model
{
/** @use HasFactory<\Database\Factories\EventFactory> */
use HasFactory;
protected $fillable = [
'client_id',
'title',
'date',
'end_date',
'location',
'category',
'people',
'emotion',
'milestone',
'custom_color',
'gradient_preset',
'image',
'key_image_title',
'note',
];
protected function casts(): array
{
return [
// `date` is a pure calendar date and is deliberately NOT cast to a
// Carbon instance: a casted value is bound into cursor-pagination
// queries as "Y-m-d H:i:s", which never matches the "Y-m-d" the
// DATE column holds, and it drags a timezone into a value that has
// none. It stays the raw "Y-m-d" string.
'emotion' => 'decimal:3',
'gradient_preset' => 'integer',
'people' => 'array',
'milestone' => 'boolean',
];
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function media(): HasMany
{
return $this->hasMany(EventMedia::class);
}
}