Phase 6, Anwendungsseite: Bildwelten und die Marke je Website

Die Theme-Sitzung wartete darauf: Seebad ruft schon ortsneutrale Plätze
über `partials/motif` auf und behilft sich mit einem eigenen `motifs/`-
Ordner. Der Kommentar dort sagt es selbst – „so a later picture-world
system can replace the mapping below". Das System gibt es jetzt.

**Bildwelten** (A18–A20) sind Pakete wie Themes: `resources/image-worlds/
<key>/` mit `world.json` und `svg/`. Eine Website wählt eine Bildwelt, eine
Wohnung darf eine andere tragen – das ist der Platz für die Bergwohnung auf
einer Küsten-Website. Vorlagen fragen über `$theme->motif($slot)` nach einem
Platz, nie nach einer Datei.

Die Render-Logik ist aus Seebads Partial in die Anwendung gewandert, damit
jedes Theme sie bekommt: Inline-SVG (nimmt die Textfarbe an, kein zweiter
Request), Titel und ARIA entfernt, und die internen Ids je Aufruf eindeutig
gemacht – zwei Kopien derselben Grafik auf einer Seite würden sonst auf
denselben Verlauf zeigen und eine davon verlöre ihre Farben.

Ein leerer Platz ist kein Fehler: die Vorlage bekommt schlicht keine
Dekoration. Weil das leicht zu übersehen ist, meldet
`php artisan image-worlds:check`, welcher Platz ohne Datei dasteht.

**Marke je Website** (A14/A22): Logo, Favicon und ein Logo für E-Mail und
Vertrag als Medien der Website. Der Mietvertrag bettet die Datei ein statt
eine URL zu holen – er wird auf dem Server gerendert und darf nicht davon
abhängen, dass dieser sich selbst erreicht. Ohne Logo bleibt der Vertrag
wie bisher.

`resources/themes/**` ist unberührt: die Ostsee-Grafiken sind kopiert, nicht
verschoben. Was die Theme-Sitzung nun tun kann, steht in
ZUSAMMENARBEIT.md §6; ihr Wunsch aus §5 ist als erledigt vermerkt.

272 Feature-Tests grün.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Lars StommerandClaude Opus 5 committed 2026-10-26 07:35:17 +01:00
1 parent f686996122
commit 4e66add1f0
28 files changed
+906 -5

No files matched your search

+56 -3
View File
@@ -12,16 +12,18 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Facades\URL;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
/**
* 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
#[Fillable(['name', 'domain', 'is_default', 'theme', 'image_world', 'theme_settings', 'locale'])]
class Site extends Model implements HasMedia
{
/** @use HasFactory<SiteFactory> */
use BelongsToTenant, HasFactory;
use BelongsToTenant, HasFactory, InteractsWithMedia;
protected static function booted(): void
{
@@ -83,6 +85,57 @@ public function signedRoute(string $name, mixed $parameters = []): string
/**
* Keep the single domain field and the host table on the same hostname.
*/
/**
* The brand of this website: the graphics that identify the landlord, not the decoration of the theme.
* Kept per website so a second landlord never inherits the first one's logo in their contract (A14/A22).
*/
public const BRAND_LOGO = 'logo';
public const BRAND_FAVICON = 'favicon';
public const BRAND_DOCUMENT_LOGO = 'document_logo';
public function registerMediaCollections(): void
{
// The brand is shown on the public website and in mails, so it lives on the public disk.
$this->addMediaCollection(self::BRAND_LOGO)
->useDisk('public')
->singleFile()
->acceptsMimeTypes(['image/svg+xml', 'image/png', 'image/webp']);
$this->addMediaCollection(self::BRAND_FAVICON)
->useDisk('public')
->singleFile()
->acceptsMimeTypes(['image/svg+xml', 'image/png', 'image/x-icon']);
// Mail clients and the PDF renderer do not draw SVG, so this one is a pixel image.
$this->addMediaCollection(self::BRAND_DOCUMENT_LOGO)
->useDisk('public')
->singleFile()
->acceptsMimeTypes(['image/png', 'image/jpeg']);
}
/**
* The URL of a brand graphic, or null when this website has none.
*/
public function brandUrl(string $collection): ?string
{
$media = $this->getFirstMedia($collection);
return $media?->getUrl() ?: null;
}
/**
* The absolute path of a brand graphic – mails and the contract PDF embed the file, they cannot fetch
* a URL from a server that may not be reachable from where the PDF is rendered.
*/
public function brandPath(string $collection): ?string
{
$path = $this->getFirstMedia($collection)?->getPath();
return is_string($path) && is_file($path) ? $path : null;
}
public function syncDomainHost(): void
{
if (! $this->wasRecentlyCreated && ! $this->wasChanged('domain')) {