Files
fewo-stommer/app/Models/Page.php
T
Lars StommerandClaude Opus 5.5 66e82d61f5 Theme-System mit Basis-Theme Ostsee-Licht, Bausteinen und saisonalen Erscheinungsbildern
- Sites (Domain, Theme, Farben; mehrfähig für weitere Vermieter), Seiten aus Bausteinen mit Menüs, Erscheinungsbilder mit jährlichem Zeitplan, Priorität und signierter Vorschau
- Theme-Kern (app/Themes): Manifest, Registry, Vererbung (Child-Themes), Token-Farben als CSS-Variablen, Bausteinkatalog als Registry (config/themes.php)
- 15 Bausteine: Titelbereich mit Suche, Eckdaten, Text mit Bildern, Galerie, Ausstattung, Lage, Preise, Angebote, Kalender & Anfrage, Bewertungen, Gastgeber, FAQ, Abschluss, Kontakt, Fließtext
- Theme Ostsee-Licht: Layout, Kopf/Fuß, Banner, mobile Buchungsleiste, Lightbox, selbst gehostete Schriften, Reduced Motion
- Seiten Start, Wohnung, Kühlungsborn, Preise & Buchung, Kontakt, Impressum, Datenschutz; Sitemap, robots.txt, JSON-LD
- Admin: Seiten-Baukasten, Erscheinungsbilder, Websites
- Dokumentation docs/THEMES.md inkl. Übergabe für die Design-Sitzung

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 15:04:21 +02:00

63 lines
1.6 KiB
PHP

<?php
namespace App\Models;
use Database\Factories\PageFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* A page of a site, composed of sections from the catalogue (App\Themes\Sections).
* sections = list of {type: string, data: array} as stored by the Filament builder.
* The home page has the slug "start" and is served at "/".
*/
#[Fillable(['site_id', 'slug', 'title', 'menu_label', 'menu_location', 'sort_order', 'is_published', 'sections', 'seo_title', 'seo_description'])]
class Page extends Model
{
/** @use HasFactory<PageFactory> */
use HasFactory;
public const HOME = 'start';
/** Menu locations a page can appear in. */
public const MENU_LOCATIONS = ['main' => 'Hauptmenü', 'footer' => 'Fußzeile', 'none' => 'Nicht im Menü'];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'is_published' => 'boolean',
'sections' => 'array',
];
}
/**
* @return BelongsTo<Site, $this>
*/
public function site(): BelongsTo
{
return $this->belongsTo(Site::class);
}
public function isHome(): bool
{
return $this->slug === self::HOME;
}
public function url(): string
{
return $this->isHome() ? route('home') : route('page', ['slug' => $this->slug]);
}
public function label(): string
{
return $this->menu_label ?: $this->title;
}
}