b2in/app/Models/Display.php
Kevin Adametz 6c6d683b9a Display CMS Optimierungen 29-05-2026
- Mediathek: Video-Vorschaubilder statt Icons (FFmpeg-Thumbnails + Backfill-Command), Kategorie "Sonstiges"
- B2in Media-Picker zeigt alle Medientypen, Typ wird automatisch erkannt; Thumbnail-Preview vor allen Medien-URL-Feldern
- B2in Marke/Footer: Footer ein/aus, Logo+Claim frei positionierbar (Ecken) mit Constraints, separate Anzeige-Schalter
- Angebote-Modul dynamisch: kein Slide-Typ mehr, einheitliches Detail-Layout mit ein-/ausblendbaren Bloecken, Logo/Brand pro Slide, Streichpreis-Option
- Player: leere Module stoppen Endlosschleife, dynamische Layout-Anpassung bei verstecktem Footer/Header
- Fix: Script-Ladereihenfolge (Livewire vor Flux), entfernte stale public/flux/flux.js, Modal-Crash beim Aktualisieren behoben

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-29 15:57:33 +00:00

83 lines
1.8 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Support\Str;
class Display extends Model
{
/** @use HasFactory<\Database\Factories\DisplayFactory> */
use HasFactory;
protected $fillable = [
'name',
'location',
'is_active',
'is_test',
'preview_token',
];
protected function casts(): array
{
return [
'is_active' => 'boolean',
'is_test' => 'boolean',
];
}
/**
* @return HasMany<DisplayPlaylist, $this>
*/
public function playlists(): HasMany
{
return $this->hasMany(DisplayPlaylist::class);
}
/**
* @return HasOne<DisplayPlaylist, $this>
*/
public function livePlaylist(): HasOne
{
return $this->hasOne(DisplayPlaylist::class)
->where('status', DisplayPlaylist::STATUS_PUBLISHED);
}
/**
* @return HasOne<DisplayPlaylist, $this>
*/
public function draftPlaylist(): HasOne
{
return $this->hasOne(DisplayPlaylist::class)
->where('status', DisplayPlaylist::STATUS_DRAFT);
}
public function ensurePreviewToken(): string
{
if (! $this->preview_token) {
$this->preview_token = Str::random(40);
$this->save();
}
return $this->preview_token;
}
public function rotatePreviewToken(): string
{
$this->preview_token = Str::random(40);
$this->save();
return $this->preview_token;
}
public function clearPreviewToken(): void
{
if ($this->preview_token !== null) {
$this->preview_token = null;
$this->save();
}
}
}