- 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>
82 lines
2.3 KiB
PHP
82 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\CarbonInterface;
|
|
use Database\Factories\SiteFactory;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
/**
|
|
* A website: domain, theme with its settings, pages and appearances, and the properties it shows.
|
|
* Today there is one site; more sites allow other landlords to use the system under their own domain.
|
|
*/
|
|
#[Fillable(['name', 'domain', 'is_default', 'theme', 'theme_settings', 'locale'])]
|
|
class Site extends Model
|
|
{
|
|
/** @use HasFactory<SiteFactory> */
|
|
use HasFactory;
|
|
|
|
/**
|
|
* Get the attributes that should be cast.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'is_default' => 'boolean',
|
|
'theme_settings' => 'array',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<Page, $this>
|
|
*/
|
|
public function pages(): HasMany
|
|
{
|
|
return $this->hasMany(Page::class)->orderBy('sort_order');
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<Appearance, $this>
|
|
*/
|
|
public function appearances(): HasMany
|
|
{
|
|
return $this->hasMany(Appearance::class);
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<Property, $this>
|
|
*/
|
|
public function properties(): HasMany
|
|
{
|
|
return $this->hasMany(Property::class);
|
|
}
|
|
|
|
/**
|
|
* The property sections show when they do not name one (the first active property).
|
|
*/
|
|
public function primaryProperty(): ?Property
|
|
{
|
|
return $this->properties()->where('is_active', true)->orderBy('id')->first()
|
|
?? Property::query()->where('is_active', true)->whereNull('site_id')->orderBy('id')->first();
|
|
}
|
|
|
|
/**
|
|
* The appearance in effect on $date: the active seasonal one with the highest priority, else the default.
|
|
*/
|
|
public function appearanceOn(CarbonInterface $date): ?Appearance
|
|
{
|
|
$appearances = $this->appearances()->where('is_active', true)->get();
|
|
|
|
return $appearances
|
|
->filter(fn (Appearance $appearance): bool => $appearance->covers($date))
|
|
->sortByDesc('priority')
|
|
->first()
|
|
?? $appearances->firstWhere('is_default', true);
|
|
}
|
|
}
|