Compare commits

...
Author SHA1 Message Date
Lars StommerandClaude Opus 5 361acfa12a Doku: Übergabe für die Phase-7-Sitzung
Deploy / test (push) Failing after 3s
Deploy / deploy (push) Skipped
Der wichtigste Hinweis steht jetzt als erstes in Abschnitt 7: `main` ist
dem Server voraus. Phase 6 liegt auf `main` und ist nicht ausgeliefert, und
sie bringt eine Migration mit. Wer das übersieht, deployt entweder blind
oder hält Server und Code für gleich.

Dazu, was Phase 7 anfassen muss: `Theme::property()` merkt sich die
Wohnung, es fehlt ein Weg, sie je Baustein zu setzen und zurückzusetzen –
mit dem ausdrücklichen Hinweis, dass es eine solche Methode heute nicht
gibt. Und die Regel, die über den ganzen Umbau gilt: jede neue Tabelle
bekommt `tenant_id` und gehört in `TenantArchive::DELETE_ORDER`, sonst
überlebt sie die Kündigung ihres Mandanten.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-26 07:56:04 +01:00
Lars StommerandClaude Opus 5 c459f7f83c Doku: Bildwelten und Marke in STATUS, Plan und Vertragsprotokoll; Platzhalter-Hash korrigiert
Deploy / test (push) Failing after 3s
Deploy / deploy (push) Skipped
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-26 07:38:45 +01:00
Lars StommerandClaude Opus 5 4e66add1f0 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>
2026-10-26 07:35:17 +01:00
Lars StommerandClaude Opus 5 f686996122 Doku: ausgelieferter Stand 20261024152057 und die Prüfungen am Server
Deploy / test (push) Failing after 3s
Deploy / deploy (push) Skipped
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-24 17:39:06 +02:00
Lars Stommer 2c5b5fc2d7 Merge branch 'feature/mandanten-phase4-5' (Phasen 4 und 5)
Deploy / test (push) Failing after 2s
Deploy / deploy (push) Skipped
2026-10-24 17:15:31 +02:00
Lars StommerandClaude Opus 5 9cd39f791f Doku: Phasen 1 bis 5 umgesetzt, Grundumbau der Mandantenfähigkeit fertig
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-24 17:15:30 +02:00
Lars StommerandClaude Opus 5 c55937d20e Phase 4 und 5: Hintergrundläufe je Mandant, Export und Kündigung
**Phase 4 – was im Hintergrund lief, kannte keinen Mandanten.**

`App\Tenancy\TenantRunner` führt jeden Lauf einmal je aktivem Mandanten
aus, mit gesetztem Kontext. Ohne ihn sah der Scheduler bei zwei Mandanten
gar keinen: Abfragen filterten nicht mehr und der Absender fiel auf die
.env zurück – eine Erinnerung des einen Vermieters wäre unter der Adresse
des anderen verschickt worden. Seit gestern gibt es zwei Mandanten; nur
weil der Cronjob auf Strato noch nicht eingerichtet ist, ist das bisher
niemandem passiert.

Betroffen: Vormerkungen, Portal-Abgleich, Portal-Postfach, Überwachung,
Erinnerungen, Bewertungsbitten, Anonymisierung. Die Datenbank-Sicherung
bleibt global – eine Datenbank, ein Dump. Ein Mandant, dessen Lauf
scheitert, hält die anderen nicht auf.

Das Postfach gehört jetzt dem Mandanten (`mailbox_*`, Passwort
verschlüsselt, leerer Server = aus). Es steht im Mandanten-Admin und nur,
wenn der Betreiber den Dienst freigeschaltet hat. Auch die Zustands-
Schlüssel im Cache tragen den Mandanten – sonst meldeten zwei Mandanten
einander ihre letzte erfolgreiche Abholung.

**Phase 5 – Kündigung.**

`App\Tenancy\TenantArchive` mit zwei Befehlen des Betreibers:
`tenants:export <slug>` schreibt alle Zeilen und Dateien in ein Zip,
`tenants:delete <slug>` exportiert erst, fragt nach und löscht dann in
der Reihenfolge, die die Fremdschlüssel erlauben, Medien eingeschlossen.

Konten, die nur zu diesem Mandanten gehörten, gehen mit – ein Konto, das
nirgends mehr hineinkommt, ist personenbezogenes Datum ohne Zweck. Wer
noch für einen anderen Mandanten arbeitet, und der Betreiber, bleiben.
Der Export nennt die Konten mit Rolle, aber ohne Passwort-Hashes und ohne
2FA-Geheimnisse: er wird herausgegeben.

Löschen ist bewusst keine Schaltfläche im Panel.

`TenantSeparationTest` füllt jeden Bereich aus A1 für zwei Mandanten,
exportiert und löscht einen und prüft, dass der andere Zeile für Zeile
unverändert ist – auch die Hosts, die über die Website am Mandanten
hängen und keine eigene tenant_id haben. Dieser Test merkt künftig, wenn
eine neue Tabelle ihre tenant_id vergisst.

262 Feature-Tests grün. Der Export einmal auf echten Daten ausgeführt
(2,3 MB mit Fotos); das Löschen nicht, weil es Dateien aus dem echten
Speicher entfernt.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-24 11:15:55 +02:00
Lars StommerandClaude Opus 5 c2cf632ad5 Doku: Betreiber-Provisionierung, Sperrseite und systemweite Einstellungen
Deploy / test (push) Failing after 2s
Deploy / deploy (push) Skipped
Dazu ein genauerer Testname: Links tragen die Hauptadresse ihrer Website,
nicht die Adresse, über die der Besucher kam. Das ist der kanonische Host
und war vorher falsch benannt.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-24 10:25:48 +02:00
Lars Stommer f2e78446a8 Merge branch 'feature/betreiber-provisionierung'
Deploy / test (push) Failing after 2s
Deploy / deploy (push) Skipped
2026-10-24 10:20:28 +02:00
Lars StommerandClaude Opus 5 03ad4667ac Betreiber richtet Mandanten vollständig ein: Adressen, Sperrseite, Systemwerte
Ein neu angelegter Mandant war eine Sackgasse. Er bekam keine Website, also
keinen Host, also keine Adresse – und der Host wird im Mandanten-Admin
eingetragen, den er ohne Adresse nicht erreicht. „Im Admin öffnen" half
nicht: ohne Domain landete es beim Mandanten des aktuellen Hosts.

Einsprungsadressen gehören jetzt dem Betreiber, weil Webspace und Hosting
ihm gehören und ein Mandant nicht die Adresse eines anderen auf sich
zeigen lassen darf. Im Mandanten-Formular: Websites mit ihren Adressen.
Beim Anlegen entstehen Website, Host-Einträge und eine leere Startseite –
ohne Startseite antwortet die Website mit 404. Im Mandanten-Admin sind die
Adressen nur noch sichtbar, nicht änderbar. Die Domain beim Hoster auf das
Verzeichnis zu legen bleibt ein Schritt von Hand.

Gesperrter Mandant: statt 404 ein Hinweis mit Status 503, Text je Mandant
einstellbar. 503 hält die Seiten im Suchindex, weil die Sperre vorübergehend
ist.

Behoben: `URL::forceRootUrl(APP_URL)` zwang **alle** Links auf einen festen
Host. Mit einem Mandanten unsichtbar; mit zwei Domains hätte jeder interne
Link der zweiten Website auf die erste gezeigt. Der Ursprung ist jetzt der
Host der aufgelösten Website.

Neu: systemweite Einstellungen sind im Betreiber-Bereich änderbar
(Löschfristen, Bot-Schutz, Flutgrenze, Sicherungen, Portal-Fristen,
Versandweg, SMTP, harte Mail-Umleitung, Tokens). Leer heißt: der Wert der
.env gilt wieder – und zwar sofort, nicht erst beim nächsten Start.
Geheimnisse liegen verschlüsselt. Datenbank-Zugang und APP_KEY bleiben in
der .env, weil sie gebraucht werden, um die Datenbank zu öffnen und das
Gespeicherte zu entschlüsseln.

253 Feature-Tests grün.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-24 10:20:18 +02:00
Lars StommerandClaude Opus 5 d9383cf3e5 Betreiber: Knopf zum Anlegen heißt jetzt "Neuen Mandanten anlegen"
Deploy / test (push) Failing after 2s
Deploy / deploy (push) Skipped
Die Schaltfläche hieß nur "Erstellen" (Filaments Vorgabe) und war als
Einstieg nicht erkennbar. Dazu ein Test, der den ganzen Weg geht: Liste,
Formular, Anlegen samt Dienste-Freischaltung – und prüft, dass ein neuer
Mandant nichts von dem Mandanten erbt, den der Betreiber gerade ansieht.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-24 09:39:41 +02:00
Lars StommerandClaude Opus 5 e0e8c1d856 Doku: Dienste-Steuerung, Host-Verwaltung und der zweite Mandant auf stommer.info
Deploy / test (push) Failing after 2s
Deploy / deploy (push) Skipped
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-24 09:33:07 +02:00
Lars Stommer 2f2aceb3bd Merge branch 'feature/mandanten-dienste' (Dienste-Steuerung und Host-Verwaltung)
Deploy / test (push) Failing after 2s
Deploy / deploy (push) Skipped
2026-10-24 09:25:23 +02:00
Lars StommerandClaude Opus 5 2e3f2ca938 Mehrere Adressen je Website, damit ein zweiter Mandant niemanden abschaltet
Bisher schrieb das Feld „Domain" genau einen Host nach `site_domains` und
löschte den vorherigen. Solange es einen Mandanten gibt, fällt das nicht
auf: jede Adresse liefert die Standard-Website. Ab dem zweiten Mandanten
bekommt jede nicht eingetragene Adresse 404 – und „www.beispiel.de" ist
eine eigene Adresse. stommer.info hätte einen zweiten Mandanten nicht
überlebt.

Das Formular hat jetzt „Hauptadresse" (steht in Gästelinks) und „Weitere
Adressen". Eingaben werden normalisiert, „https://WWW.Beispiel.de/" wird
zu „www.beispiel.de".

Eine Adresse, die schon zu einer anderen Website gehört, wird abgelehnt.
Ohne diese Sperre könnte ein Mandant die Besucher eines anderen auf seine
eigene Seite ziehen, indem er dessen Adresse einträgt.

242 Feature-Tests grün.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-24 09:25:22 +02:00
Lars StommerandClaude Opus 5 fd2a7f7ded Dienste wirklich anschließen: zentrale Steuerung statt folgenloser Schalter
Die Schalter aus Phase 3 schrieben nur in eine Tabelle, die niemand las.
Ein gesperrter Portal-Abgleich lief trotzdem weiter. Das ist behoben.

`App\Tenancy\TenantFeatures` ist die eine Stelle, die beantwortet, ob ein
Mandant einen Dienst hat. Sie wird an allen Wegen abgefragt, die zum Dienst
führen:

- `RolePolicy::allows()` – damit greift die Mandanten-Ebene in *jeder*
  Richtlinie des Admins. Die Rolle sagt, was ein Benutzer darf; der Dienst
  sagt, was der Mandant überhaupt hat. Keine Rolle wiegt einen gesperrten
  Dienst auf.
- `Channel::importsOccupations()` – Import und Scheduler.
- Der öffentliche iCal-Feed antwortet mit 404.
- `ProcessPortalMail` und `channels:fetch-mail` für den Postfach-Schnellweg.

`TenantServiceKey::isWired()` trennt Gebautes von Geplantem. Nur verdrahtete
Dienste erscheinen als Schalter; die drei KI-Dienste stehen als Hinweis da,
bis die Anwendung sie abfragt. Eigene API-Schlüssel sind aus dem Betreiber-
Formular verschwunden – sie gehören in den Admin des Mandanten, wenn es
soweit ist (A16).

Neu im Betreiber-Bereich: Seite „System" mit den Grenzen, die für alle
Mandanten gelten (aus der .env, bewusst nicht änderbar), der Mandantenliste
und dem Zugriffsprotokoll. Bisher war dort nur die Mandantenliste.

Die Migration schaltet jedem vorhandenen Mandanten die Portal-Dienste frei,
damit der Umbau laufenden Betrieb nicht stillschweigend stoppt.

240 Feature-Tests grün, davon fünf neue in `TenantServiceGateTest`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-24 09:14:10 +02:00
Lars StommerandClaude Opus 5 220ec6bfdb Doku: Sicherung, Migrationsstand und Prüfung des Phase-3-Deploys
Deploy / test (push) Failing after 2s
Deploy / deploy (push) Skipped
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-23 22:02:29 +02:00
Lars StommerandClaude Opus 5 afffa79289 Doku: Phase 3 ist auf stommer.info; Release-Nummern korrigiert
Deploy / test (push) Failing after 2s
Deploy / deploy (push) Skipped
Im Stand stand noch `20261023100346`, obwohl danach vier weitere Deploys
liefen (Grundriss, Fotos-Fix). Jetzt steht überall die wirklich aktive
Version `20261023195835` mit Phase 3.

Neu vermerkt: die Bankverbindung ist am Mandanten leer, weil die .env von
stommer.info keine `FEWO_BANK_*`-Werte hat – sie gehört jetzt in
System › Betrieb.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-23 22:01:53 +02:00
Lars Stommer f143a4f5f4 Merge branch 'feature/mandanten-phase3' (Mandanten Phase 3)
Deploy / test (push) Failing after 2s
Deploy / deploy (push) Skipped
2026-10-23 20:49:47 +02:00
Lars StommerandClaude Opus 5 e6d4d89141 Mandanten Phase 3: Einstellungen, Texte und Dienste gehören dem Mandanten
Vermieterdaten, Bank, Steuerangabe, Adressen, Betriebsart und Fristen sind
Spalten von `tenants`. `App\Tenancy\TenantConfig` legt sie über
`config('fewo.*')` und `mail.from`, sobald der Mandantenkontext wechselt –
so lesen Vorlagen, Mails und der Mietvertrag weiter dieselben Schlüssel und
`resources/themes/**` bleibt unangetastet.

Die `.env` ist die Grundlinie: Rückfall, solange kein Mandant feststeht, und
Grenze für Löschfristen und Bot-Schutz (nur verschärfen, nicht lockern). Die
Flutgrenze bleibt global. Bank, Steuerangabe und eigene Dienst-Schlüssel
liegen verschlüsselt.

Die Seite System › Betrieb schreibt jetzt den Mandanten und enthält
zusätzlich Vermieterdaten, Bank und die Fristen. Tabelle `settings` und
Modell `Setting` entfallen; die Migration übernimmt die bisherigen Werte
aus `settings` und der Konfiguration in den Mandanten Stommer.

Neu: `tenant_services` (Freischaltung je Dienst mit optionalem eigenem
API-Schlüssel, nur im Betreiber-Bereich schaltbar) und `service_usages`.
Es zählt noch nichts, weil kein Dienst aufruft.

235 Feature-Tests grün. Der Umbauweg wurde zusätzlich auf einer Kopie der
lokalen Datenbank durchgespielt.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-23 20:49:22 +02:00
LarsandClaude Opus 5.5 12e4079126 Docs: photo storage fix (admin uploads were private) in BETRIEB §8 and STATUS
Deploy / test (push) Failing after 3s
Deploy / deploy (push) Skipped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 20:17:18 +02:00
LarsandClaude Opus 5.5 1871c04507 Fix: photos uploaded in the admin were stored privately and did not show on the website
Deploy / test (push) Failing after 2s
Deploy / deploy (push) Skipped
The admin upload field used Filament's default disk (FILESYSTEM_DISK=local, private), while imports
and the website use the public disk – a photo uploaded in the admin appeared in the photo list but
its web sizes returned 403 (e.g. as floor plan picture). The photo collection and the upload field
now always use the public disk; a data migration moves photos already stored privately (original and
web sizes, folder = media id) to the public disk. Tests for the upload and the migration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 17:12:32 +02:00
LarsandClaude Opus 5.5 dfd3f77a5d Floor plan editor: move corners by drag or arrow keys, insert on edges, delete by double click
Deploy / test (push) Failing after 3s
Deploy / deploy (push) Skipped
Corners stay editable after drawing: drag a corner (mouse or touch), focus it and nudge with the arrow
keys (Shift for larger steps), '+' on an edge inserts a corner in its middle, double click or Delete
removes one. Tested in a browser harness with the real field markup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 16:47:55 +02:00
LarsandClaude Opus 5.5 f7cbc66451 Section "Grundriss (interaktiv)": floor plan with rooms, admin editor, Seebad view
Deploy / test (push) Failing after 2s
Deploy / deploy (push) Skipped
- Table floor_plans (tenant_id, one per apartment, picture = website photo, rooms as JSON with
  corners in percent of the picture), model FloorPlan with BelongsToTenant, Property::floorPlan()
- Admin › Webseite › Grundriss: room list with name, description, photos, equipment (from the
  equipment list), accessibility hint, visibility, and an area editor (click the corners on the picture)
- Section floor_plan: base view without JavaScript (areas jump to the room list), Seebad view with
  room buttons, highlighted area and a cartouche per room (theme.js initFloorPlans)
- Tests: tenant inheritance, point parsing, website output, admin create incl. validation; the
  render test for all themes now includes the floor plan
- Docs: THEMES §5, ZUSAMMENARBEIT §6, STATUS §6 (incl. note for tenancy phase 5)
- styles/grundriss: revised rendering, WebP renditions, room areas of the Stommer flat in percent

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 15:26:02 +02:00
124 changed files with 5766 additions and 209 deletions

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
{
"permissions": {
"allow": [
"Bash(git merge *)"
]
}
}
+1
View File
@@ -32,3 +32,4 @@ Thumbs.db
# Deployment settings with access data
/scripts/deploy.*.env
!/scripts/deploy.example.env
storage/app/private/exports/
+1 -1
View File
@@ -17,7 +17,7 @@ # Ferienwohnung Stommer
- Website = theme system (`docs/THEMES.md`): themes live in `resources/themes/<key>` (theme.json, theme.css, theme.js, views); views resolve via the `theme::` namespace (theme → parent → base `ostsee-licht`). Pages are lists of sections (`app/Themes/Sections`, catalogue in `config/themes.php`); seasonal `Appearance`s override tokens/texts/hero photo/photos per section (stable `data.id` per placed section) and sections can be limited to appearances. Theme views use only token colour classes (`bg-accent`, `text-muted`, …). New designs are **additional** themes: `php artisan themes:make <key>`, `themes:check`, `themes:preview` – never edit `ostsee-licht` for a new design; authoring rules in `docs/THEME-ERSTELLUNG.md`. Resolve `Theme` lazily (`app(Theme::class)`), never in constructors – middleware `ResolveTheme` replaces it per request.
- Operations (environments, Strato access, server .env, admin accounts, 2FA, known pitfalls): `docs/BETRIEB.md` – read it before touching a server. Admin accounts: `php artisan users:create`; 2FA (Filament app authentication) is mandatory for every account. Admin modes (`App\Enums\AdminMode`: simple/expert per user, user menu switch) only shape the menu via the `FollowsAdminMode` trait on every resource/page (simple menu = `AdminMode::SIMPLE_NAVIGATION`); permissions stay with roles/policies. New admin resources must use `FollowsAdminMode`.
- Deployment: `scripts/deploy.sh <env> setup|deploy [ref]|rollback|releases|artisan` (atomic releases on Strato, docs/DEPLOYMENT.md; the server keeps only the active release because of Strato's file quota – history = Git tags `deploy/<env>/<timestamp>`); CI `.gitea/workflows/deploy.yml`. Production has no dev packages (no factories/Faker) – production seeding via `ProductionSeeder`.
- Strato specifics: `public/index.php` strips the internal `/releases/<v>/public` prefix from `REQUEST_URI` (signed URLs); `URL::forceRootUrl(APP_URL)` outside local/testing; mail routing: `App\Support\Settings` (admin page System › Betrieb) – test mode (default) sends every mail to the test recipient only, live delivers normally; `FEWO_MAIL_REDIRECT_TO` is a hard override. Internal addresses are admin settings too: send notifications to `Settings::notificationRecipients()` (never `config('fewo.notification_email')` directly); contact/reply-to (`fewo.owner.email`) and sender (`mail.from`) are overridden at boot by `Settings::applyAddressOverrides()`. The booking form is protected against bots (`config('fewo.spam')`: honeypot, time trap, rate limits, max open holds per e-mail) – tests that submit it instantly set `fewo.spam.min_seconds` to 0.
- Strato specifics: `public/index.php` strips the internal `/releases/<v>/public` prefix from `REQUEST_URI` (signed URLs); `URL::forceRootUrl(APP_URL)` outside local/testing; mail routing: `App\Support\Settings` (admin page System › Betrieb, stored on the tenant) – test mode (default) sends every mail to the test recipient only, live delivers normally; `FEWO_MAIL_REDIRECT_TO` is a hard override. Landlord data, bank, addresses and periods are columns of `tenants`: `App\Tenancy\TenantConfig` lays them over `config('fewo.*')` and `mail.from` whenever the tenant context changes, so views and mails keep reading the config keys. Send notifications to `Settings::notificationRecipients()` (never `config('fewo.notification_email')` directly). Retention periods and bot-protection counters can only be tightened against the `.env` baseline. The booking form is protected against bots (`config('fewo.spam')`: honeypot, time trap, rate limits, max open holds per e-mail) – tests that submit it instantly set `fewo.spam.min_seconds` to 0.
- Vite fonts plugin is removed on purpose (corporate proxy breaks remote font downloads, and fonts must be self-hosted for GDPR).
- PHP/Composer on this machine: winget package dir `%LOCALAPPDATA%\Microsoft\WinGet\Packages\PHP.PHP.8.4_*` (Composer as `composer\composer.phar` there).
- Git remote: Gitea `https://gitea.stommer.de/Lars/fewo-stommer.git`, branch `main`.
+2 -2
View File
@@ -38,7 +38,7 @@ public static function mailboxIsStale(): bool
return false;
}
$lastSuccess = Cache::get(MailboxReader::LAST_SUCCESS_KEY);
$lastSuccess = Cache::get(MailboxReader::key(MailboxReader::LAST_SUCCESS_KEY));
return $lastSuccess === null
|| CarbonImmutable::parse($lastSuccess)->lessThan(now()->subMinutes(config('fewo.mailbox.stale_after_minutes')));
@@ -56,7 +56,7 @@ private function monitorMailbox(): int
return 0;
}
Mail::to(Settings::notificationRecipients())->send(new MailboxAlert(Cache::get(MailboxReader::LAST_ERROR_KEY)));
Mail::to(Settings::notificationRecipients())->send(new MailboxAlert(Cache::get(MailboxReader::key(MailboxReader::LAST_ERROR_KEY))));
Cache::forever(self::MAILBOX_ALERTED_KEY, true);
return 1;
+7
View File
@@ -8,12 +8,14 @@
use App\Channels\Mail\PortalMailParser;
use App\Enums\PortalEmailStatus;
use App\Enums\PortalEmailType;
use App\Enums\TenantServiceKey;
use App\Mail\ChannelConflict;
use App\Mail\PortalMailNotification;
use App\Models\BlockedPeriod;
use App\Models\Channel;
use App\Models\PortalEmail;
use App\Support\Settings;
use App\Tenancy\TenantFeatures;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Mail;
@@ -40,6 +42,11 @@ public function handle(PortalMail $mail): ?PortalEmail
return null;
}
// The fast path is a service of its own: a landlord without it keeps the mail unprocessed.
if (! app(TenantFeatures::class)->enabled(TenantServiceKey::PortalMail, $channel->tenant)) {
return null;
}
$parsed = $this->parser->parse($mail->subject, $mail->text);
$conflicts = [];
+30 -5
View File
@@ -3,6 +3,7 @@
namespace App\Channels\Mail;
use App\Channels\ChannelSyncException;
use App\Support\Settings;
use Carbon\CarbonImmutable;
use Illuminate\Support\Facades\Cache;
use Throwable;
@@ -17,11 +18,31 @@ class MailboxReader
{
public const LAST_SUCCESS_KEY = 'mailbox:last_success_at';
/**
* The state of one landlord's mailbox. Without the landlord in the key, two landlords would report
* each other's last success and alerts would be raised for the wrong one.
*/
public static function key(string $base): string
{
return $base.':'.(Settings::tenant()?->id ?? 0);
}
public const LAST_ERROR_KEY = 'mailbox:last_error';
/**
* The mailbox of the current landlord. Each landlord reads their own; an empty one means the fast path
* is off for them.
*
* @return array<string, mixed>|null
*/
public static function configuration(): ?array
{
return Settings::tenant()?->mailbox();
}
public static function isConfigured(): bool
{
return filled(config('fewo.mailbox.host')) && filled(config('fewo.mailbox.username'));
return self::configuration() !== null;
}
/**
@@ -32,7 +53,11 @@ public static function isConfigured(): bool
*/
public function fetch(array $senders): array
{
$config = config('fewo.mailbox');
$config = self::configuration();
if ($config === null) {
throw new ChannelSyncException('Für diesen Mandanten ist kein Postfach hinterlegt.');
}
try {
$client = (new ClientManager)->make([
@@ -62,13 +87,13 @@ public function fetch(array $senders): array
$client->disconnect();
} catch (Throwable $exception) {
Cache::forever(self::LAST_ERROR_KEY, $exception->getMessage());
Cache::forever(self::key(self::LAST_ERROR_KEY), $exception->getMessage());
throw new ChannelSyncException('Postfach konnte nicht gelesen werden: '.$exception->getMessage(), previous: $exception);
}
Cache::forever(self::LAST_SUCCESS_KEY, now()->toIso8601String());
Cache::forget(self::LAST_ERROR_KEY);
Cache::forever(self::key(self::LAST_SUCCESS_KEY), now()->toIso8601String());
Cache::forget(self::key(self::LAST_ERROR_KEY));
return $mails;
}
+71
View File
@@ -0,0 +1,71 @@
<?php
namespace App\Console\Commands;
use App\ImageWorlds\ImageWorldManifest;
use App\ImageWorlds\ImageWorldRegistry;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
#[Signature('image-worlds:check')]
#[Description('Check every picture world: does each slot in the manifest have its SVG file?')]
class CheckImageWorlds extends Command
{
/**
* A slot without a file is not an error at runtime – templates simply get no decoration. That makes it
* easy to miss, so it is reported here instead of silently leaving a page bare.
*/
public function handle(ImageWorldRegistry $registry): int
{
$worlds = $registry->all();
if ($worlds === []) {
$this->warn('Keine Bildwelt gefunden.');
return self::SUCCESS;
}
$incomplete = 0;
foreach ($worlds as $world) {
$missing = $world->missingFiles();
if ($missing === []) {
$this->info(sprintf('✓ %s (%s): %d Plätze', $world->name, $world->key, count($world->slots)));
continue;
}
$incomplete++;
$this->error(sprintf('✗ %s (%s): ohne Datei – %s', $world->name, $world->key, implode(', ', $missing)));
}
$this->newLine();
$this->line($this->slotOverview($worlds));
return $incomplete === 0 ? self::SUCCESS : self::FAILURE;
}
/**
* Which slot is filled by which world – so a template author sees what they may rely on.
*
* @param array<string, ImageWorldManifest> $worlds
*/
private function slotOverview(array $worlds): string
{
$slots = [];
foreach ($worlds as $world) {
foreach (array_keys($world->slots) as $slot) {
$slots[$slot][] = $world->key;
}
}
ksort($slots);
return collect($slots)
->map(fn (array $keys, string $slot): string => sprintf(' %-18s %s', $slot, implode(', ', $keys)))
->implode(PHP_EOL);
}
}
+51
View File
@@ -0,0 +1,51 @@
<?php
namespace App\Console\Commands;
use App\Models\Tenant;
use App\Tenancy\TenantArchive;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
use function Laravel\Prompts\confirm;
#[Signature('tenants:delete {slug : Kurzname des Mandanten} {--keep-export : Nicht vorher exportieren} {--force : Ohne Rückfrage}')]
#[Description('Export a landlord and then remove them with all their data and files')]
class DeleteTenant extends Command
{
/**
* Exports first, unless told otherwise: a deletion that cannot be undone should leave something behind.
*/
public function handle(TenantArchive $archive): int
{
$tenant = Tenant::query()->where('slug', $this->argument('slug'))->first();
if ($tenant === null) {
$this->error('Kein Mandant mit dem Kurznamen '.$this->argument('slug').'.');
return self::FAILURE;
}
if (! $this->option('keep-export')) {
$path = $archive->export($tenant, storage_path('app/private/exports'));
$this->info('Export geschrieben: '.$path);
}
if (! $this->option('force') && ! confirm('Mandant '.$tenant->name.' mit allen Daten und Dateien endgültig löschen?', default: false)) {
$this->line('Abgebrochen.');
return self::SUCCESS;
}
$removed = $archive->delete($tenant);
foreach ($removed as $table => $count) {
$this->line(sprintf(' %-22s %d', $table, $count));
}
$this->info('Mandant '.$tenant->name.' gelöscht.');
return self::SUCCESS;
}
}
@@ -3,22 +3,26 @@
namespace App\Console\Commands;
use App\Actions\ExpireReservations;
use App\Models\Tenant;
use App\Tenancy\TenantRunner;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
#[Signature('bookings:expire-holds')]
#[Description('Mark reservations with an elapsed hold time as expired and notify the landlord')]
#[Description('Mark reservations with an elapsed hold time as expired and notify the landlord – once per landlord')]
class ExpireReservationHolds extends Command
{
/**
* Execute the console command.
*/
public function handle(ExpireReservations $expireReservations): int
public function handle(ExpireReservations $expireReservations, TenantRunner $runner): int
{
$count = $expireReservations->handle();
$runner->each(function (Tenant $tenant) use ($expireReservations): void {
$count = $expireReservations->handle();
$this->info("{$count} Vormerkung(en) abgelaufen.");
$this->info("{$tenant->name}: {$count} Vormerkung(en) abgelaufen.");
});
return self::SUCCESS;
}
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace App\Console\Commands;
use App\Models\Tenant;
use App\Tenancy\TenantArchive;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
#[Signature('tenants:export {slug : Kurzname des Mandanten} {--to= : Zielordner, sonst storage/app/private/exports}')]
#[Description('Write all data and files of one landlord into a zip archive')]
class ExportTenant extends Command
{
public function handle(TenantArchive $archive): int
{
$tenant = Tenant::query()->where('slug', $this->argument('slug'))->first();
if ($tenant === null) {
$this->error('Kein Mandant mit dem Kurznamen '.$this->argument('slug').'.');
return self::FAILURE;
}
$path = $archive->export($tenant, (string) ($this->option('to') ?: storage_path('app/private/exports')));
$this->info('Export von '.$tenant->name.': '.$path.' ('.$this->size($path).')');
return self::SUCCESS;
}
private function size(string $path): string
{
$bytes = (int) (filesize($path) ?: 0);
return $bytes > 1048576
? round($bytes / 1048576, 1).' MB'
: round($bytes / 1024).' KB';
}
}
+27 -13
View File
@@ -5,24 +5,40 @@
use App\Actions\ProcessPortalMail;
use App\Channels\ChannelSyncException;
use App\Channels\Mail\MailboxReader;
use App\Enums\TenantServiceKey;
use App\Models\Channel;
use App\Models\Tenant;
use App\Tenancy\TenantFeatures;
use App\Tenancy\TenantRunner;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
#[Signature('channels:fetch-mail')]
#[Description('Read booking notifications of the portals from the mailbox and block recognised bookings immediately')]
#[Description('Read booking notifications of the portals from each landlord\'s mailbox and block recognised bookings immediately')]
class FetchPortalMail extends Command
{
/**
* Execute the console command.
* Execute the console command. Every landlord has their own mailbox, so every landlord gets their own
* run – one landlord's credentials are never used to read another one's mail.
*/
public function handle(MailboxReader $reader, ProcessPortalMail $processPortalMail): int
public function handle(MailboxReader $reader, ProcessPortalMail $processPortalMail, TenantRunner $runner): int
{
if (! MailboxReader::isConfigured()) {
$this->line('Kein Postfach konfiguriert (FEWO_MAILBOX_HOST).');
$runner->each(fn (Tenant $tenant) => $this->fetchForCurrentLandlord($reader, $processPortalMail, $tenant));
return self::SUCCESS;
return self::SUCCESS;
}
private function fetchForCurrentLandlord(MailboxReader $reader, ProcessPortalMail $processPortalMail, Tenant $tenant): void
{
if (! app(TenantFeatures::class)->enabled(TenantServiceKey::PortalMail, $tenant)) {
return;
}
if (! MailboxReader::isConfigured()) {
$this->line("{$tenant->name}: kein Postfach hinterlegt.");
return;
}
$senders = Channel::query()->active()->get()
@@ -32,25 +48,23 @@ public function handle(MailboxReader $reader, ProcessPortalMail $processPortalMa
->all();
if ($senders === []) {
$this->line('Für kein Portal sind Absender hinterlegt.');
$this->line("{$tenant->name}: für kein Portal sind Absender hinterlegt.");
return self::SUCCESS;
return;
}
try {
$mails = $reader->fetch($senders);
} catch (ChannelSyncException $exception) {
$this->error($exception->getMessage());
$this->error("{$tenant->name}: {$exception->getMessage()}");
return self::FAILURE;
return;
}
foreach ($mails as $mail) {
if ($record = $processPortalMail->handle($mail)) {
$this->info("{$record->channel->name}: {$record->type->getLabel()} → {$record->status->getLabel()} ({$record->subject})");
$this->info("{$tenant->name} – {$record->channel->name}: {$record->type->getLabel()} → {$record->status->getLabel()} ({$record->subject})");
}
}
return self::SUCCESS;
}
}
+12 -5
View File
@@ -4,18 +4,27 @@
use App\Actions\SyncChannel;
use App\Models\Channel;
use App\Tenancy\TenantRunner;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
#[Signature('channels:sync {channel? : ID of a single channel}')]
#[Description('Import the occupations of all active portals (or one) and report conflicts')]
#[Description('Import the occupations of all active portals (or one) and report conflicts – once per landlord')]
class SyncChannels extends Command
{
/**
* Execute the console command.
* Execute the console command. Runs per landlord so that conflict mails carry the right sender and
* reach the right people.
*/
public function handle(SyncChannel $syncChannel): int
public function handle(SyncChannel $syncChannel, TenantRunner $runner): int
{
$runner->each(fn () => $this->syncCurrentLandlord($syncChannel));
return self::SUCCESS;
}
private function syncCurrentLandlord(SyncChannel $syncChannel): void
{
$channels = Channel::query()->active()
->when($this->argument('channel'), fn ($query, $id) => $query->whereKey($id))
@@ -29,7 +38,5 @@ public function handle(SyncChannel $syncChannel): int
? $this->info("✓ {$channel->name}: {$log->events} Belegungen, +{$log->added} ~{$log->changed} -{$log->removed}, Konflikte: {$log->conflicts}")
: $this->error("✗ {$channel->name}: {$log->message}");
}
return self::SUCCESS;
}
}
+10 -1
View File
@@ -3,6 +3,7 @@
namespace App\Documents;
use App\Models\Booking;
use App\Models\Site;
use Barryvdh\DomPDF\Facade\Pdf;
use Illuminate\Support\Facades\Storage;
@@ -22,7 +23,15 @@ public function generate(Booking $booking, bool $draft = false): string
? "contracts/Angebot-{$booking->reference}-v{$booking->offer_version}.pdf"
: "contracts/Mietvertrag-{$booking->reference}.pdf";
Storage::disk(self::DISK)->put($path, Pdf::loadView('pdf.contract', ['booking' => $booking, 'draft' => $draft])->setPaper('a4')->output());
// The logo is embedded as a file: the PDF is rendered on the server and must not depend on
// fetching anything over the network. Each website has its own (A14).
$logo = $booking->website()?->brandPath(Site::BRAND_DOCUMENT_LOGO);
Storage::disk(self::DISK)->put($path, Pdf::loadView('pdf.contract', [
'booking' => $booking,
'draft' => $draft,
'logo' => $logo,
])->setPaper('a4')->output());
$booking->update([$draft ? 'offer_path' : 'contract_path' => $path]);
return $path;
+76
View File
@@ -0,0 +1,76 @@
<?php
namespace App\Enums;
/**
* Services the operator unlocks per landlord. `isWired()` says whether the application really asks before
* it acts – a service that nothing asks for must not be offered as a switch, because switching it would
* promise something that does not happen.
*/
enum TenantServiceKey: string
{
case PortalSync = 'portal_sync';
case PortalMail = 'portal_mail';
case AiOffers = 'ai_offers';
case AiMarketing = 'ai_marketing';
case AiGuestMail = 'ai_guest_mail';
public function label(): string
{
return match ($this) {
self::PortalSync => 'Portal-Abgleich (iCal)',
self::PortalMail => 'Portal-Postfach (Schnellweg)',
self::AiOffers => 'KI: Angebotsentwürfe',
self::AiMarketing => 'KI: Vermarktungsassistent',
self::AiGuestMail => 'KI: Gästekommunikation',
};
}
public function description(): string
{
return match ($this) {
self::PortalSync => 'Belegungen der Portale über iCal einlesen und den eigenen Kalender als Feed anbieten.',
self::PortalMail => 'Buchungsmails der Portale aus dem Postfach lesen und Termine sofort sperren.',
self::AiOffers, self::AiMarketing, self::AiGuestMail => 'Noch nicht gebaut.',
};
}
/**
* Whether the application asks this switch before it acts. Only wired services are offered for switching.
*/
public function isWired(): bool
{
return match ($this) {
self::PortalSync, self::PortalMail => true,
self::AiOffers, self::AiMarketing, self::AiGuestMail => false,
};
}
/**
* What applies to a landlord the operator has not decided about yet. The portal services were part of
* the product before there were landlords, so switching tenancy on must not silently stop them.
*/
public function enabledByDefault(): bool
{
return $this->isWired();
}
/**
* Whether the landlord's own API key is of any use. Nothing calls out yet, so no service has one.
*/
public function usesApiKey(): bool
{
return match ($this) {
self::AiOffers, self::AiMarketing, self::AiGuestMail => true,
self::PortalSync, self::PortalMail => false,
};
}
/**
* @return list<self>
*/
public static function wired(): array
{
return array_values(array_filter(self::cases(), fn (self $service): bool => $service->isWired()));
}
}
@@ -0,0 +1,74 @@
<?php
namespace App\Filament\Operator\Concerns;
use App\Enums\TenantServiceKey;
use App\Models\Tenant;
use App\Tenancy\TenantFeatures;
/**
* The service switches of the tenant form. They live in their own table, so the form state is read and
* written separately from the landlord's own columns. Only wired services are written – a switch for a
* service nothing asks about would promise something that does not happen.
*
* Holds no Filament hooks; EditsTenantSetup calls these.
*/
trait EditsTenantServices
{
/**
* @param array<string, mixed> $data
* @return array<string, mixed>
*/
private function fillServices(array $data): array
{
$tenant = $this->record;
if (! $tenant instanceof Tenant) {
return $data; // creating: there is nothing to read yet
}
$stored = $tenant->services->keyBy('service');
$data['services'] = collect(TenantServiceKey::wired())
->mapWithKeys(fn (TenantServiceKey $service): array => [$service->value => [
'is_enabled' => $stored->get($service->value)?->is_enabled ?? $service->enabledByDefault(),
]])
->all();
return $data;
}
/**
* @param array<string, mixed> $data
* @return array<string, mixed>
*/
private function takeServices(array $data): array
{
$this->services = is_array($data['services'] ?? null) ? $data['services'] : [];
unset($data['services']);
return $data;
}
private function saveServices(): void
{
$tenant = $this->record;
if (! $tenant instanceof Tenant) {
return;
}
foreach (TenantServiceKey::wired() as $service) {
$state = $this->services[$service->value] ?? [];
$tenant->services()->updateOrCreate(
['service' => $service->value],
['is_enabled' => (bool) ($state['is_enabled'] ?? false)],
);
}
$tenant->unsetRelation('services');
app(TenantFeatures::class)->forget($tenant);
}
}
@@ -0,0 +1,58 @@
<?php
namespace App\Filament\Operator\Concerns;
/**
* Everything the operator sets up for a landlord that does not live in the tenants table itself:
* the websites with their entry addresses, and the services that are unlocked.
*/
trait EditsTenantSetup
{
use EditsTenantServices;
use EditsTenantWebsites;
/** @var array<string, array<string, mixed>> */
public array $services = [];
/** @var list<array<string, mixed>> */
public array $websites = [];
/**
* @param array<string, mixed> $data
* @return array<string, mixed>
*/
protected function mutateFormDataBeforeFill(array $data): array
{
return $this->fillWebsites($this->fillServices($data));
}
/**
* @param array<string, mixed> $data
* @return array<string, mixed>
*/
protected function mutateFormDataBeforeCreate(array $data): array
{
return $this->takeWebsites($this->takeServices($data));
}
/**
* @param array<string, mixed> $data
* @return array<string, mixed>
*/
protected function mutateFormDataBeforeSave(array $data): array
{
return $this->takeWebsites($this->takeServices($data));
}
protected function afterCreate(): void
{
$this->saveServices();
$this->saveWebsites();
}
protected function afterSave(): void
{
$this->saveServices();
$this->saveWebsites();
}
}
@@ -0,0 +1,182 @@
<?php
namespace App\Filament\Operator\Concerns;
use App\Models\Page;
use App\Models\Site;
use App\Models\SiteDomain;
use App\Models\Tenant;
use App\Tenancy\TenantContext;
use Illuminate\Validation\ValidationException;
/**
* The websites of a landlord and the addresses they answer on. These belong to the operator: the webspace
* and the hosting are the operator's, and a landlord must not be able to point an address at themselves.
*
* Wiring a new domain to this directory stays a manual step at the hoster. What is kept here is the other
* half: which host belongs to which website, and through it to which landlord.
*
* Holds no Filament hooks; EditsTenantSetup calls these.
*/
trait EditsTenantWebsites
{
/**
* @param array<string, mixed> $data
* @return array<string, mixed>
*/
private function fillWebsites(array $data): array
{
$tenant = $this->record;
if (! $tenant instanceof Tenant) {
return $data;
}
$data['websites'] = $tenant->sites()->withoutGlobalScope('tenant')->with('domains')->get()
->map(fn (Site $site): array => [
'id' => $site->id,
'name' => $site->name,
'hosts' => $site->domains->pluck('host')->all(),
])
->all();
return $data;
}
/**
* @param array<string, mixed> $data
* @return array<string, mixed>
*/
private function takeWebsites(array $data): array
{
$this->websites = is_array($data['websites'] ?? null) ? array_values($data['websites']) : [];
$this->normaliseWebsites();
unset($data['websites']);
return $data;
}
/**
* Cleans the entered addresses and refuses what already belongs elsewhere, before anything is written.
*/
private function normaliseWebsites(): void
{
$seen = [];
foreach ($this->websites as $index => $website) {
$hosts = [];
foreach ((array) ($website['hosts'] ?? []) as $host) {
$host = SiteDomain::normalise(is_string($host) ? $host : null);
if ($host === '') {
continue;
}
if (in_array($host, $seen, true)) {
throw ValidationException::withMessages([
'data.websites' => 'Die Adresse '.$host.' ist mehrfach eingetragen.',
]);
}
$seen[] = $host;
$hosts[] = $host;
}
$this->websites[$index]['hosts'] = $hosts;
}
$this->refuseForeignHosts($seen);
}
/**
* @param list<string> $hosts
*/
private function refuseForeignHosts(array $hosts): void
{
$ownIds = collect($this->websites)->pluck('id')->filter()->all();
$taken = SiteDomain::query()
->whereIn('host', $hosts)
->whereNotIn('site_id', $ownIds ?: [0])
->pluck('host');
if ($taken->isNotEmpty()) {
throw ValidationException::withMessages([
'data.websites' => 'Gehört bereits zu einer anderen Website: '.$taken->implode(', '),
]);
}
}
/**
* Writes the websites. A website that is new gets an empty home page straight away, because a website
* without one answers 404 and the landlord would have no way in.
*/
private function saveWebsites(): void
{
$tenant = $this->record;
if (! $tenant instanceof Tenant) {
return;
}
app(TenantContext::class)->run($tenant, function () use ($tenant): void {
$keep = [];
foreach ($this->websites as $website) {
$name = trim((string) ($website['name'] ?? ''));
if ($name === '') {
continue;
}
$hosts = (array) ($website['hosts'] ?? []);
$site = $this->siteFor($tenant, $website['id'] ?? null, $name, $hosts);
$keep[] = $site->id;
$site->domains()->whereNotIn('host', $hosts ?: [''])->delete();
foreach ($hosts as $host) {
SiteDomain::query()->updateOrCreate(['host' => $host], ['site_id' => $site->id]);
}
}
$tenant->sites()->whereNotIn('id', $keep ?: [0])->each(fn (Site $site) => $site->delete());
});
}
/**
* @param list<string> $hosts
*/
private function siteFor(Tenant $tenant, mixed $id, string $name, array $hosts): Site
{
$site = $id ? Site::query()->whereKey($id)->first() : null;
if ($site !== null) {
$site->update(['name' => $name, 'domain' => $hosts[0] ?? null]);
return $site;
}
$site = Site::query()->create([
'tenant_id' => $tenant->id,
'name' => $name,
'domain' => $hosts[0] ?? null,
'is_default' => $tenant->sites()->count() === 0,
'theme' => config('themes.base'),
]);
Page::query()->create([
'site_id' => $site->id,
'slug' => Page::HOME,
'title' => $name,
'sections' => [],
'is_published' => true,
]);
return $site;
}
}
@@ -0,0 +1,116 @@
<?php
namespace App\Filament\Operator\Pages;
use App\Enums\TenantServiceKey;
use App\Models\Tenant;
use App\Models\TenantAccessLog;
use App\Tenancy\TenantConfig;
use BackedEnum;
use Filament\Pages\Page;
use Filament\Support\Icons\Heroicon;
use Illuminate\Support\Collection;
/**
* What applies to the whole installation: the limits every landlord is bound by, the delivery path, and
* who opened whose admin. These values come from the server's .env and are deliberately not editable here –
* they protect the system against the landlords, so a landlord's admin must not be able to reach them.
*/
class SystemOverview extends Page
{
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedServerStack;
protected static ?string $navigationLabel = 'System';
protected static ?string $title = 'System';
protected static ?string $slug = 'system';
protected static ?int $navigationSort = 2;
protected string $view = 'filament.operator.system-overview';
/**
* The ceilings a landlord may tighten but never exceed.
*
* @return list<array{label: string, value: string, note: string}>
*/
public function limits(): array
{
$config = app(TenantConfig::class);
$rows = [
['Gästedaten löschen nach', 'fewo.guest_retention_years', 'Jahre', 'Ein Mandant kann kürzer löschen, nicht länger aufbewahren.'],
['Nicht gebuchte Anfragen löschen nach', 'fewo.retention.inquiry_months', 'Monate', ''],
['Portal-Mail-Auszug löschen nach', 'fewo.retention.portal_email_excerpt_days', 'Tage', ''],
['Herkunftsangaben löschen nach', 'fewo.retention.attribution_months', 'Monate', ''],
['Bot-Schutz: Mindestzeit im Formular', 'fewo.spam.min_seconds', 'Sekunden', 'Ein Mandant kann länger warten lassen, nicht kürzer.'],
['Bot-Schutz: Anfragen je IP und Stunde', 'fewo.spam.per_ip_per_hour', '', ''],
['Bot-Schutz: Anfragen je E-Mail und Tag', 'fewo.spam.per_email_per_day', '', ''],
['Bot-Schutz: offene Anfragen je E-Mail', 'fewo.spam.open_requests_per_email', '', ''],
['Bot-Schutz: Links im Text', 'fewo.spam.max_links', '', ''],
];
return array_map(fn (array $row): array => [
'label' => $row[0],
'value' => trim($config->baselineValue($row[1]).' '.$row[2]),
'note' => $row[3],
], $rows);
}
/**
* Values that belong to the whole installation and to no landlord.
*
* @return list<array{label: string, value: string, note: string}>
*/
public function global(): array
{
$redirect = config('fewo.mail_redirect_to');
return [
[
'label' => 'Anfragen aller Websites zusammen',
'value' => config('fewo.spam.total_per_hour').' je Stunde',
'note' => 'Flutgrenze über alle Mandanten. Kein Mandant kann sie anheben.',
],
[
'label' => 'Harte Mail-Umleitung',
'value' => filled($redirect) ? (string) $redirect : 'nicht gesetzt',
'note' => filled($redirect)
? 'FEWO_MAIL_REDIRECT_TO: jede E-Mail dieses Servers geht hierhin, auch bei scharf geschalteten Mandanten.'
: 'Ohne Umleitung entscheidet die Betriebsart des jeweiligen Mandanten.',
],
[
'label' => 'Versandweg',
'value' => (string) config('mail.default'),
'note' => 'SMTP-Zugang und Datenbank sind Infrastruktur und liegen in der .env des Servers.',
],
[
'label' => 'Datenbank-Sicherungen',
'value' => config('fewo.backup.keep').' Stück',
'note' => 'Eine Sicherung der ganzen Datenbank, über alle Mandanten.',
],
];
}
/**
* @return Collection<int, Tenant>
*/
public function tenants(): Collection
{
return Tenant::query()->withCount(['services' => fn ($query) => $query->where('is_enabled', true)])->orderBy('name')->get();
}
public function wiredServiceCount(): int
{
return count(TenantServiceKey::wired());
}
/**
* @return Collection<int, TenantAccessLog>
*/
public function accessLog(): Collection
{
return TenantAccessLog::query()->with(['tenant', 'user'])->latest('created_at')->limit(20)->get();
}
}
@@ -0,0 +1,114 @@
<?php
namespace App\Filament\Operator\Pages;
use App\Support\SystemSettings;
use BackedEnum;
use Filament\Actions\Action;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
use Filament\Pages\Page;
use Filament\Schemas\Components\Actions;
use Filament\Schemas\Components\EmbeddedSchema;
use Filament\Schemas\Components\Form;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\Text;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
/**
* The settings of the whole installation. They are the baseline every landlord is bound by, and a
* landlord's admin never reaches this page.
*
* Empty means: the value from the server's .env applies again. Database credentials and APP_KEY are not
* here and cannot be – they are needed to open the database and to decrypt what is stored in it.
*/
class SystemSettingsPage extends Page
{
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedAdjustmentsHorizontal;
protected static ?string $navigationLabel = 'Einstellungen';
protected static ?string $title = 'Systemweite Einstellungen';
protected static ?string $slug = 'einstellungen';
protected static ?int $navigationSort = 3;
/** @var array<string, mixed> */
public array $data = [];
public function mount(): void
{
$this->form->fill(collect(SystemSettings::EDITABLE)
->mapWithKeys(fn (array $definition, string $key): array => [self::field($key) => SystemSettings::get($key)])
->all());
}
public function form(Schema $schema): Schema
{
$sections = collect(SystemSettings::EDITABLE)
->groupBy(fn (array $definition): string => $definition[2], preserveKeys: true)
->map(fn ($group, string $section) => Section::make($section)
->columns(2)
->schema($group->keys()->map(fn (string $key) => $this->field_($key))->all()));
return $schema
->statePath('data')
->components([
Text::make('Leer lassen heißt: der Wert aus der .env des Servers gilt wieder. Datenbank-Zugang und APP_KEY stehen bewusst nicht hier – sie werden gebraucht, um die Datenbank überhaupt zu öffnen und das Gespeicherte zu entschlüsseln.'),
...$sections->values()->all(),
]);
}
public function content(Schema $schema): Schema
{
return $schema->components([
Form::make([EmbeddedSchema::make('form')])
->id('form')
->livewireSubmitHandler('save')
->footer([Actions::make([Action::make('save')->label('Speichern')->submit('save')])]),
]);
}
public function save(): void
{
$data = $this->form->getState();
SystemSettings::save(collect(SystemSettings::EDITABLE)
->mapWithKeys(fn (array $definition, string $key): array => [$key => $data[self::field($key)] ?? null])
->all());
Notification::make()->title('Gespeichert')->success()->send();
}
/**
* Config keys contain dots, which Filament would read as nesting.
*/
private static function field(string $key): string
{
return str_replace('.', '__', $key);
}
private function field_(string $key): TextInput|Select
{
[$label, $kind, , $help] = SystemSettings::EDITABLE[$key];
$name = self::field($key);
if ($kind === 'mailer') {
return Select::make($name)
->label($label)
->helperText($help)
->options(['smtp' => 'SMTP (echter Versand)', 'log' => 'Nur Logdatei (kein Versand)', 'array' => 'Verwerfen (nur für Tests)']);
}
$field = TextInput::make($name)->label($label)->helperText($help);
return match ($kind) {
'int' => $field->numeric()->integer()->minValue(0),
'secret' => $field->password()->revealable()->autocomplete(false),
default => $field,
};
}
}
+56 -3
View File
@@ -2,6 +2,7 @@
namespace App\Filament\Operator;
use App\Enums\TenantServiceKey;
use App\Filament\Operator\Tenants\Pages\CreateTenant;
use App\Filament\Operator\Tenants\Pages\EditTenant;
use App\Filament\Operator\Tenants\Pages\ListTenants;
@@ -10,14 +11,21 @@
use BackedEnum;
use Filament\Actions\Action;
use Filament\Actions\EditAction;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\TagsInput;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Resources\Resource;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\Text;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Columns\ToggleColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
class TenantResource extends Resource
{
@@ -48,9 +56,50 @@ public static function form(Schema $schema): Schema
->unique(ignoreRecord: true)
->maxLength(255),
Toggle::make('is_active')
->label('Aktiv')
->helperText('Ein gesperrter Mandant ist von außen nicht mehr erreichbar. Der Betreiber kommt weiter hinein.')
->default(true),
->label('Zugang freigeschaltet')
->helperText('Ausgeschaltet sehen Besucher statt der Webseite nur den Hinweis unten. Der Betreiber kommt weiter hinein.')
->default(true)
->live(),
Textarea::make('suspended_message')
->label('Hinweis bei gesperrtem Zugang')
->placeholder('Diese Webseite ist zurzeit nicht erreichbar. Bitte versuchen Sie es später noch einmal.')
->helperText('Leer = der Standardtext. Wird mit Status 503 ausgeliefert, damit Suchmaschinen die Seite nicht aus dem Index werfen.')
->rows(2)
->columnSpanFull(),
Section::make('Einsprungsadressen')
->description('Unter welchen Adressen dieser Mandant antwortet. Die Adresse muss zusätzlich beim Hoster einmalig auf dieses Verzeichnis gelegt werden – das passiert nicht hier. Ab dem zweiten Mandanten bekommt jede nicht eingetragene Adresse eine Fehlerseite.')
->columnSpanFull()
->schema([
Repeater::make('websites')
->label('Websites')
->addActionLabel('Weitere Website')
->defaultItems(1)
->itemLabel(fn (array $state): ?string => $state['name'] ?? null)
->schema([
Hidden::make('id'),
TextInput::make('name')
->label('Name der Website')
->required()
->maxLength(120),
TagsInput::make('hosts')
->label('Adressen')
->placeholder('beispiel.de')
->helperText('Jede Schreibweise ist eine eigene Adresse: „www.beispiel.de“ und „beispiel.de“ sind zwei. Die erste gilt als Hauptadresse und steht in Links an Gäste.')
->nestedRecursiveRules(['string', 'max:190']),
]),
]),
Section::make('Dienste')
->description('Was dieser Mandant nutzen darf. Ein gesperrter Dienst verschwindet auch aus seinem Admin – die Rolle eines Benutzers kann das nicht aufwiegen.')
->columnSpanFull()
->schema([
...array_map(fn (TenantServiceKey $service): Toggle => Toggle::make('services.'.$service->value.'.is_enabled')
->label($service->label())
->helperText($service->description()), TenantServiceKey::wired()),
Text::make('Noch nicht gebaut und deshalb nicht schaltbar: '.implode(', ', array_map(
fn (TenantServiceKey $service): string => $service->label(),
array_values(array_filter(TenantServiceKey::cases(), fn (TenantServiceKey $service): bool => ! $service->isWired())),
)).'. Diese Dienste erscheinen hier, sobald die Anwendung sie wirklich abfragt; eigene API-Schlüssel gehören dann in den Admin des Mandanten.'),
]),
]);
}
@@ -60,6 +109,10 @@ public static function table(Table $table): Table
->columns([
TextColumn::make('name')->label('Name')->searchable(),
TextColumn::make('slug')->label('Kurzname'),
TextColumn::make('services_count')
->label('Dienste frei')
->counts(['services' => fn (Builder $query): Builder => $query->where('is_enabled', true)])
->suffix(' von '.count(TenantServiceKey::wired())),
ToggleColumn::make('is_active')->label('Aktiv'),
])
->recordActions([
@@ -2,10 +2,13 @@
namespace App\Filament\Operator\Tenants\Pages;
use App\Filament\Operator\Concerns\EditsTenantSetup;
use App\Filament\Operator\TenantResource;
use Filament\Resources\Pages\CreateRecord;
class CreateTenant extends CreateRecord
{
use EditsTenantSetup;
protected static string $resource = TenantResource::class;
}
@@ -2,10 +2,13 @@
namespace App\Filament\Operator\Tenants\Pages;
use App\Filament\Operator\Concerns\EditsTenantSetup;
use App\Filament\Operator\TenantResource;
use Filament\Resources\Pages\EditRecord;
class EditTenant extends EditRecord
{
use EditsTenantSetup;
protected static string $resource = TenantResource::class;
}
@@ -5,6 +5,7 @@
use App\Filament\Operator\TenantResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
use Filament\Support\Icons\Heroicon;
class ListTenants extends ListRecords
{
@@ -13,7 +14,9 @@ class ListTenants extends ListRecords
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
CreateAction::make()
->label('Neuen Mandanten anlegen')
->icon(Heroicon::OutlinedPlus),
];
}
}
+178 -18
View File
@@ -2,12 +2,17 @@
namespace App\Filament\Pages;
use App\Enums\TenantServiceKey;
use App\Enums\UserRole;
use App\Filament\Concerns\FollowsAdminMode;
use App\Models\Tenant;
use App\Support\Settings;
use App\Tenancy\TenantConfig;
use App\Tenancy\TenantFeatures;
use BackedEnum;
use Filament\Actions\Action;
use Filament\Forms\Components\Radio;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TagsInput;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
@@ -23,13 +28,31 @@
use UnitEnum;
/**
* Operating mode (test mode sends every e-mail to one test recipient only; live delivers to the real recipients)
* and the addresses of the internal communication (notifications, contact/reply-to, sender). Administrators only.
* Operating data of the landlord: operating mode (test mode sends every e-mail to one test recipient only;
* live delivers to the real recipients), the addresses of the internal communication, the landlord's own
* address and bank details, and the periods. Administrators only.
*/
class Operations extends Page
{
use FollowsAdminMode;
/** Periods and counters the landlord may set (column => label). Empty means the system default. */
private const PERIODS = [
'deposit_due_days' => 'Anzahlung fällig nach (Tage)',
'review_request_after_days' => 'Bewertungsbitte nach Abreise (Tage)',
'guest_retention_years' => 'Gästedaten löschen nach (Jahre)',
'retention_inquiry_months' => 'Nicht gebuchte Anfragen löschen nach (Monate)',
'retention_portal_email_excerpt_days' => 'Portal-Mail-Auszug löschen nach (Tage)',
'retention_attribution_months' => 'Herkunftsangaben löschen nach (Monate)',
'spam_min_seconds' => 'Bot-Schutz: Mindestzeit im Formular (Sekunden)',
'spam_per_ip_per_hour' => 'Bot-Schutz: Anfragen je IP und Stunde',
'spam_per_email_per_day' => 'Bot-Schutz: Anfragen je E-Mail und Tag',
'spam_open_requests_per_email' => 'Bot-Schutz: gleichzeitig offene Anfragen je E-Mail',
'spam_max_links' => 'Bot-Schutz: erlaubte Links im Text',
'channel_stale_after_minutes' => 'Portal-Abgleich gilt als veraltet nach (Minuten)',
'channel_task_reminder_after_minutes' => 'Erinnerung an Portal-Aufgaben nach (Minuten)',
];
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedPower;
protected static string|UnitEnum|null $navigationGroup = 'System';
@@ -42,7 +65,7 @@ class Operations extends Page
protected static ?int $navigationSort = 1;
/** @var array<string, ?string> */
/** @var array<string, mixed> */
public array $data = [];
public static function canAccess(): bool
@@ -52,13 +75,31 @@ public static function canAccess(): bool
public function mount(): void
{
$tenant = $this->tenant();
$this->form->fill([
'mode' => Settings::get(Settings::MODE, Settings::MODE_TEST),
'test_recipient' => Settings::get(Settings::TEST_RECIPIENT) ?? auth()->user()?->email,
'notification_recipients' => Settings::notificationRecipients(),
'contact_email' => config('fewo.owner.email'),
'sender_name' => config('mail.from.name'),
'sender_email' => config('mail.from.address'),
'mode' => $tenant->operating_mode ?: Settings::MODE_TEST,
'test_recipient' => $tenant->test_recipient ?: auth()->user()?->email,
'notification_recipients' => $tenant->notificationRecipients(),
'contact_email' => $tenant->contact_email,
'sender_name' => $tenant->sender_name,
'sender_email' => $tenant->sender_email,
'owner_name' => $tenant->owner_name,
'owner_street' => $tenant->owner_street,
'owner_city' => $tenant->owner_city,
'owner_phone' => $tenant->owner_phone,
'bank_account_holder' => $tenant->bank_account_holder,
'bank_name' => $tenant->bank_name,
'bank_iban' => $tenant->bank_iban,
'bank_bic' => $tenant->bank_bic,
'tax_note' => $tenant->tax_note,
'mailbox_host' => $tenant->mailbox_host,
'mailbox_port' => $tenant->mailbox_port,
'mailbox_username' => $tenant->mailbox_username,
'mailbox_password' => $tenant->mailbox_password,
'mailbox_encryption' => $tenant->mailbox_encryption,
'mailbox_folder' => $tenant->mailbox_folder,
...$this->periodValues($tenant),
]);
}
@@ -117,6 +158,50 @@ public function form(Schema $schema): Schema
: '')
->columnSpanFull(),
]),
Section::make('Vermieterin')
->description('Steht in E-Mails, im Angebot, im Mietvertrag und auf der Webseite.')
->columns(2)
->schema([
TextInput::make('owner_name')->label('Name')->required()->maxLength(255),
TextInput::make('owner_phone')->label('Telefon')->maxLength(50),
TextInput::make('owner_street')->label('Straße und Hausnummer')->maxLength(255),
TextInput::make('owner_city')->label('PLZ und Ort')->maxLength(255),
]),
Section::make('Bankverbindung und Steuer')
->description('Steht im Mietvertrag und in den Zahlungsaufforderungen. Die Angaben liegen verschlüsselt in der Datenbank.')
->columns(2)
->schema([
TextInput::make('bank_account_holder')->label('Kontoinhaber')->maxLength(255),
TextInput::make('bank_name')->label('Bank')->maxLength(255),
TextInput::make('bank_iban')->label('IBAN')->maxLength(40),
TextInput::make('bank_bic')->label('BIC')->maxLength(20),
TextInput::make('tax_note')
->label('Steuerangabe')
->helperText('Zum Beispiel die Steuernummer oder der Hinweis auf die Kleinunternehmerregelung.')
->maxLength(255)
->columnSpanFull(),
]),
Section::make('Portal-Postfach')
->description('Aus diesem Postfach werden die Buchungsmails der Portale gelesen, damit ein Termin sofort gesperrt wird. Leerer Server = ausgeschaltet. Das Passwort liegt verschlüsselt in der Datenbank.')
->columns(2)
->collapsed()
->visible(fn (): bool => app(TenantFeatures::class)->enabled(TenantServiceKey::PortalMail))
->schema([
TextInput::make('mailbox_host')->label('IMAP-Server')->maxLength(190),
TextInput::make('mailbox_port')->label('Port')->numeric()->integer()->placeholder('993'),
TextInput::make('mailbox_username')->label('Benutzer')->maxLength(190),
TextInput::make('mailbox_password')->label('Passwort')->password()->revealable()->autocomplete(false)->maxLength(190),
Select::make('mailbox_encryption')
->label('Verschlüsselung')
->options(['ssl' => 'SSL', 'tls' => 'TLS', 'starttls' => 'STARTTLS'])
->placeholder('SSL'),
TextInput::make('mailbox_folder')->label('Ordner')->placeholder('INBOX')->maxLength(190),
]),
Section::make('Fristen und Grenzen')
->description('Leer bedeutet: die Vorgabe des Systems gilt. Löschfristen und Bot-Schutz lassen sich verschärfen, aber nicht über die Vorgabe hinaus lockern.')
->columns(3)
->collapsed()
->schema($this->periodFields()),
]);
}
@@ -133,20 +218,95 @@ public function content(Schema $schema): Schema
public function save(): void
{
$data = $this->form->getState();
$tenant = $this->tenant();
$wasLive = $tenant->isLive();
if ($data['mode'] === Settings::MODE_LIVE && Settings::get(Settings::MODE) !== Settings::MODE_LIVE) {
$tenant->update([
'operating_mode' => $data['mode'],
'test_recipient' => $data['test_recipient'] ?? $tenant->test_recipient,
'notification_emails' => implode(', ', Settings::addressList(implode(',', $data['notification_recipients'] ?? []))),
'contact_email' => $data['contact_email'],
'sender_name' => $data['sender_name'],
'sender_email' => $data['sender_email'],
'owner_name' => $data['owner_name'],
'owner_street' => $data['owner_street'] ?? null,
'owner_city' => $data['owner_city'] ?? null,
'owner_phone' => $data['owner_phone'] ?? null,
'bank_account_holder' => $data['bank_account_holder'] ?? null,
'bank_name' => $data['bank_name'] ?? null,
'bank_iban' => $data['bank_iban'] ?? null,
'bank_bic' => $data['bank_bic'] ?? null,
'tax_note' => $data['tax_note'] ?? null,
'mailbox_host' => $data['mailbox_host'] ?? null,
'mailbox_port' => filled($data['mailbox_port'] ?? null) ? (int) $data['mailbox_port'] : null,
'mailbox_username' => $data['mailbox_username'] ?? null,
'mailbox_password' => $data['mailbox_password'] ?? null,
'mailbox_encryption' => $data['mailbox_encryption'] ?? null,
'mailbox_folder' => $data['mailbox_folder'] ?? null,
...array_map(fn (mixed $value): ?int => filled($value) ? (int) $value : null, $this->periodInput($data)),
]);
app(TenantConfig::class)->refresh();
if ($data['mode'] === Settings::MODE_LIVE && ! $wasLive) {
Notification::make()->title('Scharf geschaltet')->body('Ab jetzt erhalten Gäste und Vermieterin die E-Mails direkt.')->warning()->send();
} else {
Notification::make()->title('Gespeichert')->success()->send();
}
}
Settings::save([
Settings::MODE => $data['mode'],
Settings::TEST_RECIPIENT => $data['test_recipient'] ?? Settings::get(Settings::TEST_RECIPIENT),
Settings::NOTIFICATION_RECIPIENTS => implode(', ', Settings::addressList(implode(',', $data['notification_recipients'] ?? []))),
Settings::CONTACT_EMAIL => $data['contact_email'],
Settings::SENDER_NAME => $data['sender_name'],
Settings::SENDER_EMAIL => $data['sender_email'],
]);
/**
* The landlord this page edits: the one of the request, else the only one there is.
*/
private function tenant(): Tenant
{
$tenant = Settings::tenant();
abort_if($tenant === null, 404);
return $tenant;
}
/**
* @return array<string, ?int>
*/
private function periodValues(Tenant $tenant): array
{
return array_combine(array_keys(self::PERIODS), array_map(fn (string $column): ?int => $tenant->{$column}, array_keys(self::PERIODS)));
}
/**
* @param array<string, mixed> $data
* @return array<string, mixed>
*/
private function periodInput(array $data): array
{
return array_combine(array_keys(self::PERIODS), array_map(fn (string $column): mixed => $data[$column] ?? null, array_keys(self::PERIODS)));
}
/**
* @return list<TextInput>
*/
private function periodFields(): array
{
return array_map(function (string $column) {
$field = TextInput::make($column)
->label(self::PERIODS[$column])
->numeric()
->integer()
->minValue(0);
$config = app(TenantConfig::class);
if (($ceiling = $config->ceilingFor($column)) !== null) {
return $field->maxValue($ceiling)->helperText('Vorgabe des Systems: höchstens '.$ceiling);
}
if (($floor = $config->floorFor($column)) !== null) {
return $field->minValue($floor)->helperText('Vorgabe des Systems: mindestens '.$floor);
}
return $field;
}, array_keys(self::PERIODS));
}
}
@@ -0,0 +1,56 @@
<?php
namespace App\Filament\Resources\FloorPlans;
use App\Filament\Concerns\FollowsAdminMode;
use App\Filament\Resources\FloorPlans\Pages\CreateFloorPlan;
use App\Filament\Resources\FloorPlans\Pages\EditFloorPlan;
use App\Filament\Resources\FloorPlans\Pages\ListFloorPlans;
use App\Filament\Resources\FloorPlans\Schemas\FloorPlanForm;
use App\Filament\Resources\FloorPlans\Tables\FloorPlansTable;
use App\Models\FloorPlan;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use UnitEnum;
/**
* Floor plan per apartment: picture from the website photos plus rooms drawn on it (section "Grundriss").
*/
class FloorPlanResource extends Resource
{
use FollowsAdminMode;
protected static ?string $model = FloorPlan::class;
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedMap;
protected static string|UnitEnum|null $navigationGroup = 'Webseite';
protected static ?string $modelLabel = 'Grundriss';
protected static ?string $pluralModelLabel = 'Grundriss';
protected static ?int $navigationSort = 5;
public static function form(Schema $schema): Schema
{
return FloorPlanForm::configure($schema);
}
public static function table(Table $table): Table
{
return FloorPlansTable::configure($table);
}
public static function getPages(): array
{
return [
'index' => ListFloorPlans::route('/'),
'create' => CreateFloorPlan::route('/create'),
'edit' => EditFloorPlan::route('/{record}/edit'),
];
}
}
@@ -0,0 +1,11 @@
<?php
namespace App\Filament\Resources\FloorPlans\Pages;
use App\Filament\Resources\FloorPlans\FloorPlanResource;
use Filament\Resources\Pages\CreateRecord;
class CreateFloorPlan extends CreateRecord
{
protected static string $resource = FloorPlanResource::class;
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\FloorPlans\Pages;
use App\Filament\Resources\FloorPlans\FloorPlanResource;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditFloorPlan extends EditRecord
{
protected static string $resource = FloorPlanResource::class;
protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
];
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\FloorPlans\Pages;
use App\Filament\Resources\FloorPlans\FloorPlanResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
class ListFloorPlans extends ListRecords
{
protected static string $resource = FloorPlanResource::class;
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
];
}
}
@@ -0,0 +1,81 @@
<?php
namespace App\Filament\Resources\FloorPlans\Schemas;
use App\Filament\Forms\Components\PhotoSelect;
use App\Models\Amenity;
use App\Models\FloorPlan;
use App\Models\Property;
use Closure;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\ViewField;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Schema;
use Illuminate\Support\Str;
class FloorPlanForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->columns(2)
->components([
Select::make('property_id')
->label('Wohnung')
->options(fn (): array => Property::query()->pluck('name', 'id')->all())
->default(fn (): ?int => Property::query()->value('id'))
->unique(ignoreRecord: true)
->validationMessages(['unique' => 'Für diese Wohnung gibt es schon einen Grundriss.'])
->required()
->live(),
PhotoSelect::make('photo_id')
->label('Grundriss-Bild')
->helperText('Rendering oder Plan aus Webseite › Fotos. Ein neues Bild im gleichen Ausschnitt behält die Räume.')
->required()
->live(),
Repeater::make('rooms')
->label('Räume')
->columnSpanFull()
->defaultItems(0)
->addActionLabel('Raum hinzufügen')
->reorderable()
->collapsible()
->itemLabel(fn (array $state): string => filled($state['name'] ?? null) ? $state['name'] : 'Neuer Raum')
->columns(2)
->schema([
Hidden::make('id')->default(fn (): string => (string) Str::uuid()),
TextInput::make('name')->label('Name')->placeholder('z. B. Schlafzimmer')->required()->maxLength(60)->live(onBlur: true),
Toggle::make('is_visible')->label('Auf der Website zeigen')->default(true)->inline(false),
ViewField::make('points')
->label('Fläche auf dem Grundriss')
->view('filament.forms.floor-plan-area')
->columnSpanFull()
->rules([
fn (): Closure => function (string $attribute, mixed $value, Closure $fail): void {
if (count(FloorPlan::points(is_string($value) ? $value : null)) < 3) {
$fail('Bitte mindestens drei Ecken des Raums auf dem Bild anklicken.');
}
},
]),
Textarea::make('description')->label('Beschreibung')->rows(3)->maxLength(400)->columnSpanFull(),
PhotoSelect::make('photo_ids')->label('Fotos')->multiple()->helperText('Das erste Foto steht oben, die weiteren als kleine Bilder darunter.'),
Select::make('amenity_ids')
->label('Ausstattung')
->multiple()
->searchable()
->options(fn (Get $get): array => Amenity::query()->where('property_id', $get('../../property_id'))->orderBy('sort_order')->pluck('name', 'id')->all())
->helperText('Aus Webseite › Ausstattung – nichts doppelt pflegen.'),
TextInput::make('hint')
->label('Hinweis zur Barrierefreiheit (optional)')
->placeholder('z. B. Flache Dusche mit kleiner Kante')
->maxLength(160)
->columnSpanFull(),
]),
]);
}
}
@@ -0,0 +1,26 @@
<?php
namespace App\Filament\Resources\FloorPlans\Tables;
use App\Models\FloorPlan;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class FloorPlansTable
{
public static function configure(Table $table): Table
{
return $table
->paginated(false)
->columns([
TextColumn::make('property.name')->label('Wohnung'),
TextColumn::make('rooms')->label('Räume')
->state(fn (FloorPlan $record): string => $record->visibleRooms()->pluck('name')->implode(', ') ?: 'noch keine'),
TextColumn::make('updated_at')->label('Geändert')->since(),
])
->recordActions([
EditAction::make(),
]);
}
}
@@ -21,6 +21,7 @@ public static function configure(Schema $schema): Schema
SpatieMediaLibraryFileUpload::make('image')
->label('Bild')
->collection(Photo::COLLECTION)
->disk('public')
->image()
->imageEditor()
->maxSize(25 * 1024)
@@ -3,6 +3,7 @@
namespace App\Filament\Resources\Properties\Schemas;
use App\Filament\Forms\Components\EuroInput;
use App\ImageWorlds\ImageWorldRegistry;
use App\Models\Site;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
@@ -52,6 +53,11 @@ public static function configure(Schema $schema): Schema
->label('Website')
->options(fn (): array => Site::query()->pluck('name', 'id')->all())
->placeholder('keine'),
Select::make('image_world')
->label('Bildwelt')
->options(fn (): array => app(ImageWorldRegistry::class)->options())
->placeholder('wie die Website')
->helperText('Nur setzen, wenn diese Wohnung anders aussehen soll als die Website – etwa eine Bergwohnung auf einer Küsten-Website.'),
Toggle::make('is_active')
->label('Aktiv (auf der Webseite buchbar)')
->default(true),
@@ -0,0 +1,33 @@
<?php
namespace App\Filament\Resources\Sites\Concerns;
use App\Models\Site;
/**
* Shows the hostnames of a website in the landlord's admin. Read only: addresses are given out by the
* operator, because every address also has to be wired to this directory at the hoster, and because a
* landlord must not be able to point somebody else's address at their own website.
*/
trait EditsSiteHosts
{
/**
* @param array<string, mixed> $data
* @return array<string, mixed>
*/
protected function mutateFormDataBeforeFill(array $data): array
{
$site = $this->record;
if (! $site instanceof Site) {
return $data;
}
$data['extra_hosts'] = $site->domains()
->where('host', '!=', (string) $site->domain)
->pluck('host')
->all();
return $data;
}
}
@@ -2,12 +2,15 @@
namespace App\Filament\Resources\Sites\Pages;
use App\Filament\Resources\Sites\Concerns\EditsSiteHosts;
use App\Filament\Resources\Sites\SiteResource;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditSite extends EditRecord
{
use EditsSiteHosts;
protected static string $resource = SiteResource::class;
protected function getHeaderActions(): array
@@ -3,10 +3,13 @@
namespace App\Filament\Resources\Sites\Schemas;
use App\Filament\Resources\Appearances\Schemas\AppearanceForm;
use App\ImageWorlds\ImageWorldRegistry;
use App\Models\Site;
use App\Themes\ThemeRegistry;
use Filament\Actions\Action;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
use Filament\Forms\Components\TagsInput;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Components\Section;
@@ -26,11 +29,16 @@ public static function configure(Schema $schema): Schema
->schema([
TextInput::make('name')->label('Name')->required()->maxLength(120),
TextInput::make('domain')
->label('Domain')
->placeholder('www.fewo-stommer.de')
->helperText('Leer = Standard-Website, solange es nur diesen Mandanten gibt. Ab dem zweiten Mandanten antwortet nur eine eingetragene Domain.')
->unique(ignoreRecord: true)
->maxLength(190),
->label('Hauptadresse')
->helperText('Steht in Links an Gäste. Adressen werden vom Betreiber vergeben, weil sie beim Hoster eingerichtet werden müssen.')
->disabled()
->dehydrated(false),
TagsInput::make('extra_hosts')
->label('Antwortet außerdem auf')
->placeholder('keine weitere Adresse')
->disabled()
->dehydrated(false)
->columnSpanFull(),
Select::make('theme')
->label('Theme')
->options(fn (): array => app(ThemeRegistry::class)->options())
@@ -44,8 +52,35 @@ public static function configure(Schema $schema): Schema
->icon('heroicon-o-eye')
->url(fn (Get $get): string => URL::temporarySignedRoute('home', now()->addDay(), ['theme' => $get('theme') ?: config('themes.base')]), shouldOpenInNewTab: true),
),
Select::make('image_world')
->label('Bildwelt')
->options(fn (): array => app(ImageWorldRegistry::class)->options())
->placeholder('Vorgabe der Installation')
->helperText(fn (Get $get): ?string => app(ImageWorldRegistry::class)->get($get('image_world'))?->description
?: 'Bänder, Vignetten und Ornamente dieser Website. Eine Wohnung kann eine andere Bildwelt tragen.'),
Toggle::make('is_default')->label('Standard-Website')->inline(false),
]),
Section::make('Marke')
->description('Logo, Favicon und das Logo für E-Mails und den Mietvertrag. Gehört dem Vermieter, nicht dem Theme – jede Website hat ihre eigene.')
->columns(3)
->collapsible()
->schema([
SpatieMediaLibraryFileUpload::make('logo')
->label('Logo')
->collection(Site::BRAND_LOGO)
->acceptedFileTypes(['image/svg+xml', 'image/png', 'image/webp'])
->helperText('SVG bevorzugt – bleibt in jeder Größe scharf.'),
SpatieMediaLibraryFileUpload::make('favicon')
->label('Favicon')
->collection(Site::BRAND_FAVICON)
->acceptedFileTypes(['image/svg+xml', 'image/png', 'image/x-icon'])
->helperText('Das kleine Zeichen im Browser-Tab.'),
SpatieMediaLibraryFileUpload::make('document_logo')
->label('Logo für E-Mail und Vertrag')
->collection(Site::BRAND_DOCUMENT_LOGO)
->acceptedFileTypes(['image/png', 'image/jpeg'])
->helperText('Als PNG oder JPG – E-Mail-Programme und der PDF-Druck zeichnen kein SVG.'),
]),
Section::make('Farben des Themes')
->description('Grundfarben dieser Website; saisonale Erscheinungsbilder können einzelne Farben zusätzlich ändern.')
->columns(3)
@@ -15,7 +15,8 @@ public static function configure(Table $table): Table
return $table
->columns([
TextColumn::make('name')->label('Website')->weight('medium'),
TextColumn::make('domain')->label('Domain')->placeholder('alle übrigen Adressen'),
TextColumn::make('domain')->label('Hauptadresse')->placeholder('alle übrigen Adressen'),
TextColumn::make('domains.host')->label('Antwortet auf')->badge()->placeholder('jede Adresse'),
TextColumn::make('theme')->label('Theme')->formatStateUsing(fn (string $state): string => app(ThemeRegistry::class)->get($state)->name),
TextColumn::make('properties_count')->label('Wohnungen')->counts('properties'),
IconColumn::make('is_default')->label('Standard')->boolean(),
+4 -2
View File
@@ -27,6 +27,8 @@ public function feed(string $token, ICalFeed $feed): Response
{
$channel = Channel::query()->where('export_token', $token)->where('is_active', true)->firstOrFail();
abort_unless($channel->servesItsLandlord(), 404);
return response($feed->build($channel), 200, [
'Content-Type' => 'text/calendar; charset=utf-8',
'Content-Disposition' => 'inline; filename="belegung.ics"',
@@ -49,8 +51,8 @@ public function health(Request $request): JsonResponse
$mailbox = [
'configured' => MailboxReader::isConfigured(),
'ok' => ! MonitorChannels::mailboxIsStale(),
'last_success_at' => Cache::get(MailboxReader::LAST_SUCCESS_KEY),
'last_error' => Cache::get(MailboxReader::LAST_ERROR_KEY),
'last_success_at' => Cache::get(MailboxReader::key(MailboxReader::LAST_SUCCESS_KEY)),
'last_error' => Cache::get(MailboxReader::key(MailboxReader::LAST_ERROR_KEY)),
];
$ok = $channels->every(fn (array $channel): bool => $channel['ok']) && $mailbox['ok'];
+33 -1
View File
@@ -2,6 +2,7 @@
namespace App\Http\Middleware;
use App\Models\Site;
use App\Models\Tenant;
use App\Models\User;
use App\Tenancy\TenantContext;
@@ -9,6 +10,7 @@
use App\Themes\ThemeFactory;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\URL;
use Symfony\Component\HttpFoundation\Response;
/**
@@ -36,15 +38,45 @@ public function handle(Request $request, Closure $next): Response
if ($tenant !== null) {
if (! $tenant->is_active && ! $this->operatorMayPass($request)) {
abort(404);
return $this->suspended($tenant);
}
$context->set($tenant);
}
$this->useSiteOrigin($theme->site);
return $next($request);
}
/**
* Links must carry the address the visitor came in on. AppServiceProvider forces APP_URL for every
* generated URL, because on Strato the document root is a release folder; with one landlord that was
* harmless, but a second website on its own domain would otherwise send every visitor to the first
* landlord's host. The forced root stays – only its value becomes the website that was resolved.
*/
private function useSiteOrigin(Site $site): void
{
$origin = $site->exists ? $site->origin() : null;
if ($origin === null) {
return;
}
URL::forceRootUrl($origin);
URL::forceScheme(parse_url($origin, PHP_URL_SCHEME) ?: 'https');
}
/**
* What a visitor of a suspended landlord sees: a plain notice instead of a dead link.
*/
private function suspended(Tenant $tenant): Response
{
return response()->view('suspended', [
'message' => $tenant->suspended_message ?: 'Diese Webseite ist zurzeit nicht erreichbar. Bitte versuchen Sie es später noch einmal.',
], 503);
}
/**
* A suspended landlord stays reachable for the operator, and the operator panel itself stays open.
*/
+77
View File
@@ -0,0 +1,77 @@
<?php
namespace App\ImageWorlds;
use JsonException;
use RuntimeException;
/**
* One picture world ("Bildwelt"): a folder with a world.json and SVG files, exactly like a theme is a
* folder with a theme.json. Themes ask for a slot (divider, vignette.beach …), never for a file, so a
* website can be dressed in "Ostsee" or later in "Berge" without touching a single template (A18/A19).
*/
class ImageWorldManifest
{
/**
* @param array<string, string> $slots slot => file name without .svg
*/
public function __construct(
public readonly string $key,
public readonly string $name,
public readonly ?string $description,
public readonly string $path,
public readonly array $slots,
) {}
public static function fromFile(string $file): self
{
try {
$data = json_decode((string) file_get_contents($file), true, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $exception) {
throw new RuntimeException('Bildwelt '.$file.' ist kein gültiges JSON: '.$exception->getMessage());
}
$path = dirname($file);
$key = basename($path);
return new self(
key: $key,
name: is_string($data['name'] ?? null) ? $data['name'] : $key,
description: is_string($data['description'] ?? null) ? $data['description'] : null,
path: $path,
slots: array_filter(
is_array($data['slots'] ?? null) ? $data['slots'] : [],
fn (mixed $file, mixed $slot): bool => is_string($slot) && is_string($file),
ARRAY_FILTER_USE_BOTH,
),
);
}
/**
* The file behind a slot, or null when this world does not fill it. A missing slot is not an error:
* a template asks for decoration and simply gets none.
*/
public function fileFor(string $slot): ?string
{
$name = $this->slots[$slot] ?? null;
if ($name === null) {
return null;
}
$file = $this->path.DIRECTORY_SEPARATOR.'svg'.DIRECTORY_SEPARATOR.$name.'.svg';
return is_file($file) ? $file : null;
}
/**
* @return list<string>
*/
public function missingFiles(): array
{
return array_values(array_filter(
array_keys($this->slots),
fn (string $slot): bool => $this->fileFor($slot) === null,
));
}
}
+52
View File
@@ -0,0 +1,52 @@
<?php
namespace App\ImageWorlds;
/**
* Discovers the picture worlds below config('image-worlds.paths'), the same way themes are discovered.
*/
class ImageWorldRegistry
{
/** @var array<string, ImageWorldManifest>|null */
private ?array $worlds = null;
/**
* @return array<string, ImageWorldManifest>
*/
public function all(): array
{
if ($this->worlds === null) {
$this->worlds = [];
foreach (config('image-worlds.paths') as $path) {
foreach (glob(rtrim($path, '/\\').'/*/world.json') ?: [] as $file) {
$manifest = ImageWorldManifest::fromFile($file);
$this->worlds[$manifest->key] = $manifest;
}
}
ksort($this->worlds);
}
return $this->worlds;
}
public function get(?string $key): ?ImageWorldManifest
{
if ($key === null || $key === '') {
return null;
}
return $this->all()[$key] ?? null;
}
/**
* Key => name, for a select in the admin.
*
* @return array<string, string>
*/
public function options(): array
{
return array_map(fn (ImageWorldManifest $world): string => $world->name, $this->all());
}
}
+65
View File
@@ -0,0 +1,65 @@
<?php
namespace App\ImageWorlds;
use App\Themes\Theme;
use Illuminate\Support\HtmlString;
use Illuminate\Support\Str;
/**
* Renders the graphic behind a slot. Inline SVG, so the graphics take the text colour and need no second
* request; the ids inside are made unique per call, because two copies of the same gradient on one page
* would otherwise refer to the same definition and one of them would lose its colours.
*
* Which world applies: the apartment overrules the website (A20), the website overrules the installation.
*/
class MotifRenderer
{
/** @var array<string, string> */
private array $cache = [];
public function render(string $slot, ?string $class = null, ?string $label = null): HtmlString
{
$world = $this->world();
$file = $world?->fileFor($slot);
if ($file === null) {
return new HtmlString(''); // a template asks for decoration and gets none
}
$svg = $this->cache[$file] ??= (string) file_get_contents($file);
if ($svg === '') {
return new HtmlString('');
}
$unique = 'm'.Str::lower(Str::random(6));
$svg = (string) preg_replace(['/\s(role|aria-label|aria-hidden)="[^"]*"/', '/<title>.*?<\/title>/s'], '', $svg);
$svg = (string) preg_replace(['/id="([^"]+)"/', '/url\(#([^)]+)\)/'], ['id="$1-'.$unique.'"', 'url(#$1-'.$unique.')'], $svg);
$attributes = 'class="'.e((string) $class).'" '.($label !== null
? 'role="img" aria-label="'.e($label).'"'
: 'aria-hidden="true" focusable="false"');
return new HtmlString((string) preg_replace('/<svg\s/', '<svg '.$attributes.' ', $svg, 1));
}
public function has(string $slot): bool
{
return $this->world()?->fileFor($slot) !== null;
}
/**
* The picture world in force for what is being rendered right now.
*/
public function world(): ?ImageWorldManifest
{
$registry = app(ImageWorldRegistry::class);
$theme = app()->bound(Theme::class) ? app(Theme::class) : null;
return $registry->get($theme?->property()?->image_world)
?? $registry->get($theme?->site->image_world)
?? $registry->get(config('image-worlds.default'));
}
}
+12 -1
View File
@@ -4,7 +4,9 @@
use App\Channels\ChannelRegistry;
use App\Channels\Contracts\ChannelConnector;
use App\Enums\TenantServiceKey;
use App\Models\Concerns\BelongsToTenant;
use App\Tenancy\TenantFeatures;
use Database\Factories\ChannelFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Hidden;
@@ -100,7 +102,16 @@ public function connector(): ChannelConnector
public function importsOccupations(): bool
{
return $this->is_active && $this->connector()->canImport($this);
return $this->is_active && $this->servesItsLandlord() && $this->connector()->canImport($this);
}
/**
* Whether the landlord this channel belongs to has the portal synchronisation unlocked at all.
* Asked here, so that neither an import nor the export feed can run around the switch.
*/
public function servesItsLandlord(): bool
{
return app(TenantFeatures::class)->enabled(TenantServiceKey::PortalSync, $this->tenant);
}
public function exportUrl(): string
+1 -1
View File
@@ -66,7 +66,7 @@ public static function bootBelongsToTenant(): void
}
if (app()->runningUnitTests() && ! app(TenantContext::class)->isRequired()) {
$model->setAttribute('tenant_id', Tenant::query()->create([
$model->setAttribute('tenant_id', Tenant::factory()->create([
'name' => 'Testmandant',
'slug' => 'test-'.Str::lower(Str::random(10)),
])->id);
+81
View File
@@ -0,0 +1,81 @@
<?php
namespace App\Models;
use App\Models\Concerns\BelongsToTenant;
use Database\Factories\FloorPlanFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Collection;
/**
* Floor plan of an apartment: a picture (rendering or scan) from the website photos and the rooms drawn
* on it. Room corners are stored in percent of the picture, so the areas fit every picture size.
*
* @property list<array{id?: string, name?: string, description?: string, hint?: string, points?: string, photo_ids?: list<int|string>, amenity_ids?: list<int|string>, is_visible?: bool}>|null $rooms
*/
#[Fillable(['property_id', 'photo_id', 'rooms'])]
class FloorPlan extends Model
{
/** @use HasFactory<FloorPlanFactory> */
use BelongsToTenant, HasFactory;
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'rooms' => 'array',
];
}
/**
* @return BelongsTo<Property, $this>
*/
public function property(): BelongsTo
{
return $this->belongsTo(Property::class);
}
/**
* @return BelongsTo<Photo, $this>
*/
public function photo(): BelongsTo
{
return $this->belongsTo(Photo::class);
}
/**
* Rooms shown on the website: visible and with an area of at least three corners.
*
* @return Collection<int, array<string, mixed>>
*/
public function visibleRooms(): Collection
{
return collect($this->rooms ?? [])
->filter(fn (array $room): bool => ($room['is_visible'] ?? true) && filled($room['name'] ?? null) && count(self::points($room['points'] ?? null)) >= 3)
->values();
}
/**
* Parses "x,y x,y …" (percent) into points, ignoring anything outside 0–100.
*
* @return list<array{float, float}>
*/
public static function points(?string $points): array
{
$parsed = [];
foreach (preg_split('/\s+/', trim((string) $points)) ?: [] as $pair) {
if (preg_match('/^(\d{1,3}(?:\.\d+)?),(\d{1,3}(?:\.\d+)?)$/', $pair, $match) && (float) $match[1] <= 100 && (float) $match[2] <= 100) {
$parsed[] = [(float) $match[1], (float) $match[2]];
}
}
return $parsed;
}
}
+2
View File
@@ -45,7 +45,9 @@ protected function casts(): array
public function registerMediaCollections(): void
{
// Website photos are public files; the app's default disk (FILESYSTEM_DISK=local) is private.
$this->addMediaCollection(self::COLLECTION)
->useDisk('public')
->singleFile()
->acceptsMimeTypes(['image/jpeg', 'image/png', 'image/webp']);
}
+10
View File
@@ -10,6 +10,7 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
/**
* A rentable holiday apartment. All money amounts are stored in euro cents.
@@ -18,6 +19,7 @@
'site_id',
'name',
'slug',
'image_world',
'address',
'size_sqm',
'max_guests',
@@ -115,6 +117,14 @@ public function amenities(): HasMany
return $this->hasMany(Amenity::class)->orderBy('sort_order');
}
/**
* @return HasOne<FloorPlan, $this>
*/
public function floorPlan(): HasOne
{
return $this->hasOne(FloorPlan::class);
}
/**
* @return HasMany<SpecialOffer, $this>
*/
+34
View File
@@ -0,0 +1,34 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* One use of a service by a landlord. Nothing writes usages yet because no service calls out.
*/
#[Fillable(['tenant_id', 'service', 'quantity', 'used_at'])]
class ServiceUsage extends Model
{
public $timestamps = false;
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'used_at' => 'datetime',
];
}
/**
* @return BelongsTo<Tenant, $this>
*/
public function tenant(): BelongsTo
{
return $this->belongsTo(Tenant::class);
}
}
-12
View File
@@ -1,12 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
/**
* One operational setting (key → value), read through App\Support\Settings.
*/
#[Fillable(['key', 'value'])]
class Setting extends Model {}
+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')) {
+13
View File
@@ -12,6 +12,19 @@
#[Fillable(['site_id', 'host'])]
class SiteDomain extends Model
{
/**
* Turns what someone typed into a bare hostname: "https://WWW.Example.de/" becomes "www.example.de".
* Returns an empty string when nothing usable is left, so callers can skip it.
*/
public static function normalise(?string $value): string
{
$host = mb_strtolower(trim((string) $value));
$host = (string) preg_replace('~^[a-z]+://~', '', $host);
$host = (string) preg_replace('~[/?#].*$~', '', $host);
return trim($host, '.');
}
/**
* @return BelongsTo<Site, $this>
*/
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
/**
* One setting of the whole installation, read through App\Support\SystemSettings. Belongs to no landlord;
* only the operator ever writes it. Secrets are stored encrypted by the service, not by a cast, because
* the value column also holds plain numbers.
*/
#[Fillable(['key', 'value', 'is_secret'])]
class SystemSetting extends Model
{
/** @var list<string> */
protected $hidden = ['value'];
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'is_secret' => 'boolean',
];
}
}
+74 -2
View File
@@ -2,6 +2,8 @@
namespace App\Models;
use App\Support\Settings;
use App\Tenancy\TenantDefaults;
use Database\Factories\TenantFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
@@ -13,7 +15,18 @@
* A landlord. Owns websites, apartments, guests, bookings and settings. One account can belong
* to several landlords; the operator is not a landlord.
*/
#[Fillable(['name', 'slug', 'is_active'])]
#[Fillable([
'name', 'slug', 'is_active',
'owner_name', 'owner_street', 'owner_city', 'owner_phone', 'contact_email', 'notification_emails',
'sender_name', 'sender_email',
'bank_account_holder', 'bank_iban', 'bank_bic', 'bank_name', 'tax_note',
'operating_mode', 'test_recipient', 'suspended_message',
'mailbox_host', 'mailbox_port', 'mailbox_encryption', 'mailbox_username', 'mailbox_password', 'mailbox_folder',
'deposit_due_days', 'review_request_after_days', 'guest_retention_years', 'retention_inquiry_months',
'retention_portal_email_excerpt_days', 'retention_attribution_months',
'spam_min_seconds', 'spam_per_ip_per_hour', 'spam_per_email_per_day', 'spam_open_requests_per_email', 'spam_max_links',
'channel_stale_after_minutes', 'channel_task_reminder_after_minutes',
])]
class Tenant extends Model
{
/** @use HasFactory<TenantFactory> */
@@ -26,7 +39,7 @@ public static function stommer(): self
{
return static::query()->firstOrCreate(
['slug' => 'stommer'],
['name' => 'Stommer'],
['name' => 'Stommer'] + TenantDefaults::forLegacyLandlord(encryptBank: false),
);
}
@@ -37,6 +50,12 @@ protected function casts(): array
{
return [
'is_active' => 'boolean',
'bank_account_holder' => 'encrypted',
'bank_iban' => 'encrypted',
'bank_bic' => 'encrypted',
'bank_name' => 'encrypted',
'tax_note' => 'encrypted',
'mailbox_password' => 'encrypted',
];
}
@@ -56,6 +75,59 @@ public function properties(): HasMany
return $this->hasMany(Property::class);
}
/**
* @return HasMany<TenantService, $this>
*/
public function services(): HasMany
{
return $this->hasMany(TenantService::class);
}
/**
* @return HasMany<ServiceUsage, $this>
*/
public function serviceUsages(): HasMany
{
return $this->hasMany(ServiceUsage::class);
}
/**
* The mailbox this landlord reads portal notifications from, or null when they have none. An empty
* host means the fast path is simply off for them.
*
* @return array{host: string, port: int, encryption: string, username: string, password: ?string, folder: string}|null
*/
public function mailbox(): ?array
{
if (blank($this->mailbox_host) || blank($this->mailbox_username)) {
return null;
}
return [
'host' => (string) $this->mailbox_host,
'port' => (int) ($this->mailbox_port ?: 993),
'encryption' => (string) ($this->mailbox_encryption ?: 'ssl'),
'username' => (string) $this->mailbox_username,
'password' => $this->mailbox_password,
'folder' => (string) ($this->mailbox_folder ?: 'INBOX'),
];
}
public function isLive(): bool
{
return $this->operating_mode === 'live';
}
/**
* Notification addresses of this landlord.
*
* @return list<string>
*/
public function notificationRecipients(): array
{
return Settings::addressList($this->notification_emails);
}
/**
* @return BelongsToMany<User, $this>
*/
+37
View File
@@ -0,0 +1,37 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* A service the operator switched on for a landlord. The own API key is optional and stored encrypted;
* an empty key means that the operator's key applies (no service calls it yet).
*/
#[Fillable(['tenant_id', 'service', 'is_enabled', 'api_key'])]
class TenantService extends Model
{
/** @var list<string> */
protected $hidden = ['api_key'];
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'is_enabled' => 'boolean',
'api_key' => 'encrypted',
];
}
/**
* @return BelongsTo<Tenant, $this>
*/
public function tenant(): BelongsTo
{
return $this->belongsTo(Tenant::class);
}
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Policies;
use App\Enums\Permission;
class FloorPlanPolicy extends RolePolicy
{
protected function permission(): Permission
{
return Permission::Content;
}
}
+11 -1
View File
@@ -4,6 +4,7 @@
use App\Enums\Permission;
use App\Models\User;
use App\Tenancy\TenantFeatures;
/**
* Grants every ability that the current membership includes. The operator counts as administrator
@@ -48,8 +49,17 @@ public function reorder(User $user): bool
return $this->allows($user);
}
/**
* Both questions, in one place: the role says what this user may do, TenantFeatures says what the
* landlord has unlocked at all. An administrator of a landlord without the portal services does not
* reach the portal screens either – no role grants what the landlord does not have.
*/
protected function allows(User $user): bool
{
return (bool) $user->currentRole()?->grants($this->permission());
if (! $user->currentRole()?->grants($this->permission())) {
return false;
}
return app(TenantFeatures::class)->permits($this->permission());
}
}
+3 -1
View File
@@ -6,7 +6,9 @@
use App\Models\User;
/**
* Landlords are created and suspended by the operator. Deleting one is a later, separate step.
* Landlords are created and suspended by the operator. Deleting one is deliberately not an action in the
* panel: it removes data and files for good. It happens through `php artisan tenants:delete <slug>`, which
* writes an export first and asks before it acts.
*/
class TenantPolicy
{
+14 -4
View File
@@ -2,13 +2,15 @@
namespace App\Providers;
use App\Support\Settings;
use App\Support\StripImageMetadata;
use App\Support\SystemSettings;
use App\Tenancy\TenantConfig;
use App\Tenancy\TenantContext;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
use Spatie\MediaLibrary\MediaCollections\Events\MediaHasBeenAddedEvent;
use Throwable;
class AppServiceProvider extends ServiceProvider
{
@@ -18,6 +20,7 @@ class AppServiceProvider extends ServiceProvider
public function register(): void
{
$this->app->singleton(TenantContext::class);
$this->app->singleton(TenantConfig::class);
}
/**
@@ -25,9 +28,16 @@ public function register(): void
*/
public function boot(): void
{
// Test mode (System › Betrieb, default until switched live): every e-mail goes to the test recipient only.
Settings::applyAddressOverrides();
Settings::applyMailRouting();
// Settings of the installation first (they become the baseline a landlord may tighten), then the
// operating data of the landlord: addresses, periods and test mode, which sends every e-mail to the
// test recipient only until a landlord is switched live. Console and boot know the landlord only if
// there is exactly one.
try {
SystemSettings::apply();
$this->app->make(TenantConfig::class)->refresh();
} catch (Throwable) {
// no database yet (package discovery, first install)
}
// Photos: remove metadata (GPS position, camera data) from uploaded originals, which stay downloadable.
Event::listen(MediaHasBeenAddedEvent::class, fn (MediaHasBeenAddedEvent $event) => StripImageMetadata::strip($event->media));
@@ -2,6 +2,8 @@
namespace App\Providers\Filament;
use App\Filament\Operator\Pages\SystemOverview;
use App\Filament\Operator\Pages\SystemSettingsPage;
use App\Http\Middleware\ResolveTheme;
use Filament\Auth\MultiFactor\App\AppAuthentication;
use Filament\Http\Middleware\Authenticate;
@@ -40,6 +42,8 @@ public function panel(Panel $panel): Panel
->discoverResources(in: app_path('Filament/Operator'), for: 'App\Filament\Operator')
->pages([
Dashboard::class,
SystemOverview::class,
SystemSettingsPage::class,
])
->widgets([
AccountWidget::class,
+24 -76
View File
@@ -2,72 +2,37 @@
namespace App\Support;
use App\Models\Setting;
use Illuminate\Mail\MailManager;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Mail;
use Throwable;
use App\Models\Tenant;
use App\Tenancy\TenantConfig;
/**
* Operational settings from the admin (System › Betrieb), cached. The most important one: the operating mode.
* Operating mode and addresses of the current landlord (admin page System › Betrieb, stored on the landlord).
* In **test mode** (the default until the site is switched live) every e-mail goes to the test recipient only,
* whatever address was entered on the website.
* whatever address was entered on the website. Without any landlord the .env values apply.
*/
class Settings
{
public const MODE = 'operations.mode';
public const TEST_RECIPIENT = 'operations.test_recipient';
/** Comma-separated: who is informed about new requests, answered offers, portal events … */
public const NOTIFICATION_RECIPIENTS = 'addresses.notifications';
/** Contact address shown on the website and in the contract; reply-to of guest mails. */
public const CONTACT_EMAIL = 'addresses.contact';
public const SENDER_EMAIL = 'addresses.sender_email';
public const SENDER_NAME = 'addresses.sender_name';
public const MODE_TEST = 'test';
public const MODE_LIVE = 'live';
private const CACHE_KEY = 'settings.all';
public static function get(string $key, ?string $default = null): ?string
{
try {
$values = Cache::rememberForever(self::CACHE_KEY, fn (): array => Setting::query()->pluck('value', 'key')->all());
} catch (Throwable) {
return $default; // e.g. before the migrations ran
}
return $values[$key] ?? $default;
}
/**
* @param array<string, ?string> $values
* The landlord of the context, else the only landlord.
*/
public static function save(array $values): void
public static function tenant(): ?Tenant
{
foreach ($values as $key => $value) {
Setting::query()->updateOrCreate(['key' => $key], ['value' => $value]);
}
Cache::forget(self::CACHE_KEY);
self::applyAddressOverrides();
self::applyMailRouting();
return app(TenantConfig::class)->effectiveTenant();
}
/**
* The recipients of internal notifications (admin setting, else FEWO_NOTIFICATION_EMAIL).
* The recipients of internal notifications (the landlord's setting, else FEWO_NOTIFICATION_EMAIL while no landlord is known).
*
* @return list<string>
*/
public static function notificationRecipients(): array
{
return self::addressList(self::get(self::NOTIFICATION_RECIPIENTS) ?: (string) config('fewo.notification_email'));
return self::tenant()?->notificationRecipients()
?: self::addressList((string) config('fewo.notification_email'));
}
/**
@@ -83,25 +48,9 @@ public static function addressList(?string $value): array
));
}
/**
* Admin settings for the contact address and the sender override the .env values for this request.
*/
public static function applyAddressOverrides(): void
{
$overrides = array_filter([
'fewo.owner.email' => self::get(self::CONTACT_EMAIL),
'mail.from.address' => self::get(self::SENDER_EMAIL),
'mail.from.name' => self::get(self::SENDER_NAME),
]);
if ($overrides !== []) {
config($overrides);
}
}
public static function isLive(): bool
{
return self::get(self::MODE, self::MODE_TEST) === self::MODE_LIVE;
return (self::tenant()?->operating_mode ?? self::MODE_TEST) === self::MODE_LIVE;
}
/**
@@ -109,34 +58,33 @@ public static function isLive(): bool
* FEWO_MAIL_REDIRECT_TO in .env always wins (hard override for test servers).
*/
public static function mailRedirect(): ?string
{
return self::mailRedirectFor(self::tenant());
}
public static function mailRedirectFor(?Tenant $tenant): ?string
{
$override = config('fewo.mail_redirect_to');
if (filled($override)) {
return (string) $override;
}
if (self::isLive()) {
if ($tenant?->isLive()) {
return null;
}
return self::get(self::TEST_RECIPIENT) ?: (self::notificationRecipients()[0] ?? null);
// A landlord without any address of their own must not fall through to normal delivery: the operator's
// address catches the mails until the landlord has entered their own.
$recipients = $tenant?->notificationRecipients() ?: self::addressList((string) config('fewo.notification_email'));
return $tenant?->test_recipient ?: ($recipients[0] ?? null);
}
/**
* Applies the redirect to the mailer; called at boot and after saving.
* Applies the redirect of the current landlord to the mailer; called after saving.
*/
public static function applyMailRouting(): void
{
$manager = Mail::getFacadeRoot();
if (! $manager instanceof MailManager) {
return; // Mail::fake() in tests
}
$redirect = self::mailRedirect();
$manager->purge();
if (filled($redirect)) {
$manager->alwaysTo($redirect);
}
app(TenantConfig::class)->refresh();
}
}
+162
View File
@@ -0,0 +1,162 @@
<?php
namespace App\Support;
use App\Models\SystemSetting;
use Illuminate\Support\Facades\Cache;
use Throwable;
/**
* Settings of the whole installation, owned by the operator. They are laid over the configuration at boot,
* before any landlord is known, so `config('fewo.*')` keeps being the one place the rest of the code reads.
*
* This is not the old `settings` table in a new coat: that one held a single landlord's operating data,
* which now lives on `tenants`. What is kept here belongs to no landlord and is never reachable from a
* landlord's admin.
*
* Database credentials and APP_KEY cannot be kept here. They are needed to open the database and to decrypt
* what is in it, so they have to be readable before any of this exists – they stay in the server's .env.
*/
class SystemSettings
{
/**
* Editable keys: config key => [label, kind, section, help]. The kind decides the form field and
* whether the value is stored encrypted.
*
* @var array<string, array{0: string, 1: string, 2: string, 3: string}>
*/
public const EDITABLE = [
'fewo.guest_retention_years' => ['Gästedaten löschen nach (Jahre)', 'int', 'Löschfristen', 'Obergrenze für alle Mandanten; ein Mandant kann kürzer löschen.'],
'fewo.retention.inquiry_months' => ['Nicht gebuchte Anfragen löschen nach (Monate)', 'int', 'Löschfristen', ''],
'fewo.retention.portal_email_excerpt_days' => ['Portal-Mail-Auszug löschen nach (Tage)', 'int', 'Löschfristen', ''],
'fewo.retention.attribution_months' => ['Herkunftsangaben löschen nach (Monate)', 'int', 'Löschfristen', ''],
'fewo.spam.min_seconds' => ['Mindestzeit im Formular (Sekunden)', 'int', 'Bot-Schutz', 'Untergrenze; ein Mandant kann länger warten lassen.'],
'fewo.spam.per_ip_per_hour' => ['Anfragen je IP und Stunde', 'int', 'Bot-Schutz', ''],
'fewo.spam.per_email_per_day' => ['Anfragen je E-Mail und Tag', 'int', 'Bot-Schutz', ''],
'fewo.spam.open_requests_per_email' => ['Gleichzeitig offene Anfragen je E-Mail', 'int', 'Bot-Schutz', ''],
'fewo.spam.max_links' => ['Erlaubte Links im Text', 'int', 'Bot-Schutz', ''],
'fewo.spam.total_per_hour' => ['Anfragen aller Websites zusammen, je Stunde', 'int', 'Bot-Schutz', 'Flutgrenze über alle Mandanten. Kein Mandant kann sie anheben.'],
'fewo.channels.stale_after_minutes' => ['Portal-Abgleich gilt als veraltet nach (Minuten)', 'int', 'Portale', ''],
'fewo.channels.task_reminder_after_minutes' => ['Erinnerung an Portal-Aufgaben nach (Minuten)', 'int', 'Portale', ''],
'fewo.backup.keep' => ['Aufbewahrte Datenbank-Sicherungen', 'int', 'Sicherung', 'Eine Sicherung der ganzen Datenbank, über alle Mandanten.'],
'mail.default' => ['Versandweg', 'mailer', 'E-Mail-Versand', '„log“ schreibt jede E-Mail nur in die Logdatei und versendet nichts.'],
'mail.mailers.smtp.host' => ['SMTP-Server', 'text', 'E-Mail-Versand', ''],
'mail.mailers.smtp.port' => ['SMTP-Port', 'int', 'E-Mail-Versand', ''],
'mail.mailers.smtp.username' => ['SMTP-Benutzer', 'text', 'E-Mail-Versand', 'Die Absenderadresse eines Mandanten muss zu diesem Postfach passen, sonst lehnt Strato ab.'],
'mail.mailers.smtp.password' => ['SMTP-Passwort', 'secret', 'E-Mail-Versand', ''],
'fewo.mail_redirect_to' => ['Harte Umleitung aller E-Mails', 'text', 'E-Mail-Versand', 'Gefüllt: JEDE E-Mail dieses Servers geht nur hierhin, auch bei scharf geschalteten Mandanten. Leer: die Betriebsart jedes Mandanten entscheidet allein.'],
'fewo.scheduler_token' => ['Scheduler-Token', 'secret', 'Schnittstellen', 'Für GET /automation/scheduler. Leer = abgeschaltet.'],
'fewo.channels.health_token' => ['Health-Token', 'secret', 'Schnittstellen', 'Für GET /health/sync. Leer = abgeschaltet.'],
'fewo.automation.webhook_url' => ['Automation: Adresse', 'text', 'Schnittstellen', ''],
'fewo.automation.secret' => ['Automation: Geheimnis', 'secret', 'Schnittstellen', ''],
];
private const CACHE_KEY = 'system-settings';
/**
* What the server configured, before anything stored was laid over it. Captured once per process.
*
* @var array<string, mixed>
*/
private static array $baseline = [];
/**
* Lays the stored values over the configuration. Called at boot before any landlord is resolved, so
* TenantConfig takes these as its baseline.
*/
public static function apply(): void
{
$stored = self::stored();
$values = [];
foreach (array_keys(self::EDITABLE) as $key) {
if (! array_key_exists($key, self::$baseline)) {
self::$baseline[$key] = config($key);
}
// A key the operator cleared has to give the .env value back in the same request, not only
// after the next boot – otherwise an emptied field looks saved while the old value still acts.
$values[$key] = array_key_exists($key, $stored)
? self::cast($key, $stored[$key])
: self::$baseline[$key];
}
config($values);
}
/**
* The value in force: what the operator stored, else what the server's .env configured.
*/
public static function get(string $key): mixed
{
$stored = self::stored();
return array_key_exists($key, $stored) ? self::cast($key, $stored[$key]) : config($key);
}
/**
* @param array<string, mixed> $values config key => value; null or "" falls back to the .env again
*/
public static function save(array $values): void
{
foreach ($values as $key => $value) {
if (! array_key_exists($key, self::EDITABLE)) {
continue;
}
$isSecret = self::EDITABLE[$key][1] === 'secret';
if (blank($value)) {
SystemSetting::query()->where('key', $key)->delete();
continue;
}
SystemSetting::query()->updateOrCreate(
['key' => $key],
['value' => $isSecret ? encrypt((string) $value) : (string) $value, 'is_secret' => $isSecret],
);
}
Cache::forget(self::CACHE_KEY);
self::apply();
}
public static function forget(): void
{
Cache::forget(self::CACHE_KEY);
self::$baseline = [];
}
/**
* @return array<string, ?string>
*/
private static function stored(): array
{
try {
return Cache::rememberForever(self::CACHE_KEY, fn (): array => SystemSetting::query()->pluck('value', 'key')->all());
} catch (Throwable) {
return []; // before the migrations ran
}
}
private static function cast(string $key, ?string $value): mixed
{
if ($value === null) {
return null;
}
$kind = self::EDITABLE[$key][1] ?? 'text';
return match ($kind) {
'int' => (int) $value,
'secret' => rescue(fn (): string => decrypt($value), null, report: false),
default => $value,
};
}
}
+234
View File
@@ -0,0 +1,234 @@
<?php
namespace App\Tenancy;
use App\Models\Photo;
use App\Models\Tenant;
use App\Models\User;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Schema;
use RuntimeException;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
use ZipArchive;
/**
* Hands a landlord their data back and removes them (A25). Everything of one landlord is reachable by
* `tenant_id`, so neither is a join across eight levels – it is a list of tables.
*/
class TenantArchive
{
/**
* Child rows first, so foreign keys allow the delete. The reverse order is the one in which the rows
* were assigned when tenancy was introduced.
*
* @var list<string>
*/
private const DELETE_ORDER = [
'floor_plans',
'channel_sync_logs',
'channel_tasks',
'portal_emails',
'payments',
'reviews',
'blocked_periods',
'bookings',
'special_offers',
'extras',
'seasons',
'amenities',
'photos',
'appearances',
'pages',
'notices',
'faqs',
'content_blocks',
'guests',
'channels',
'properties',
'site_domains',
'sites',
'tenant_services',
'service_usages',
'tenant_access_logs',
'tenant_user',
];
/**
* Writes every row and every uploaded file of this landlord into one zip file.
*
* @return string the path of the written archive
*/
public function export(Tenant $tenant, string $directory): string
{
File::ensureDirectoryExists($directory);
$path = rtrim($directory, '/\\').DIRECTORY_SEPARATOR.'mandant-'.$tenant->slug.'-'.now()->format('Ymd-His').'.zip';
$zip = new ZipArchive;
if ($zip->open($path, ZipArchive::CREATE | ZipArchive::OVERWRITE) !== true) {
throw new RuntimeException('Archiv konnte nicht angelegt werden: '.$path);
}
$zip->addFromString('mandant.json', (string) json_encode($tenant->toArray(), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
foreach ($this->tables() as $table) {
$rows = $this->rowsOf($table, $tenant);
$zip->addFromString(
'daten/'.$table.'.json',
(string) json_encode($rows, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
);
}
$zip->addFromString(
'daten/benutzer.json',
(string) json_encode($this->usersOf($tenant), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
);
$this->addFiles($zip, $tenant);
$zip->close();
return $path;
}
/**
* Who worked for this landlord, with their role. Deliberately without password hashes and without the
* two-factor secrets: the export is handed out, and those would be worth stealing.
*
* @return list<array{id: int, name: string, email: string, role: ?string, weitere_mandanten: int}>
*/
public function usersOf(Tenant $tenant): array
{
return User::query()
->whereHas('tenants', fn ($query) => $query->where('tenants.id', $tenant->id))
->withCount('tenants')
->get()
->map(fn (User $user): array => [
'id' => $user->id,
'name' => $user->name,
'email' => $user->email,
'role' => $user->roleOn($tenant->id)?->value,
'weitere_mandanten' => max(0, $user->tenants_count - 1),
])
->all();
}
/**
* Removes the landlord and everything that belongs to them, files included. The landlord row goes last.
*
* @return array<string, int> how many rows were removed per table
*/
public function delete(Tenant $tenant): array
{
$this->deleteFiles($tenant);
$orphans = $this->accountsLosingTheirLastLandlord($tenant);
$removed = [];
DB::transaction(function () use ($tenant, $orphans, &$removed): void {
foreach (self::DELETE_ORDER as $table) {
if (! $this->hasTenantColumn($table)) {
continue;
}
$count = DB::table($table)->where('tenant_id', $tenant->id)->delete();
if ($count > 0) {
$removed[$table] = $count;
}
}
if ($orphans !== []) {
$removed['users'] = User::query()->whereKey($orphans)->delete();
}
$tenant->delete();
});
return $removed;
}
/**
* Accounts that belonged to this landlord only. They are removed with them – an account that can reach
* nothing is personal data without a purpose. An operator keeps their account, and so does anybody who
* still works for another landlord.
*
* @return list<int>
*/
private function accountsLosingTheirLastLandlord(Tenant $tenant): array
{
return User::query()
->where('is_operator', false)
->whereHas('tenants', fn ($query) => $query->where('tenants.id', $tenant->id))
->withCount('tenants')
->get()
->filter(fn (User $user): bool => $user->tenants_count === 1)
->pluck('id')
->all();
}
/**
* Tables carrying a tenant_id, in a stable order.
*
* @return list<string>
*/
public function tables(): array
{
return array_values(array_filter(self::DELETE_ORDER, fn (string $table): bool => $this->hasTenantColumn($table)));
}
/**
* @return list<array<string, mixed>>
*/
private function rowsOf(string $table, Tenant $tenant): array
{
return array_map(
fn (object $row): array => (array) $row,
DB::table($table)->where('tenant_id', $tenant->id)->get()->all(),
);
}
/**
* Photos keep their files through Spatie's media library; they hang off the photo, not off the landlord,
* so they are collected through the photos of this landlord.
*/
private function addFiles(ZipArchive $zip, Tenant $tenant): void
{
foreach ($this->mediaOf($tenant) as $media) {
$path = $media->getPath();
if (is_string($path) && File::exists($path)) {
$zip->addFile($path, 'dateien/'.$media->id.'-'.$media->file_name);
}
}
}
private function deleteFiles(Tenant $tenant): void
{
foreach ($this->mediaOf($tenant) as $media) {
$media->delete(); // removes the stored file as well
}
}
/**
* @return Collection<int, Media>
*/
private function mediaOf(Tenant $tenant): Collection
{
return app(TenantContext::class)->run(
$tenant,
fn () => Photo::query()->with('media')->get()->flatMap(fn (Photo $photo) => $photo->media),
);
}
private function hasTenantColumn(string $table): bool
{
static $known = [];
return $known[$table] ??= Schema::hasTable($table)
&& Schema::hasColumn($table, 'tenant_id');
}
}
+215
View File
@@ -0,0 +1,215 @@
<?php
namespace App\Tenancy;
use App\Models\Tenant;
use App\Support\Settings;
use Illuminate\Mail\MailManager;
use Illuminate\Support\Facades\Mail;
use Throwable;
/**
* Lays the operating data of the current landlord over config('fewo.*') and the mail sender, so e-mails,
* contracts and theme views keep reading the same keys. The values from config/.env stay the baseline:
* infrastructure, the fallback while no landlord is known, and the limits a landlord may tighten but not exceed.
*/
class TenantConfig
{
/**
* Retention periods and bot protection: the landlord may be stricter, never more lax than the baseline.
* Fewer days/attempts is stricter.
*
* @var array<string, string>
*/
private const AT_MOST = [
'fewo.guest_retention_years' => 'guest_retention_years',
'fewo.retention.inquiry_months' => 'retention_inquiry_months',
'fewo.retention.portal_email_excerpt_days' => 'retention_portal_email_excerpt_days',
'fewo.retention.attribution_months' => 'retention_attribution_months',
'fewo.spam.per_ip_per_hour' => 'spam_per_ip_per_hour',
'fewo.spam.per_email_per_day' => 'spam_per_email_per_day',
'fewo.spam.open_requests_per_email' => 'spam_open_requests_per_email',
'fewo.spam.max_links' => 'spam_max_links',
];
/**
* The time trap works the other way round: a longer minimum time is stricter.
*
* @var array<string, string>
*/
private const AT_LEAST = [
'fewo.spam.min_seconds' => 'spam_min_seconds',
];
/**
* Values the landlord chooses freely; empty means the baseline.
*
* @var array<string, string>
*/
private const FREE = [
'fewo.deposit_due_days' => 'deposit_due_days',
'fewo.review_request_after_days' => 'review_request_after_days',
'fewo.channels.stale_after_minutes' => 'channel_stale_after_minutes',
'fewo.channels.task_reminder_after_minutes' => 'channel_task_reminder_after_minutes',
];
/**
* Data of the landlord: an empty value stays empty instead of falling back to another landlord's.
*
* @var array<string, string>
*/
private const OWNED = [
'fewo.owner.name' => 'owner_name',
'fewo.owner.street' => 'owner_street',
'fewo.owner.city' => 'owner_city',
'fewo.owner.phone' => 'owner_phone',
'fewo.owner.email' => 'contact_email',
'fewo.bank.account_holder' => 'bank_account_holder',
'fewo.bank.iban' => 'bank_iban',
'fewo.bank.bic' => 'bank_bic',
'fewo.bank.bank_name' => 'bank_name',
];
/** @var array<string, mixed>|null */
private ?array $baseline = null;
/**
* What this class wrote into the config last time. A key that now holds something else was changed from
* outside (a test, a command) – that value becomes the new baseline instead of being overwritten again.
*
* @var array<string, mixed>
*/
private array $written = [];
/**
* The landlord of the current context, else the only landlord there is (console, boot), else none.
*/
public function effectiveTenant(): ?Tenant
{
$current = app(TenantContext::class)->get();
if ($current !== null) {
return $current;
}
try {
$tenants = Tenant::query()->limit(2)->get();
} catch (Throwable) {
return null; // before the migrations ran
}
return $tenants->count() === 1 ? $tenants->first() : null;
}
/**
* Applies the effective landlord, or the baseline when there is none.
*/
public function refresh(): void
{
$this->apply($this->effectiveTenant());
}
public function apply(?Tenant $tenant): void
{
$baseline = $this->baseline();
$values = $baseline;
if ($tenant !== null && ! array_key_exists('owner_name', $tenant->getAttributes())) {
$tenant = null; // the migration that adds the columns has not run yet; the baseline stands
}
if ($tenant !== null) {
foreach (self::OWNED as $key => $column) {
$values[$key] = $tenant->{$column};
}
foreach (self::FREE as $key => $column) {
$values[$key] = $tenant->{$column} ?? $baseline[$key];
}
foreach (self::AT_MOST as $key => $column) {
$values[$key] = min($tenant->{$column} ?? $baseline[$key], $baseline[$key]);
}
foreach (self::AT_LEAST as $key => $column) {
$values[$key] = max($tenant->{$column} ?? $baseline[$key], $baseline[$key]);
}
$values['mail.from.address'] = $tenant->sender_email ?: $baseline['mail.from.address'];
$values['mail.from.name'] = $tenant->sender_name ?: $baseline['mail.from.name'];
}
config($values);
$this->written = $values;
$this->applyMailRouting($tenant);
}
/**
* The mailer sends everything to one address while the landlord is in test mode.
*/
public function applyMailRouting(?Tenant $tenant): void
{
$manager = Mail::getFacadeRoot();
if (! $manager instanceof MailManager) {
return; // Mail::fake() in tests
}
$manager->purge();
$redirect = Settings::mailRedirectFor($tenant);
if (filled($redirect)) {
$manager->alwaysTo($redirect);
}
}
/**
* The value of a config key as the installation configured it, before any landlord was laid over it.
*/
public function baselineValue(string $key): mixed
{
return $this->baseline()[$key] ?? config($key);
}
/**
* The highest value the landlord may enter for a column, or null when it is free.
*/
public function ceilingFor(string $column): ?int
{
$key = array_search($column, self::AT_MOST, true);
return $key === false ? null : (int) $this->baseline()[$key];
}
/**
* The lowest value the landlord may enter for a column, or null when it is free.
*/
public function floorFor(string $column): ?int
{
$key = array_search($column, self::AT_LEAST, true);
return $key === false ? null : (int) $this->baseline()[$key];
}
/**
* @return array<string, mixed>
*/
private function baseline(): array
{
$keys = [...array_keys(self::OWNED), ...array_keys(self::FREE), ...array_keys(self::AT_MOST), ...array_keys(self::AT_LEAST), 'mail.from.address', 'mail.from.name'];
if ($this->baseline === null) {
$this->baseline = array_combine($keys, array_map(fn (string $key): mixed => config($key), $keys));
return $this->baseline;
}
foreach ($keys as $key) {
if (array_key_exists($key, $this->written) && config($key) !== $this->written[$key]) {
$this->baseline[$key] = config($key);
}
}
return $this->baseline;
}
}
+12
View File
@@ -17,12 +17,14 @@ class TenantContext
public function set(Tenant $tenant): void
{
$this->tenant = $tenant;
$this->applyConfig();
}
public function forget(): void
{
$this->tenant = null;
$this->required = false;
$this->applyConfig();
}
public function get(): ?Tenant
@@ -57,11 +59,21 @@ public function run(Tenant $tenant, callable $callback): mixed
{
$previous = $this->tenant;
$this->tenant = $tenant;
$this->applyConfig();
try {
return $callback();
} finally {
$this->tenant = $previous;
$this->applyConfig();
}
}
/**
* Operating data of the landlord (addresses, periods, bank) is overlaid on config('fewo.*').
*/
private function applyConfig(): void
{
app(TenantConfig::class)->refresh();
}
}
+81
View File
@@ -0,0 +1,81 @@
<?php
namespace App\Tenancy;
use Illuminate\Support\Facades\Crypt;
/**
* Operating data of a landlord taken from what the single-landlord installation used: the admin settings
* and config/.env. Used once by the migration and as the factory default in tests.
*/
class TenantDefaults
{
/**
* @param array<string, ?string> $settings Rows of the former `settings` table (key => value)
* @param bool $encryptBank true for raw database writes; the model's own cast encrypts otherwise
* @return array<string, mixed>
*/
public static function forLegacyLandlord(array $settings = [], bool $encryptBank = true): array
{
return [
'owner_name' => self::baseline('fewo.owner.name'),
'owner_street' => self::baseline('fewo.owner.street'),
'owner_city' => self::baseline('fewo.owner.city'),
'owner_phone' => self::baseline('fewo.owner.phone'),
'contact_email' => self::setting($settings, 'addresses.contact') ?? self::baseline('fewo.owner.email'),
'notification_emails' => self::setting($settings, 'addresses.notifications') ?? config('fewo.notification_email'),
'sender_name' => self::setting($settings, 'addresses.sender_name') ?? self::baseline('mail.from.name'),
'sender_email' => self::setting($settings, 'addresses.sender_email') ?? self::baseline('mail.from.address'),
'bank_account_holder' => self::bank(self::baseline('fewo.bank.account_holder'), $encryptBank),
'bank_iban' => self::bank(self::baseline('fewo.bank.iban'), $encryptBank),
'bank_bic' => self::bank(self::baseline('fewo.bank.bic'), $encryptBank),
'bank_name' => self::bank(self::baseline('fewo.bank.bank_name'), $encryptBank),
'operating_mode' => ($settings['operations.mode'] ?? 'test') === 'live' ? 'live' : 'test',
'test_recipient' => self::setting($settings, 'operations.test_recipient'),
'deposit_due_days' => self::baseline('fewo.deposit_due_days'),
'review_request_after_days' => self::baseline('fewo.review_request_after_days'),
];
}
/**
* The mailbox the single-landlord installation used, taken from the .env for a raw database write.
*
* @return array<string, mixed>
*/
public static function mailboxFromConfig(): array
{
return [
'mailbox_host' => config('fewo.mailbox.host'),
'mailbox_port' => config('fewo.mailbox.port'),
'mailbox_encryption' => config('fewo.mailbox.encryption'),
'mailbox_username' => config('fewo.mailbox.username'),
'mailbox_password' => self::bank(config('fewo.mailbox.password'), true),
'mailbox_folder' => config('fewo.mailbox.folder'),
];
}
/**
* The value of the installation, not the one a landlord may already have laid over the configuration.
*/
private static function baseline(string $key): mixed
{
return app(TenantConfig::class)->baselineValue($key);
}
/**
* @param array<string, ?string> $settings
*/
private static function setting(array $settings, string $key): ?string
{
return filled($settings[$key] ?? null) ? (string) $settings[$key] : null;
}
public static function bank(mixed $value, bool $encrypt): ?string
{
if (blank($value)) {
return null;
}
return $encrypt ? Crypt::encryptString((string) $value) : (string) $value;
}
}
+105
View File
@@ -0,0 +1,105 @@
<?php
namespace App\Tenancy;
use App\Enums\Permission;
use App\Enums\TenantServiceKey;
use App\Models\Tenant;
use App\Models\TenantService;
use Throwable;
/**
* The single place that answers "is this service unlocked for this landlord". Everything that acts on a
* service asks here: the policies of the admin, the console commands, the portal feed. Roles decide what a
* *user* may do, this decides what the *landlord* has at all – a landlord without the service keeps nobody
* out by role, so both questions have to be asked, and asking them in two places is how they drift apart.
*/
class TenantFeatures
{
/**
* Services a permission depends on. The permission is granted when at least one of them is unlocked,
* so a landlord with only the mailbox still reaches the portal screens.
*
* @var array<string, list<TenantServiceKey>>
*/
private const REQUIRES_ANY = [
Permission::Channels->value => [TenantServiceKey::PortalSync, TenantServiceKey::PortalMail],
];
/**
* Unlocked services per landlord id, for the length of one request.
*
* @var array<int, array<string, bool>>
*/
private array $cache = [];
/**
* Whether the landlord may use the service. Without a landlord (console before a context is chosen,
* boot) the default of the service applies, which keeps a single-landlord installation unchanged.
*/
public function enabled(TenantServiceKey $service, ?Tenant $tenant = null): bool
{
$tenant ??= app(TenantContext::class)->get();
if ($tenant === null) {
return $service->enabledByDefault();
}
return $this->forTenant($tenant)[$service->value] ?? $service->enabledByDefault();
}
/**
* Whether the landlord has what a permission needs. A permission that depends on no service is always
* granted here – the role still decides separately.
*/
public function permits(Permission $permission, ?Tenant $tenant = null): bool
{
$required = self::REQUIRES_ANY[$permission->value] ?? [];
if ($required === []) {
return true;
}
foreach ($required as $service) {
if ($this->enabled($service, $tenant)) {
return true;
}
}
return false;
}
/**
* Forgets what was read, so a switch takes effect without a new request.
*/
public function forget(?Tenant $tenant = null): void
{
if ($tenant === null) {
$this->cache = [];
return;
}
unset($this->cache[$tenant->id]);
}
/**
* @return array<string, bool>
*/
private function forTenant(Tenant $tenant): array
{
if (! array_key_exists($tenant->id, $this->cache)) {
try {
$this->cache[$tenant->id] = TenantService::query()
->where('tenant_id', $tenant->id)
->pluck('is_enabled', 'service')
->map(fn (mixed $enabled): bool => (bool) $enabled)
->all();
} catch (Throwable) {
return []; // before the migrations ran; the defaults apply
}
}
return $this->cache[$tenant->id];
}
}
+57
View File
@@ -0,0 +1,57 @@
<?php
namespace App\Tenancy;
use App\Models\Tenant;
use Closure;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Throwable;
/**
* Runs background work once per landlord, with that landlord current. Everything the scheduler does –
* expiring holds, importing portals, writing reminders – acts on one landlord's data and sends mail with
* one landlord's sender, so it has to be told which one.
*
* Without this, a run with several landlords sees no landlord at all: queries fall back to unfiltered and
* mail falls back to the .env sender, which would send one landlord's reminders with another one's address.
*
* A landlord whose run fails does not stop the others – the next one still gets its turn.
*/
class TenantRunner
{
/**
* @param Closure(Tenant): void $callback
* @return int how many landlords ran without an error
*/
public function each(Closure $callback, bool $onlyActive = true): int
{
$context = app(TenantContext::class);
$succeeded = 0;
foreach ($this->tenants($onlyActive) as $tenant) {
try {
$context->run($tenant, fn () => $callback($tenant));
$succeeded++;
} catch (Throwable $exception) {
Log::error('Lauf für Mandant '.$tenant->slug.' fehlgeschlagen: '.$exception->getMessage(), [
'tenant_id' => $tenant->id,
'exception' => $exception,
]);
}
}
return $succeeded;
}
/**
* @return Collection<int, Tenant>
*/
public function tenants(bool $onlyActive = true): Collection
{
return Tenant::query()
->when($onlyActive, fn ($query) => $query->where('is_active', true))
->orderBy('id')
->get();
}
}
+71
View File
@@ -0,0 +1,71 @@
<?php
namespace App\Themes\Sections;
use App\Models\Amenity;
use App\Models\FloorPlan;
use App\Models\Photo;
use App\Themes\Theme;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Illuminate\Support\Str;
/**
* Interactive floor plan of the apartment (Admin › Webseite › Grundriss): guests tap a room and see its
* photos, equipment and accessibility hint. Without JavaScript the rooms are listed below the plan.
*/
class FloorPlanSection extends Section
{
public static function key(): string
{
return 'floor_plan';
}
public static function label(): string
{
return 'Grundriss (interaktiv)';
}
public static function icon(): string
{
return 'heroicon-o-map';
}
public static function schema(): array
{
return [
TextInput::make('heading')->label('Überschrift')->default('Der Grundriss')->maxLength(120)
->helperText('Bild und Räume pflegen Sie unter Webseite › Grundriss.'),
Textarea::make('text')->label('Text')->rows(2)->maxLength(300)
->default('Tippen Sie auf einen Raum, um Fotos und Ausstattung zu sehen.'),
];
}
public function data(Theme $theme, array $data): array
{
$plan = $theme->property()?->floorPlan()->with('photo')->first();
$rooms = $plan?->photo ? $plan->visibleRooms() : collect();
$photos = Photo::query()->published()->with('media')
->whereIn('id', $rooms->flatMap(fn (array $room): array => $room['photo_ids'] ?? [])->unique()->all())
->get()->keyBy('id');
$amenities = Amenity::query()
->whereIn('id', $rooms->flatMap(fn (array $room): array => $room['amenity_ids'] ?? [])->unique()->all())
->pluck('name', 'id');
return [
'heading' => $data['heading'] ?? 'Der Grundriss',
'text' => $data['text'] ?? null,
'photo' => $plan?->photo,
'rooms' => $rooms->map(fn (array $room, int $index): array => [
'key' => 'raum-'.Str::slug($room['name']).'-'.($index + 1),
'name' => $room['name'],
'description' => $room['description'] ?? null,
'hint' => $room['hint'] ?? null,
'points' => collect(FloorPlan::points($room['points']))->map(fn (array $point): string => $point[0].','.$point[1])->implode(' '),
'photos' => collect($room['photo_ids'] ?? [])->map(fn ($id) => $photos->get((int) $id))->filter()->values(),
'amenities' => collect($room['amenity_ids'] ?? [])->map(fn ($id) => $amenities->get((int) $id))->filter()->values(),
]),
];
}
}
+36
View File
@@ -2,6 +2,8 @@
namespace App\Themes;
use App\ImageWorlds\ImageWorldManifest;
use App\ImageWorlds\MotifRenderer;
use App\Models\Appearance;
use App\Models\Page;
use App\Models\Photo;
@@ -9,6 +11,7 @@
use App\Models\Site;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\View;
use Illuminate\Support\HtmlString;
/**
* The theme context of the current request: site, theme chain and appearance. Activating it registers the
@@ -128,6 +131,39 @@ public function appearanceKey(): string
return $this->appearance ? str($this->appearance->name)->slug()->toString() : 'standard';
}
/**
* A brand graphic of this website (logo, favicon, document logo), or null when none was uploaded.
* The brand belongs to the landlord; the picture world belongs to the look. Templates that fall back
* to their own graphic should ask for this first (A14/A22).
*/
public function brand(string $collection): ?string
{
return $this->site->exists ? $this->site->brandUrl($collection) : null;
}
/**
* The graphic behind a picture-world slot (divider, closing, vignette.beach …). Templates ask for a
* slot, never for a file, so the same template works in every picture world (A18/A19).
*/
public function motif(string $slot, ?string $class = null, ?string $label = null): HtmlString
{
return app(MotifRenderer::class)->render($slot, $class, $label);
}
/**
* Whether the current picture world fills this slot – for templates that want to leave out a whole
* decorative block instead of rendering an empty one.
*/
public function hasMotif(string $slot): bool
{
return app(MotifRenderer::class)->has($slot);
}
public function imageWorld(): ?ImageWorldManifest
{
return app(MotifRenderer::class)->world();
}
public function property(): ?Property
{
if (! $this->propertyResolved) {
+26
View File
@@ -0,0 +1,26 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Picture worlds ("Bildwelten")
|--------------------------------------------------------------------------
|
| Every folder below one of these paths that contains a world.json is a
| picture world: the bands, vignettes and ornaments a website is dressed
| in. Themes ask for a slot, never for a file (MANDANTEN-ANFORDERUNGEN
| A18/A19), so the same theme can wear "Ostsee" or later "Berge".
|
*/
'paths' => [
resource_path('image-worlds'),
],
/*
| Applies while a website has chosen none. Empty = no decoration at all.
*/
'default' => env('FEWO_IMAGE_WORLD', 'ostsee'),
];
+1
View File
@@ -39,6 +39,7 @@
Sections\TextImageSection::class,
Sections\GallerySection::class,
Sections\AmenitiesSection::class,
Sections\FloorPlanSection::class,
Sections\LocationSection::class,
Sections\PricesSection::class,
Sections\OffersSection::class,
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace Database\Factories;
use App\Models\FloorPlan;
use App\Models\Photo;
use App\Models\Property;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<FloorPlan>
*/
class FloorPlanFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'property_id' => Property::factory(),
'photo_id' => Photo::factory(),
'rooms' => [
['id' => (string) Str::uuid(), 'name' => 'Wohnbereich', 'description' => 'Helles Wohnzimmer mit Ledersofa.', 'hint' => null, 'points' => '10,20 50,20 50,65 10,65', 'photo_ids' => [], 'amenity_ids' => [], 'is_visible' => true],
['id' => (string) Str::uuid(), 'name' => 'Bad', 'description' => 'Bad mit Glasdusche.', 'hint' => 'Flache Dusche mit kleiner Kante.', 'points' => '50,40 66,40 66,65 50,65', 'photo_ids' => [], 'amenity_ids' => [], 'is_visible' => true],
],
];
}
}
+2
View File
@@ -3,6 +3,7 @@
namespace Database\Factories;
use App\Models\Tenant;
use App\Tenancy\TenantDefaults;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
@@ -22,6 +23,7 @@ public function definition(): array
'name' => $name,
'slug' => Str::slug($name).'-'.Str::lower(Str::random(4)),
'is_active' => true,
...TenantDefaults::forLegacyLandlord(encryptBank: false),
];
}
}
@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* One floor plan per apartment: a picture from the website photos and the rooms drawn on it.
*/
public function up(): void
{
Schema::create('floor_plans', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained()->restrictOnDelete();
$table->foreignId('property_id')->unique()->constrained()->cascadeOnDelete();
$table->foreignId('photo_id')->nullable()->constrained()->nullOnDelete();
$table->json('rooms')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('floor_plans');
}
};
@@ -0,0 +1,48 @@
<?php
use App\Models\Photo;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
return new class extends Migration
{
/**
* Photos uploaded in the admin landed on the private default disk ("local"), so the website could not
* show them. Moves their files (original and web sizes, folder = media id) to the public disk.
* Safe to run again: only media not yet on the public disk are touched.
*/
public function up(): void
{
$media = DB::table('media')
->where('model_type', Photo::class)
->where(fn ($query) => $query->where('disk', '!=', 'public')->orWhere('conversions_disk', '!=', 'public'))
->get(['id', 'disk', 'conversions_disk']);
foreach ($media as $item) {
$folder = (string) $item->id;
$public = Storage::disk('public');
$disks = array_values(array_diff(array_unique([$item->disk, $item->conversions_disk ?: $item->disk]), ['public']));
if (array_filter($disks, fn (string $diskName): bool => config("filesystems.disks.{$diskName}") === null) !== []) {
continue;
}
foreach ($disks as $diskName) {
$source = Storage::disk($diskName);
foreach ($source->allFiles($folder) as $file) {
$public->writeStream($file, $source->readStream($file));
}
$source->deleteDirectory($folder);
}
DB::table('media')->where('id', $item->id)->update(['disk' => 'public', 'conversions_disk' => 'public']);
}
}
public function down(): void
{
// Files stay public; moving them back to a private disk would hide them from the website again.
}
};
@@ -0,0 +1,96 @@
<?php
use App\Tenancy\TenantDefaults;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Landlord data, bank, addresses, operating mode and periods become columns of the landlord. The values
* of the existing (single) landlord come from the `settings` table and from config/.env. The `settings`
* table stays until the shipped code no longer reads it (own step, see docs/MANDANTEN-PLAN.md §4).
*/
public function up(): void
{
Schema::table('tenants', function (Blueprint $table) {
$table->string('owner_name')->nullable();
$table->string('owner_street')->nullable();
$table->string('owner_city')->nullable();
$table->string('owner_phone')->nullable();
$table->string('contact_email')->nullable();
$table->text('notification_emails')->nullable();
$table->string('sender_name')->nullable();
$table->string('sender_email')->nullable();
$table->text('bank_account_holder')->nullable();
$table->text('bank_iban')->nullable();
$table->text('bank_bic')->nullable();
$table->text('bank_name')->nullable();
$table->text('tax_note')->nullable();
$table->string('operating_mode', 10)->default('test');
$table->string('test_recipient')->nullable();
$table->unsignedSmallInteger('deposit_due_days')->nullable();
$table->unsignedSmallInteger('review_request_after_days')->nullable();
$table->unsignedSmallInteger('guest_retention_years')->nullable();
$table->unsignedSmallInteger('retention_inquiry_months')->nullable();
$table->unsignedSmallInteger('retention_portal_email_excerpt_days')->nullable();
$table->unsignedSmallInteger('retention_attribution_months')->nullable();
$table->unsignedSmallInteger('spam_min_seconds')->nullable();
$table->unsignedSmallInteger('spam_per_ip_per_hour')->nullable();
$table->unsignedSmallInteger('spam_per_email_per_day')->nullable();
$table->unsignedSmallInteger('spam_open_requests_per_email')->nullable();
$table->unsignedSmallInteger('spam_max_links')->nullable();
$table->unsignedSmallInteger('channel_stale_after_minutes')->nullable();
$table->unsignedSmallInteger('channel_task_reminder_after_minutes')->nullable();
});
$stommer = DB::table('tenants')->where('slug', 'stommer')->first();
if ($stommer !== null) {
DB::table('tenants')->where('id', $stommer->id)->update(TenantDefaults::forLegacyLandlord(
DB::table('settings')->pluck('value', 'key')->all(),
));
}
Schema::create('tenant_services', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
$table->string('service', 40);
$table->boolean('is_enabled')->default(false);
$table->text('api_key')->nullable();
$table->timestamps();
$table->unique(['tenant_id', 'service']);
});
Schema::create('service_usages', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
$table->string('service', 40);
$table->unsignedInteger('quantity')->default(1);
$table->timestamp('used_at')->useCurrent();
$table->index(['tenant_id', 'service', 'used_at']);
});
}
public function down(): void
{
Schema::dropIfExists('service_usages');
Schema::dropIfExists('tenant_services');
Schema::table('tenants', function (Blueprint $table) {
$table->dropColumn([
'owner_name', 'owner_street', 'owner_city', 'owner_phone', 'contact_email', 'notification_emails',
'sender_name', 'sender_email', 'bank_account_holder', 'bank_iban', 'bank_bic', 'bank_name', 'tax_note',
'operating_mode', 'test_recipient', 'deposit_due_days', 'review_request_after_days',
'guest_retention_years', 'retention_inquiry_months', 'retention_portal_email_excerpt_days',
'retention_attribution_months', 'spam_min_seconds', 'spam_per_ip_per_hour', 'spam_per_email_per_day',
'spam_open_requests_per_email', 'spam_max_links', 'channel_stale_after_minutes',
'channel_task_reminder_after_minutes',
]);
});
}
};
@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* The operating settings are columns of the landlord now (see the previous migration); nothing reads
* this table any more. One store for operating data, not two.
*/
public function up(): void
{
Schema::dropIfExists('settings');
}
public function down(): void
{
Schema::create('settings', function (Blueprint $table) {
$table->id();
$table->string('key')->unique();
$table->text('value')->nullable();
$table->timestamps();
});
}
};
@@ -0,0 +1,35 @@
<?php
use App\Enums\TenantServiceKey;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Writes the switches of the services that are wired, so the operator sees the state instead of an
* empty form. The portal services were part of the product before there were landlords, so every
* landlord that exists today keeps them.
*/
public function up(): void
{
$now = now();
foreach (DB::table('tenants')->pluck('id') as $tenantId) {
foreach (TenantServiceKey::wired() as $service) {
DB::table('tenant_services')->updateOrInsert(
['tenant_id' => $tenantId, 'service' => $service->value],
['is_enabled' => $service->enabledByDefault(), 'updated_at' => $now, 'created_at' => $now],
);
}
}
}
public function down(): void
{
DB::table('tenant_services')->whereIn('service', array_map(
fn (TenantServiceKey $service): string => $service->value,
TenantServiceKey::wired(),
))->delete();
}
};
@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Two things the operator owns. The notice a suspended landlord's visitors see instead of a dead link,
* and the settings of the whole installation – which, unlike the former `settings` table, belong to
* nobody's landlord: they are the operator's, and a landlord's admin never reaches them.
*/
public function up(): void
{
Schema::table('tenants', function (Blueprint $table) {
$table->text('suspended_message')->nullable();
});
Schema::create('system_settings', function (Blueprint $table) {
$table->id();
$table->string('key')->unique();
$table->text('value')->nullable();
$table->boolean('is_secret')->default(false);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('system_settings');
Schema::table('tenants', function (Blueprint $table) {
$table->dropColumn('suspended_message');
});
}
};
@@ -0,0 +1,43 @@
<?php
use App\Tenancy\TenantDefaults;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Each landlord reads the portals' booking notifications from their own mailbox. An empty host means
* the fast path is off for that landlord. The password is encrypted with APP_KEY like the bank details.
*/
public function up(): void
{
Schema::table('tenants', function (Blueprint $table) {
$table->string('mailbox_host')->nullable();
$table->unsignedSmallInteger('mailbox_port')->nullable();
$table->string('mailbox_encryption', 10)->nullable();
$table->string('mailbox_username')->nullable();
$table->text('mailbox_password')->nullable();
$table->string('mailbox_folder')->nullable();
});
// Whatever the single-landlord installation had in its .env belongs to Stommer.
$stommer = DB::table('tenants')->where('slug', 'stommer')->first();
if ($stommer !== null && filled(config('fewo.mailbox.host'))) {
DB::table('tenants')->where('id', $stommer->id)->update(TenantDefaults::mailboxFromConfig());
}
}
public function down(): void
{
Schema::table('tenants', function (Blueprint $table) {
$table->dropColumn([
'mailbox_host', 'mailbox_port', 'mailbox_encryption',
'mailbox_username', 'mailbox_password', 'mailbox_folder',
]);
});
}
};
@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* A website is dressed in a picture world; an apartment may wear a different one (A18/A20) – that is
* the place for a mountain apartment on a coastal website. Empty means: the one above decides.
*/
public function up(): void
{
Schema::table('sites', function (Blueprint $table) {
$table->string('image_world')->nullable()->after('theme');
});
Schema::table('properties', function (Blueprint $table) {
$table->string('image_world')->nullable();
});
}
public function down(): void
{
Schema::table('properties', function (Blueprint $table) {
$table->dropColumn('image_world');
});
Schema::table('sites', function (Blueprint $table) {
$table->dropColumn('image_world');
});
}
};
+1
View File
@@ -150,6 +150,7 @@ ## 8. Bekannte Eigenheiten und Lösungen
| Nach dem Umschalten lief die alte Version weiter | Strato-OPcache speichert Skripte unter dem Symlink-Pfad `current/…` | `.htaccess` zeigt auf den konkreten Ordner `releases/<version>/public` und wird bei jedem Umschalten neu geschrieben |
| Links mit `/current/public` (z. B. Sitemap) | Laravel leitet den Basis-Pfad aus dem Skript-Pfad ab | `URL::forceRootUrl(APP_URL)` außerhalb von local/testing (`AppServiceProvider`) |
| HTTP 500 „Composer platform“ | Web-PHP des Pakets ist 8.3 | `AddType application/x-httpd-php84 .php` in der Ordner-`.htaccess` |
| Im Admin hochgeladenes Foto erscheint in der Fotoliste, auf der Website/im Grundriss-Editor aber als leeres Bild (HTTP 403) | Upload-Feld nahm Filaments Standard-Speicher `FILESYSTEM_DISK=local` (privat, `storage/app/private/<media-id>`); Import und Website nutzen `public` | Seit 23.10.2026 (`1871c04`): Fotos immer auf `public` (`Photo`-Sammlung `useDisk('public')`, Upload-Feld `->disk('public')`); Migration `2026_10_23_171001_move_photo_media_to_the_public_disk` hat vorhandene private Fotos verschoben (stommer.info: Foto 41). Direkt nach dem Verschieben kann Strato die Adresse kurz noch mit 403 beantworten |
| SSH „connection closed“ | falscher Server `ssh.strato.de` | paketspezifischer Server (§2) |
| Domain-Ziel `current/public` nicht wählbar | Strato erlaubt kein Symlink-Ziel | Domain auf den Deploy-Ordner, `.htaccess` leitet weiter |
| Ersteinrichtung mit Factories schlägt fehl | Produktion ohne Dev-Pakete | `ProductionSeeder` |
+25 -16
View File
@@ -1,6 +1,6 @@
# Mandantenfähigkeit – Umbauplan
Stand: 23.10.2026, nachmittag · Phase 1, 2 und der Website-Teil von Phase 4 sind auf `main` und auf stommer.info (Release `20261023100346`) · Anforderungen: [MANDANTEN-ANFORDERUNGEN.md](MANDANTEN-ANFORDERUNGEN.md) · Design: [DESIGN-KONZEPT.md](DESIGN-KONZEPT.md) §7 · Übergabe: [STATUS.md](STATUS.md) Abschnitt 7
Stand: 24.10.2026 · **Phasen 1 bis 5 umgesetzt**, Phase 6 auf der Anwendungsseite ebenfalls. Offen: der Theme-Teil von Phase 6 (§6 der Zusammenarbeit) und Phase 7 · Anforderungen: [MANDANTEN-ANFORDERUNGEN.md](MANDANTEN-ANFORDERUNGEN.md) · Design: [DESIGN-KONZEPT.md](DESIGN-KONZEPT.md) §7 · Übergabe: [STATUS.md](STATUS.md) Abschnitt 7
Kein Portal, kein Marktplatz. Das Produkt bleibt die eigene Website eines Vermieters mit Vermietung. Wenige Mandanten, eine gemeinsame Datenbank, Laravel und Filament bleiben die Basis. Ein Python-Dienst ist nicht Teil dieses Umbaus.
@@ -228,37 +228,40 @@ ### Phase 2 – Rollen, Admin, Benutzer
Tests: Mitglied von A öffnet eine Buchung von B per Adresse und bekommt 404. Mandanten-Administrator vergibt keine Betreiber-Markierung und sieht keine fremden Benutzer. Konto mit zwei Mitgliedschaften: Passwort-Reset durch den Mandanten-Administrator wird verweigert, durch den Betreiber nicht. Rolle Vermietung kann keine Benutzer anlegen. Einfache Ansicht enthält dieselben Menüpunkte wie vor dem Umbau. Konto mit einem Mandanten sieht keinen Wechsel.
### Phase 3 – Einstellungen, Texte, Dienste-Grundlage
### Phase 3 – Einstellungen, Texte, Dienste-Grundlage · umgesetzt
Ziel: Vermieterdaten und Texte sind Daten des Mandanten. Die `.env` von Stommer ist nach der Übernahme nur noch Infrastruktur.
- Spalten am Mandanten, `content_blocks` je Mandant, FAQ und Hinweise je Mandant, Seite „Betrieb“ schreibt den aktuellen Mandanten.
- Katalog in `config/content.php` bleibt.
- `tenant_services` und `service_usages`, Schalter nur im Betreiber-Bereich.
- Tabelle `settings` entfernen.
- Spalten am Mandanten, `content_blocks` je Mandant, FAQ und Hinweise je Mandant, Seite „Betrieb“ schreibt den aktuellen Mandanten. Umgesetzt.
- Katalog in `config/content.php` bleibt. Unverändert.
- `tenant_services` und `service_usages`, Schalter nur im Betreiber-Bereich. Umgesetzt und am 24.10. **wirklich angeschlossen**: `App\Tenancy\TenantFeatures` wird in `RolePolicy::allows()`, beim Portal-Import, im iCal-Feed und im Postfach-Schnellweg abgefragt. Nur verdrahtete Dienste sind schaltbar (`TenantServiceKey::isWired()`); die KI-Dienste erscheinen erst, wenn die Anwendung sie abfragt. Eigene API-Schlüssel gehören dann in den Admin des Mandanten, nicht zum Betreiber (A16). `service_usages` steht bereit, es zählt noch nichts.
- Tabelle `settings` entfernen. Umgesetzt.
Tests: Zwei Mandanten, unterschiedliches Impressum, unterschiedliche Bank, unterschiedliche Betriebsart. Mandant kann die Flutgrenze und die Löschfrist nicht über die globale Obergrenze heben. Leerer Dienst-Schlüssel ist erlaubt.
Gebaut als Überlagerung: `App\Tenancy\TenantConfig` legt die Werte des aktuellen Mandanten über `config('fewo.*')` und `mail.from`, sobald sich der Kontext ändert. Vorlagen, Mails und der Vertrag lesen weiter dieselben Schlüssel; `resources/themes/**` blieb unangetastet. Die `.env` bleibt die Grundlinie: Rückfall ohne Mandanten und Obergrenze für Löschfristen und Bot-Schutz.
### Phase 4 – Domain, Cron, Mail, Postfach
Tests (`tests/Feature/TenantSettingsTest.php`, `OperationsModeTest.php`): Zwei Mandanten, unterschiedliches Impressum, unterschiedliche Bank, unterschiedliche Betriebsart. Mandant kann die Löschfrist und den Bot-Schutz nicht über die globale Obergrenze heben. Leerer Dienst-Schlüssel ist erlaubt, eigene Schlüssel und Bankdaten liegen verschlüsselt.
### Phase 4 – Domain, Cron, Mail, Postfach · umgesetzt
Ziel: Host, Erinnerungen und Portal-Mails gehören dem richtigen Mandanten.
- `site_domains`, 404 für unbekannte Hosts ab dem zweiten Mandanten. Umgesetzt. Mit genau einem Mandanten bleibt die Standard-Website auf jeder Adresse.
- `site_domains`, 404 für unbekannte Hosts ab dem zweiten Mandanten. Umgesetzt. Mit genau einem Mandanten bleibt die Standard-Website auf jeder Adresse. Am 24.10. ergänzt: mehrere Adressen je Website im Admin, weil „www" ein eigener Host ist und das Feld „Domain" nur einen schrieb. Fremde Hosts werden abgelehnt.
- Links mit dem Ursprung der Website. Umgesetzt für Angebot, Annahme, Bewertung und Einwilligung.
- Scheduler-Schleife, Postfach je Mandant, Absender je Versand. Noch nicht.
- Scheduler-Schleife, Postfach je Mandant, Absender je Versand. Umgesetzt am 24.10.: `App\Tenancy\TenantRunner` führt jeden Lauf einmal je aktivem Mandanten aus, mit gesetztem Kontext; ein scheiternder Mandant hält die anderen nicht auf. Die Datenbank-Sicherung bleibt global. Das Postfach liegt als `mailbox_*` am Mandanten (Passwort verschlüsselt, leerer Server = aus), steht im Mandanten-Admin und nur bei freigeschaltetem Dienst. Auch die Cache-Schlüssel der Postfach-Überwachung tragen den Mandanten.
Tests: Angebotslink trägt den Host der Website. Erinnerungslauf für A schreibt keine Mail an Gäste von B und nicht mit dem Absender von B. Postfach-Passwort von A ist aus dem Kontext von B nicht lesbar. iCal-Token von A liefert keine Belegung von B. Unbekannter Host bei zwei Mandanten: 404. Mit einem Mandanten: Standard-Website wie heute.
### Phase 5 – Abnahme der Trennung und Kündigung
### Phase 5 – Abnahme der Trennung und Kündigung · umgesetzt
Ziel: Ein Befehl exportiert und löscht genau einen Mandanten (A25). Die Trennung ist als Suite festgehalten, nicht nur in den einzelnen Phasen.
- Befehl des Betreibers: Export (Daten + Dateien dieses Mandanten) und Löschung in der Reihenfolge, die die Fremdschlüssel erlauben, einschließlich Medien.
- Eine Testklasse je Bereich aus A1: Wohnungen, Preise, Kalender, Buchungen, Zahlungen, Gäste, Bewertungen, Portale, Texte, Fotos, Seiten, Einstellungen, Benutzer.
- Befehl des Betreibers: `tenants:export <slug>` und `tenants:delete <slug>` (exportiert erst, fragt nach, löscht dann einschließlich Medien). `App\Tenancy\TenantArchive`. Löschen ist bewusst **keine** Schaltfläche im Panel.
- Konten, die nur zu diesem Mandanten gehörten, werden mitgelöscht; wer noch für einen anderen arbeitet, und der Betreiber bleiben. Der Export nennt die Konten mit Rolle, aber ohne Passwort-Hashes und ohne 2FA-Geheimnisse – er wird herausgegeben.
- `tests/Feature/TenantSeparationTest.php` füllt jeden Bereich aus A1 für zwei Mandanten, exportiert und löscht einen und prüft den anderen Zeile für Zeile, auch die Hosts (die über die Website hängen und keine eigene `tenant_id` haben). Der Test merkt künftig, wenn eine neue Tabelle ihre `tenant_id` vergisst.
Tests: Nach der Löschung von A ist B vollständig da, inklusive Dateien und Buchungsnummern. Export von A enthält keine Zeile von B.
### Phase 6 – Marke und Bildwelt (danach, eigene Freigabe)
### Phase 6 – Marke und Bildwelt · Anwendungsseite umgesetzt (24.10.), Theme-Teil offen
A14, A18, A19, A20, A22. Nicht zusammen mit Phase 1–5, und nicht solange der Branch `theme/<key>` die Vorlagen noch nicht nachziehen kann.
@@ -266,7 +269,11 @@ ### Phase 6 – Marke und Bildwelt (danach, eigene Freigabe)
- Bildwelten als Pakete neben den Themes (`resources/image-worlds/<key>/`, Manifest und SVGs), analog zu Themes, nicht als Upload. Die Website wählt eine Bildwelt. Eine Wohnung kann sie überschreiben (A20); das ist die Stelle für die Berg-Wohnung, auch wenn Phase 7 die Auswahl in den Bausteinen erst danach scharf schaltet.
- Themes sprechen nur Plätze an (Trenner, Abschlussband, Vignette), keine feste Ostsee-Datei (A19). Das ändert den Vorlagen-Vertrag. Vor der ersten geänderten Theme-Datei steht der Eintrag in ZUSAMMENARBEIT.md §6. Das parallel entstehende Theme wird nicht von dieser Sitzung editiert.
### Phase 7 – Mehrere Wohnungen je Website (zuletzt)
**Umgesetzt am 24.10. (ohne eine Theme-Datei zu ändern):** Bildwelten als Pakete in `resources/image-worlds/<key>/`, Registry, Auswahl an der Website, Überschreibung an der Wohnung; `$theme->motif()`/`hasMotif()`/`imageWorld()` als Platz-API; `image-worlds:check`. Marke als Medien der Website mit `$theme->brand()`, eingebettet im Mietvertrag. Die Ostsee-Grafiken wurden **kopiert**, nicht verschoben.
**Offen und ein Vertragsfall (ZUSAMMENARBEIT.md §6):** `ostsee-licht` von `partials/brand` auf Plätze umstellen, das Favicon in beiden Themes zuerst bei `$theme->brand('favicon')` erfragen, und Seebads `motifs/`-Ordner gegen die Bildwelt tauschen. `public/brand/` entfällt erst danach.
### Phase 7 – Mehrere Wohnungen je Website (zuletzt, eigene Sitzung)
A21. Die Seite bleibt bei einer Wohnung, solange ein Baustein keine nennt.
@@ -288,6 +295,8 @@ ## 9. Betrieb und Abgrenzung
## 10. Freigabe
Phase 1 und 2 sowie der Website-Teil von Phase 4 sind auf stommer.info (Release `20261023100346`). Die bisherigen Daten gehören zum Mandanten Stommer, `lars@stommer.com` ist Betreiber. Die nächste Codesitzung ist Phase 3; Übergabe mit den gebauten Bausteinen: [STATUS.md](STATUS.md) Abschnitt 7. Phase 3 bis 5 bringen weitere Migrationen. Phase 6 und 7 warten auf eine eigene Freigabe.
**Phasen 1 bis 5 sind umgesetzt und ausgeliefert**, von Phase 6 die Anwendungsseite (auf `main`, noch nicht ausgeliefert). Der Grundumbau ist damit fertig: Daten, Rollen, Einstellungen, Domains, Hintergrundläufe, Export und Kündigung, dazu Bildwelten und die Marke je Website. **Phase 7 schließt eine eigene Sitzung ab**; die Übergabe dafür steht in [STATUS.md](STATUS.md) Abschnitt 7. Die bisherigen Daten gehören zum Mandanten Stommer, `lars@stommer.com` ist Betreiber. Ausgelieferter Stand und Übergabe: [STATUS.md](STATUS.md) Abschnitt 7.
Offen und **nicht** Teil dieses Plans: Subscription und Abrechnung (§9 schließt sie aus; `service_usages` liegt als Grundlage bereit) sowie die Frage, ob Strato für die Domain eines Mandanten ein Zertifikat ausstellt – davon hängt ab, ob das Modell „Mandant bringt seine Domain mit" auf diesem Hosting trägt. Phase 6 und 7 warten auf eine eigene Freigabe und einen Eintrag in [ZUSAMMENARBEIT.md](ZUSAMMENARBEIT.md) §6.
Die Sicherheitsregel in §1 gilt: Passwort und 2FA gehören zum Konto, die Rolle zur Mitgliedschaft. Der Betreiber darf zusätzlich Mandanten-Administrator der eigenen Wohnung sein.
+74 -16
View File
@@ -1,6 +1,6 @@
# Projektstand
Stand: 23.10.2026 · ausgelieferter Stand: `deploy/staging/20261023100346` · 217 Feature-Tests grün
Stand: 24.10.2026 · ausgelieferter Stand: `deploy/staging/20261024152057` · `main` ist voraus (Phase 6 noch nicht ausgeliefert) · 272 Feature-Tests grün
> Dieses Dokument ist der Einstieg für jede neue Arbeitssitzung. Bitte bei größeren Änderungen fortschreiben (Abschnitte „Fertig“, „Offen“, „Nächste Schritte“).
@@ -70,7 +70,7 @@ ## 3. Offen
**Technik**
- Cronjob auf Strato einrichten (BETRIEB.md §6).
- Design-Theme Seebad 0.3 ist auf `main` und auf stommer.info aktiv (Abschnitt 6).
- Mandantenfähigkeit: Phase 1, 2 und der Website-Teil von Phase 4 sind auf stommer.info. **Nächste Codesitzung: Phase 3.** Stand, Bausteine und Fallen stehen in Abschnitt 7. Plan: `docs/MANDANTEN-PLAN.md`.
- Mandantenfähigkeit: **Phasen 1 bis 5 sind umgesetzt** – der Grundumbau ist fertig. Stand, Bausteine und Fallen stehen in Abschnitt 7. Plan: `docs/MANDANTEN-PLAN.md`.
- Logo in E-Mails und im Vertrags-PDF (`public/brand/logo-600.png` liegt bereit).
- Content-Security-Policy: braucht wegen Livewire/Filament Nonces und einen sorgfältigen Test.
- Produktion `www.fewo-stommer.de` vorbereiten:
@@ -109,6 +109,8 @@ ## 6. Design-Theme „Seebad“ (Abschnitt der Design-Session)
**Fertig:** alle 15 Bausteine, Kopf/Fuß/Banner/mobile Buchungsleiste, Logo aus `styles/satz4` (SVG-Master + WebP), Favicon (Eckbau mit Rundbogengaube), Bäderstil-Details des Hauses (Rundbogen mit Fasche und Schlussstein, Rundbogengaube, Kopfbänder als Eckkonsolen, Balkongeländer), Farben aus dem Logo, Schriften selbst gehostet. Gearbeitet wird im eigenen Worktree auf `theme/seebad`, ausgeliefert nur über `main`.
**Behoben 23.10.2026:** Im Admin hochgeladene Fotos landeten im privaten Speicher und waren auf der Website unsichtbar (403) – jetzt immer öffentlich, vorhandene per Migration verschoben (BETRIEB.md §8).
**Offen (Design):**
- Ziffer 0 mit Schrägstrich (Schrift Atkinson Hyperlegible) in Preisen und Daten – Entscheidung Lars: lassen oder Preise/Daten in anderer Schrift.
- Seite „Kühlungsborn“ wirkt leer, bis es den Baustein „Tipps der Gastgeberin“ gibt (Vignetten liegen bereit: `motifs/vignette-*.svg`).
@@ -121,7 +123,7 @@ ## 6. Design-Theme „Seebad“ (Abschnitt der Design-Session)
| Baustein | Daten / Admin | Darstellung | Abhängig von |
|---|---|---|---|
| Interaktiver Grundriss | je Wohnung: Grundriss (SVG/Bild) + Räume (Name, Text, Fotos, Fläche als Polygon in %); Editor im Admin | Inline-SVG, Räume antippen → Foto/Text; ohne JS als Liste | Mandanten-Umbau Phase 1 (Daten je Wohnung/Mandant) |
| Interaktiver Grundriss – **gebaut** (23.10.2026, Branch `feature/bausteine`) | Tabelle `floor_plans` (`tenant_id`, eine je Wohnung, Bild = Foto aus Webseite › Fotos, Räume als JSON: Name, Text, Hinweis, Fotos, Ausstattung, sichtbar, Ecken in %); Admin › Webseite › Grundriss mit Eckpunkt-Editor (Ecken setzen, ziehen, mit Pfeiltasten feinjustieren, auf Kanten einfügen, per Doppelklick/Entf löschen) (`resources/views/filament/forms/floor-plan-area.blade.php`, nur Expertenansicht) | Baustein `floor_plan`; Seebad: Flächen und Raum-Tasten wählen einen Raum, Kartusche mit Foto/Ausstattung/Hinweis; ohne JS Liste. Rendering: `styles/grundriss/` | **Mandanten Phase 5:** `floor_plans` beim Export/Löschen eines Mandanten mitnehmen |
| Tipps der Gastgeberin | eigene Liste je Website (Ort, Kategorie, Weg/Gehzeit, Text, Foto, Karten-Link, Saison) | Liste mit Vignette je Kategorie | Bildwelt (Vignetten je Kategorie) |
| Gut zu wissen | strukturierte Felder an der Wohnung (Zugang, Dusche, Haustiere, An-/Abreise, Parken) – auch für Angebot/Mail/JSON-LD | Kartusche | – (klein) |
| Belegungs-/Preiskalender (nur ansehen) | vorhandene Daten (`AvailabilityChecker`, `PriceCalculator`) | Monatsansicht, Livewire oder statisch gerendert | – |
@@ -133,32 +135,68 @@ ## 6. Design-Theme „Seebad“ (Abschnitt der Design-Session)
## 7. Mandanten – Übergabe an die nächste Sitzung
Stand: 23.10.2026, 12:20 · Branch `main` · Plan: [MANDANTEN-PLAN.md](MANDANTEN-PLAN.md) · Anforderungen: [MANDANTEN-ANFORDERUNGEN.md](MANDANTEN-ANFORDERUNGEN.md)
Stand: 24.10.2026, abends · Branch `main` (`c459f7f`) · Plan: [MANDANTEN-PLAN.md](MANDANTEN-PLAN.md) · Anforderungen: [MANDANTEN-ANFORDERUNGEN.md](MANDANTEN-ANFORDERUNGEN.md)
**Hier weitermachen: Phase 3** (Einstellungen, Texte, Dienste-Grundlage). Danach der Rest von Phase 4 (Scheduler, Postfach, Absender, iCal-Token), dann Phase 5 (Export und Löschung eines Mandanten). Phase 6 und 7 erst nach eigener Freigabe und einem Eintrag in ZUSAMMENARBEIT.md §6. Neuen Branch von `main` abzweigen. `feature/mandanten` ist bereits zusammengeführt.
> **`main` ist dem Server voraus.** Ausgeliefert ist `20261024152057` (Commit `2c5b5fc`, Phasen 1–5). Phase 6 (Bildwelten, Marke) liegt seit `4e66add` auf `main` und ist **nicht** ausgeliefert; sie bringt eine Migration mit (`image_world` an `sites` und `properties`). Vor dem nächsten Deploy also sichern wie immer: `bash scripts/backup-pull.sh staging /c/Dev/fewo-backups/staging`, dann `bash scripts/deploy.sh staging deploy`.
**Der Grundumbau (Phasen 1–5) ist fertig.** Von Phase 6 ist die **Anwendungsseite gebaut** (Bildwelten, Marke je Website) – ohne eine einzige Theme-Datei zu ändern; der Rest ist ein Vertragsfall und steht als Aufgabe für die Theme-Sitzung in ZUSAMMENARBEIT.md §6: Favicon und die fest verdrahteten Grafiken in `ostsee-licht` auf `$theme->brand()` bzw. Plätze umstellen. Offen bleibt Phase 7 (mehrere Wohnungen je Website). Nicht im Plan und offen: Subscription/Abrechnung und die Zertifikatsfrage bei Strato.
### Hier weitermachen: Phase 7
Ziel (A21): Ein Baustein kann eine Wohnung **dieser Website** wählen; ohne Wahl gilt wie heute die Hauptwohnung. Voraussetzung für die Bergwohnung unter `fewo-stommer.de`.
**Der Kern braucht keine Theme-Änderung.** Bestehende Vorlagen rufen `$theme->property()`; wenn der Renderer vor dem Baustein die gewählte Wohnung setzt, bleiben sie unverändert gültig. Ein Eintrag in [ZUSAMMENARBEIT.md](ZUSAMMENARBEIT.md) §6 wird erst fällig, wenn **neue** Bausteine dazukommen (Übersicht aller Wohnungen, Suche über mehrere) – die brauchen eine Pflicht-Vorlage im Basis-Theme.
Anzufassen wären vermutlich:
| | |
|---|---|
| `app/Themes/Theme.php` | `property()` merkt sich die Wohnung (`$this->property`, `$this->propertyResolved`). Für Phase 7 braucht es einen Weg, sie je Baustein zu setzen und danach zurückzusetzen – am ehesten ein `runForProperty(Property $p, Closure $c)` nach dem Vorbild von `TenantContext::run()`. **Achtung:** eine solche Methode gibt es heute nicht – ein Test, der sie voraussetzt, schlägt fehl. |
| `app/Themes/Sections/*` | Gemeinsames Feld „Wohnung" im Admin-Formular der Bausteine, leer = Hauptwohnung. |
| Seiten-Renderer | Setzt die Wohnung, bevor der Baustein läuft. |
**Nicht vergessen:** Jede neue Tabelle bekommt `tenant_id` von Anfang an und gehört in `TenantArchive::DELETE_ORDER`, sonst überlebt sie die Kündigung ihres Mandanten. `tests/Feature/TenantSeparationTest.php` merkt das – aber nur, wenn der Testaufbau dort die neue Tabelle auch füllt.
### Ebenfalls offen
- **Theme-Teil von Phase 6:** Favicon und `partials/brand` in beiden Themes auf `$theme->brand()` bzw. Plätze umstellen, Seebads `motifs/`-Ordner gegen die Bildwelt tauschen. Steht als Aufgabe in ZUSAMMENARBEIT.md §6 und gehört der Theme-Sitzung.
- **Subscription und Abrechnung** – nicht Teil des Mandanten-Plans (§9 schließt sie aus). `service_usages` liegt als Grundlage bereit und zählt nichts.
- **Zertifikatsfrage bei Strato:** Ob eine Domain eines Mandanten aufgeschaltet werden kann **und** ein Zertifikat bekommt. Eine Subdomain bekommt keines. Davon hängt ab, ob „Mandant bringt seine Domain mit“ auf diesem Hosting trägt – das ist keine Code-Frage.
**Phase 3 ist ausgeliefert** (23.10.2026 abends). Die Migrationen sind auf der MariaDB von stommer.info durch, `settings` ist weg, die Werte stehen am Mandanten Stommer.
**Dienste-Steuerung und Host-Verwaltung sind ausgeliefert** (24.10.2026, Release `20261024072737`). Seitdem läuft stommer.info mit **zwei** Mandanten:
| | |
|---|---|
| Mandant 1 | `stommer` – die bestehenden Daten, Website „Ferienwohnung Stommer" |
| Mandant 2 | `testmandant` („Testmandant (Probe)") – **ohne Website und damit unter keiner Adresse erreichbar**. Das ist jetzt ein richtiger Zustand, kein Fehler: Einsprungsadressen vergibt der Betreiber, und dieser Mandant hat noch keine. Soll er erreichbar werden, braucht er eine Domain, die bei Strato auf dieses Verzeichnis zeigt. Betriebsart Test, Mails fallen auf `FEWO_NOTIFICATION_EMAIL` zurück. |
| Hosts | An der Website von Stommer stehen jetzt `stommer.info` (Hauptadresse) **und** `www.stommer.info`. Das war die Voraussetzung: ab dem zweiten Mandanten bekommt jede nicht eingetragene Adresse 404. |
| Geprüft nach dem Anlegen | `/`, `/wohnung`, `/buchen` auf beiden Hosts 200 und weiterhin Inhalte von Stommer; `/admin` und `/betreiber` 302. |
### Ausgeliefert
| | |
|---|---|
| Server | nur **stommer.info** (Staging). `www.fewo-stommer.de` ist unberührt und bleibt WordPress. |
| Release | `20261023100346`, Git-Tag `deploy/staging/20261023100346`, Commit `cec49da` |
| Code danach | Commits auf `main` nach `cec49da` sind Dokumentation. Sie sind nicht erneut ausgeliefert. Ein Deploy nur wegen dieser Texte ist unnötig: das Skript nimmt `docs/` nicht mit. |
| Migration | drei Migrationen vom 23.10. sind auf der MariaDB von stommer.info durch. Vorhandene Zeilen gehören zum Mandanten **Stommer** (`slug` `stommer`). Ein zweites Migrieren legt keinen zweiten Stommer an, solange keine Zeile ohne Mandant übrig ist. |
| Sicherung davor | `C:\Dev\fewo-backups\staging\20261023-120038` (Datenbank-Dump und Dateien). Ein Rollback der Version nimmt die Migration **nicht** zurück. |
| Release | `20261024152057`, Git-Tag `deploy/staging/20261024152057`, Commit `2c5b5fc` (**Phasen 1–5 vollständig**). Der Tag `20261024151841` zeigt auf denselben Commit – ein Deploy wurde wiederholt, weil die erste Ausgabe durch einen Absturz verloren ging. |
| Code danach | Commits auf `main` nach `2c5b5fc` sind Dokumentation. Sie sind nicht erneut ausgeliefert. Ein Deploy nur wegen dieser Texte ist unnötig: das Skript nimmt `docs/` nicht mit. |
| Migration | fünf Migrationen vom 23.10. sind auf der MariaDB von stommer.info durch. Vorhandene Zeilen gehören zum Mandanten **Stommer** (`slug` `stommer`); die Betriebsdaten stehen an dessen Spalten, `settings` ist weg. Ein zweites Migrieren legt keinen zweiten Stommer an, solange keine Zeile ohne Mandant übrig ist. |
| Sicherung davor | `C:\Dev\fewo-backups\staging\20261024-171534`; davor `…\20261024-102031`, `…\20261024-092543` und `…\20261023-215553` (die letzte mit noch vorhandener `settings`-Tabelle). Erstellt mit `scripts/backup-pull.sh staging`. Ein Rollback der Version nimmt die Migration **nicht** zurück. |
| Konto | `php artisan users:promote-operator lars@stommer.com` ist auf dem Server gelaufen. Passwort und 2FA sind gleich geblieben. |
| Prüfung | `https://stommer.info/`, `/wohnung` und `/buchen` antworten 200 und zeigen weiter Seebad und Stommer. `/admin` und `/betreiber` leiten ohne Anmeldung auf die Login-Seite um (302). Lars hat den Admin danach angemeldet geprüft: funktionsfähig. |
| Prüfung | `https://stommer.info/`, `/wohnung` und `/buchen` antworten 200 und zeigen weiter Seebad und Stommer samt Vermieterdaten aus den Mandanten-Spalten. `/admin` und `/betreiber` leiten ohne Anmeldung auf die Login-Seite um (302). Betriebsart Testbetrieb, Umleitung an `lars@stommer.com`. **Noch nicht angemeldet geprüft:** die Seite System › Betrieb mit den neuen Abschnitten. |
| Prüfung (24.10., nach Phase 4/5) | `/`, `/wohnung`, `/buchen` auf beiden Hosts 200; `/admin` und `/betreiber` 302. `bookings:expire-holds` läuft nachweislich **je Mandant** („Stommer: 0 …“, „Testmandant (Probe): 0 …“). `tenants:export testmandant` einmal auf dem Server ausgeführt; Exporte landen über den Symlink in `shared/storage/app/private/exports` (überleben jeden Deploy) und sind aus dem Web mit 403 gesperrt. **Nicht geprüft:** `tenants:delete` auf echten Daten – es löscht Dateien. |
Die lokale Datei `database/database.sqlite` (`.env`: `DB_CONNECTION=sqlite`, `APP_URL=http://localhost:8000`) ist **nicht** migriert. `php artisan serve` auf diesem Rechner trifft das alte Schema und läuft mit dem neuen Code nicht. Testinstanz ist stommer.info. Die lokale Datei nur migrieren, wenn jemand bewusst lokal arbeiten will (`php artisan migrate`, danach `users:promote-operator` für das lokale Konto). Die `.env` nicht auf die Datenbank von stommer.info zeigen lassen.
Die lokale Datei `database/database.sqlite` (`.env`: `DB_CONNECTION=sqlite`, `APP_URL=http://localhost:8000`) ist **nicht** vollständig migriert (die zwei Migrationen von Phase 3 stehen dort auf „Pending“). `php artisan serve` auf diesem Rechner trifft das alte Schema und läuft mit dem neuen Code nicht. Testinstanz ist stommer.info. Die lokale Datei nur migrieren, wenn jemand bewusst lokal arbeiten will (`php artisan migrate`, danach `users:promote-operator` für das lokale Konto). Die `.env` nicht auf die Datenbank von stommer.info zeigen lassen.
Nicht committet und nicht Teil des Umbaus: `styles/satz3/svg/haus.svg`, `styles/satz3/svg/haus-klein.svg`.
### Nicht anfassen, solange es nicht der Auftrag ist
- `resources/themes/**`. Seebad 0.3 ist auf stommer.info aktiv. Eine neue Theme-Datei erst nach Eintrag in ZUSAMMENARBEIT.md §6.
- Keinen zweiten Mandanten anlegen, bevor an der Website von Stommer der Host `stommer.info` steht (Webseite › Website, Feld Domain). Die Domain ist leer. Mit genau einem Mandanten liefert jeder Host die Standard-Website. Ab dem zweiten Mandanten antwortet ein unbekannter Host mit 404, `is_default` rettet ihn nicht. `www` ist ein eigener Host.
- Die Hosts stehen jetzt (`stommer.info`, `www.stommer.info`), und es gibt zwei Mandanten. Jede weitere Adresse muss **vor** ihrer Benutzung in Webseite › Website eingetragen werden, sonst 404. `is_default` rettet einen unbekannten Host nicht.
- `users.role` nicht löschen. Die Mitgliedschaft in `tenant_user` gilt; die Spalte bleibt der Übergang, wenn es genau einen Mandanten gibt und noch kein Kontext gesetzt ist.
- Tabelle `settings` nicht nebenbei leeren. Das ist Phase 3.
- `config/fewo.php` bleibt die Grundlinie und die Obergrenze. Werte des Mandanten gehören in die Spalten von `tenants`, nicht in neue `.env`-Schlüssel.
- Filaments `Panel::tenant()` und `tenantDomain()` nicht einschalten.
- Produktion nicht ausliefern. Deploy nur aus aktuellem `main` mit grünen Feature-Tests (`scripts/deploy.sh staging deploy`). Dabei läuft `migrate` mit. Die Datenbank nicht allein migrieren, während noch alter Code aktiv ist.
@@ -176,13 +214,33 @@ ### So ist es gebaut
| Rollen | `tenant_user.role`. `User::currentRole()`: Betreiber im gesetzten Kontext ist Mandanten-Administrator; sonst die Mitgliedschaft; sonst, bei genau einem Mandanten, `users.role`. `is_operator` ist nicht massenzuweisbar, nur `users:promote-operator`. In `canAccessPanel` als `(bool)` lesen, sonst kommt `null` zurück und der Panel-Zugriff wirft einen TypeError. Passwort und 2FA setzt ein Mandanten-Administrator nur zurück, wenn das Konto ausschließlich seinem Mandanten gehört. |
| Betreiber | Panel `operator`, Pfad `/betreiber`, entdeckt nur `App\Filament\Operator`. Mandant anlegen und bearbeiten. Löschen ist in der Policy falsch (Phase 5). „Im Admin öffnen“ schreibt `tenant_access_logs` und geht auf `https://<domain>/admin`. Der Menüpunkt „Anderer Mandant“ erscheint nur, wenn es eine weitere Mitgliedschaft mit Domain gibt. `routes/web.php` lässt `betreiber` nicht als Seiten-Slug durch. |
| Weitere Stellen | `Property::site()` ist `BelongsTo`. `Booking::website()` und `Guest::website()` laden die Website ohne Mandanten-Scope. `BookingObserver` lädt die Wohnung ohne Scope `tenant`, sonst fehlt sie bei einem fremden Kontext. Rate-Limits je IP und E-Mail enthalten die Mandanten-Id; `booking-request-all` bleibt global. Cache-Schlüssel der Texte: `content-blocks.{tenantId}`. |
| Noch global | Tabelle `settings` (Vermieter, Bank, Betriebsart, Fristen, Adressen). Postfach, Absender und der Scheduler kennen keinen Mandanten. Der Cronjob auf Strato ist weiterhin nicht eingerichtet, der Versandweg ist `log`. Das ist mit einem Mandanten der bisherige Betrieb. |
| `TenantConfig` (Phase 3) | Legt die Werte des Mandanten über `config('fewo.*')` und `mail.from`, sobald der Kontext gesetzt, gewechselt oder vergessen wird. Dadurch lesen Vorlagen, Mails und der Vertrag weiter dieselben Schlüssel, und `resources/themes/**` musste nicht angefasst werden. Die `.env` ist die Grundlinie. Ändert jemand von außen einen dieser Schlüssel (Test, Befehl), wird dieser Wert zur neuen Grundlinie statt beim nächsten Durchlauf überschrieben zu werden. |
| Grenzen (Phase 3) | Löschfristen und Bot-Schutz sind nach oben durch die `.env` gedeckelt (`AT_MOST`), die Mindestzeit im Formular nach unten (`AT_LEAST`); das Formular zeigt die Grenze an. Anzahlungsfrist, Bewertungsfrist und Portal-Fristen sind frei. Die Flutgrenze `spam.total_per_hour` bleibt global. |
| Betrieb (Phase 3) | Die Seite System › Betrieb schreibt jetzt den Mandanten des Kontextes (`Settings::tenant()`), nicht mehr die Tabelle `settings`. Sie enthält zusätzlich Vermieterdaten, Bank, Steuerangabe und die Fristen. Bank, Steuerangabe und Dienst-Schlüssel liegen über das `encrypted`-Cast verschlüsselt (`APP_KEY`). |
| Dienste (Phase 3) | `tenant_services` (Mandant, Schlüssel aus `App\Enums\TenantServiceKey`, an/aus, eigener API-Schlüssel) wird nur im Betreiber-Bereich am Mandanten-Formular geschaltet. `service_usages` steht bereit; es zählt noch nichts, weil kein Dienst aufruft. |
| `settings` | Entfernt. Modell `App\Models\Setting` gelöscht, `Settings::get/save` gibt es nicht mehr. |
| Läufe je Mandant (24.10.) | `App\Tenancy\TenantRunner` führt jeden Hintergrundlauf einmal je aktivem Mandanten aus, mit gesetztem Kontext (`routes/console.php` und die Befehle `bookings:expire-holds`, `channels:sync`, `channels:fetch-mail`). Ohne ihn sah der Scheduler bei zwei Mandanten **keinen** – Abfragen filterten nicht und der Absender fiel auf die `.env` zurück. Ein scheiternder Mandant hält die anderen nicht auf (Log-Eintrag). Die Datenbank-Sicherung bleibt global. |
| Postfach (24.10.) | Gehört dem Mandanten (`mailbox_*`, Passwort verschlüsselt, leerer Server = aus). Im Mandanten-Admin, sichtbar nur bei freigeschaltetem Dienst `portal_mail`. Die Cache-Schlüssel der Überwachung tragen den Mandanten. |
| Kündigung (24.10.) | `php artisan tenants:export <slug>` schreibt Zeilen und Dateien in ein Zip; `tenants:delete <slug>` exportiert erst, fragt nach und löscht dann einschließlich Medien. **Löschen ist bewusst keine Schaltfläche im Panel.** Konten, die nur zu diesem Mandanten gehörten, gehen mit; wer noch woanders arbeitet, und der Betreiber bleiben. Der Export nennt Konten mit Rolle, ohne Passwort-Hashes und ohne 2FA-Geheimnisse. Exporte liegen in `storage/app/private/exports` (nicht im Web, nicht in Git). |
| Dienste (24.10.) | `App\Tenancy\TenantFeatures` ist die einzige Stelle, die beantwortet, ob ein Mandant einen Dienst hat. Abgefragt in `RolePolicy::allows()` (damit in **jeder** Richtlinie des Admins), in `Channel::importsOccupations()`, im öffentlichen iCal-Feed und im Postfach-Schnellweg. Keine Rolle wiegt einen gesperrten Dienst auf. `TenantServiceKey::isWired()` trennt Gebautes von Geplantem: nur verdrahtete Dienste sind schaltbar, die drei KI-Dienste stehen als Hinweis. Eigene API-Schlüssel gehören später in den Admin des Mandanten, nicht zum Betreiber. |
| Bildwelten (24.10.) | Pakete in `resources/image-worlds/<key>/` (`world.json` + `svg/`), analog zu Themes. Website wählt, Wohnung darf überschreiben (A20). Vorlagen fragen über `$theme->motif($slot, $class, $label)` nach einem **Platz**, nie nach einer Datei (A19). Ein leerer Platz ist kein Fehler – es gibt dann keine Dekoration; `php artisan image-worlds:check` meldet Plätze ohne Datei. Die Ids im SVG werden je Aufruf eindeutig gemacht, sonst teilen sich zwei Kopien einer Grafik ihren Verlauf. Die Ostsee-Grafiken sind nach `image-worlds/ostsee` **kopiert**; `resources/themes/seebad/motifs/` ist unberührt, bis die Theme-Sitzung umstellt. |
| Marke (24.10.) | Logo, Favicon und Logo für E-Mail/Vertrag als Medien der **Website** (A14/A22), gepflegt unter Webseite › Website › Marke. `$theme->brand(...)` für Vorlagen. Der Mietvertrag bettet die Datei ein statt eine URL zu holen. Ohne Logo bleibt alles wie bisher. **Noch nicht umgestellt:** Favicon und `partials/brand` in den Themes – §6. |
| Einsprungsadressen (24.10.) | Gehören dem **Betreiber**: Mandanten-Formular › Einsprungsadressen, je Website eine Liste von Adressen. Die erste ist die Hauptadresse und steht in Gästelinks. Beim Anlegen entstehen Website, Host-Einträge und eine leere Startseite – ohne Startseite antwortet die Website 404. Im Mandanten-Admin sind die Adressen nur sichtbar. Eine fremde Adresse wird abgelehnt. Die Domain beim Hoster auf das Verzeichnis zu legen bleibt ein Schritt von Hand, auch bei Domains, die dem Mandanten gehören. |
| Links (24.10.) | `URL::forceRootUrl(APP_URL)` zwang **alle** Links auf einen festen Host – mit einem Mandanten unsichtbar, mit zwei Domains hätte jeder interne Link der zweiten Website auf die erste gezeigt. `ResolveTheme` setzt den Ursprung jetzt auf die **Hauptadresse der aufgelösten Website**. Wer über eine Nebenadresse kommt (`www`), bekommt trotzdem Links auf die Hauptadresse – ein kanonischer Host. |
| Gesperrter Mandant (24.10.) | Statt 404 eine schlichte Hinweisseite mit Status **503**, Text je Mandant einstellbar (sonst Standardtext). 503 hält die Seiten im Suchindex, weil eine Sperre vorübergehend ist. Gilt auch für `/admin` des Mandanten; der Betreiber kommt weiter hinein. |
| Systemweite Einstellungen (24.10.) | Betreiber › Einstellungen, gespeichert in `system_settings`: Löschfristen, Bot-Schutz, Flutgrenze, Sicherungen, Portal-Fristen, Versandweg, SMTP, harte Mail-Umleitung, Tokens. **Leer = der Wert der `.env` gilt wieder**, und zwar sofort. Geheimnisse liegen verschlüsselt. Datenbank-Zugang und `APP_KEY` sind nicht dabei und können es nicht sein: sie werden gebraucht, um die Datenbank zu öffnen und das Gespeicherte zu entschlüsseln. Betreiber › System bleibt die Übersicht (Mandanten, geltende Werte, Zugriffsprotokoll). |
| Noch global | Postfach, Absender des Scheduler-Laufs und der Scheduler selbst kennen keinen Mandanten (Rest von Phase 4). Der Cronjob auf Strato ist weiterhin nicht eingerichtet, der Versandweg ist `log`. Das ist mit einem Mandanten der bisherige Betrieb. Ein Mandant ohne eigene Adressen fällt für die Testumleitung auf `FEWO_NOTIFICATION_EMAIL` zurück, damit nichts versehentlich an echte Gäste geht. |
Tests dazu: `tests/Feature/TenantIsolationTest.php`, `TenantAccessTest.php`, `WebsiteTenancyTest.php`. Zuletzt 217 Feature-Tests grün. PHP auf diesem Rechner: `%LOCALAPPDATA%\Microsoft\WinGet\Packages\PHP.PHP.NTS.8.4_*\php.exe`, nicht im PATH der Git-Bash. Für `scripts/deploy.sh` von hier `COMPOSER_BIN` auf `php …/composer/composer.phar` setzen, sonst findet die Bash kein `composer`.
Tests dazu: `TenantIsolationTest`, `TenantAccessTest`, `WebsiteTenancyTest`, `TenantSettingsTest`, `OperationsModeTest`, `TenantServiceGateTest`, `TenantProvisioningTest`, `SystemSettingsTest`, `TenantScheduleTest` und `TenantSeparationTest` (alle in `tests/Feature`). Zuletzt 262 Feature-Tests grün. PHP auf diesem Rechner: `%LOCALAPPDATA%\Microsoft\WinGet\Packages\PHP.PHP.NTS.8.4_*\php.exe`, nicht im PATH der Git-Bash. Für `scripts/deploy.sh` von hier `COMPOSER_BIN` auf `php …/composer/composer.phar` setzen, sonst findet die Bash kein `composer`.
### Offen, aber nicht in derselben Sitzung nötig gewesen
- Phase 3, Rest von Phase 4, Phase 5. Jede davon bringt eigene Migrationen. Auslieferung und Migration wieder in einem Schritt, nach Sicherung.
- Rest von Phase 4 und Phase 5. Jede davon bringt eigene Migrationen. Auslieferung und Migration wieder in einem Schritt, nach Sicherung.
- **Bankverbindung eintragen:** Die `.env` von stommer.info hat keine `FEWO_BANK_*`-Werte, deshalb sind Kontoinhaber, IBAN, BIC und Bank am Mandanten leer (wie vorher auch). Sie gehören jetzt in System › Betrieb › Bankverbindung und Steuer; `mail/partials/bank.blade.php` und der Vertrag zeigen den Block erst, wenn eine IBAN da ist.
- **Testmandant wieder loswerden,** wenn er nicht mehr gebraucht wird. Löschen ist erst Phase 5; bis dahin im Betreiber-Bereich den Zugang ausschalten.
- **Noch nicht am lebenden Server geprüft:** die Hinweisseite eines gesperrten Mandanten und das Anlegen einer Website über den Betreiber-Admin. Beides deckt die Testsuite ab, aber es fehlt eine Domain, unter der sich ein zweiter Mandant wirklich zeigen ließe.
- **Subscription** (was ein Mandant bucht, Abrechnung) ist noch nirgends abgebildet. `service_usages` steht als Grundlage bereit, es zählt nichts.
- **Vor jeder weiteren Adresse:** Jede Schreibweise ist ein eigener Host. Kommt `fewo-stommer.de` dazu, gehören `fewo-stommer.de` **und** `www.fewo-stommer.de` in das Feld „Weitere Adressen", sonst antwortet eine davon mit 404.
- Betreiber-Bereich https://stommer.info/betreiber einmal öffnen. Der Admin ist geprüft.
- Host `stommer.info` an der Website eintragen, bevor ein zweiter Mandant entsteht. Später ebenso `www` und `fewo-stommer.de`, wenn die Produktion umzieht.
- Brigitte, Cronjob, SMTP, Rechtstexte: Abschnitt 4, unverändert und unabhängig vom Mandanten-Code.
+1
View File
@@ -106,6 +106,7 @@ ## 5. Bausteinkatalog – Vertrag der Vorlagen
| `text_image` | Text mit Bildern | `$eyebrow`, `$heading`, `$text` (HtmlString\|null), `$photos` (≤3), `$imagePosition` (`left`\|`right`), `$linkLabel`, `$linkUrl` |
| `gallery` | Bildergalerie | `$heading`, `$photos` – Lightbox: `<a href="{{ $photo->url('lg') }}" data-lightbox data-alt="…">` |
| `amenities` | Ausstattung | `$heading`, `$groups` (Bereich ⇒ Collection<Amenity>) |
| `floor_plan` | Grundriss (interaktiv) | `$heading`, `$text`, `$photo` (Grundriss-Bild, `Photo`), `$rooms` (Collection von Arrays: `key` – Anker-ID, `name`, `description`, `hint` – Barrierefreiheit, `points` – „x,y x,y …“ in **Prozent** des Bildes → SVG `viewBox="0 0 100 100" preserveAspectRatio="none"` über dem Bild, `photos` – Collection<Photo>, `amenities` – Collection<string>). Rendert nichts ohne Bild oder Räume. Daten: Admin › Webseite › Grundriss (`FloorPlan`) |
| `location` | Lage & Umgebung | `$eyebrow`, `$heading`, `$text`, `$address`, `$mapUrl` (OpenStreetMap-Link, keine eingebettete Karte), `$photos` |
| `prices` | Preise & Saisons | `$eyebrow`, `$heading`, `$text`, `$property`, `$seasons` (nächste 12 Monate), `$extras`, `$featuredSeason` (Name des Erscheinungsbilds) |
| `offers` | Sonderangebote | `$heading`, `$display` (`grid`\|`list`\|`rotating`), `$offers` (Collection<`App\Pricing\AdvertisedOffer`>: `title`, `description`, `advantage`, `conditions`, `arrival`/`departure`/`nights()` bei festen Terminen und Lücken, `quote` + `regularTotal()` für „statt …“, `bookingUrl()`). Rollierend: `data-rotator`, `data-rotator-slide`, `data-rotator-prev/next/dot` (theme.js) |
+4 -1
View File
@@ -74,7 +74,7 @@ ## 5. Wünsche der Design-Session an die Anwendung
| 23.10.2026 | **Darstellungsvarianten je Baustein** (`theme.json › variants`), Feld „Darstellung“ im Seiten-Baukasten (DESIGN-KONZEPT §7 Nr. 2) | offen |
| 23.10.2026 | **Baustein „Tipps der Gastgeberin“**: Orte mit Kategorie (Strand, Seebrücke, Bahn, Rad, Wald …), Weg/Gehzeit, Text, Foto, Karten-Link; saisonal filterbar. Seebad zeigt je Kategorie eine Vignette der Bildwelt (DESIGN-KONZEPT §7 Nr. 4) | offen |
| 23.10.2026 | **Baustein „Gut zu wissen“**: strukturierte Angaben (Zugang/Stufen, Dusche, Rollstuhl, Haustiere, An-/Abreisezeiten, Parken) an der Wohnung; Seebad stellt ihn in der Kartusche dar (DESIGN-KONZEPT §7 Nr. 5) | offen |
| 23.10.2026 | **Bildwelt-System** (MANDANTEN-ANFORDERUNGEN A18–A20): Seebad nutzt schon Plätze über `partials/motif` (`mark`, `divider`, `closing`, `crest`, `gulls`, `vignette.*`) | offen |
| 23.10.2026 | **Bildwelt-System** (MANDANTEN-ANFORDERUNGEN A18–A20): Seebad nutzt schon Plätze über `partials/motif` (`mark`, `divider`, `closing`, `crest`, `gulls`, `vignette.*`) | **erledigt in `4e66add`** – Anwendungsseite steht, siehe §6 |
| 23.10.2026 | Hilfetext „*Wort* wird hervorgehoben“ im Titelbereich ist theme-abhängig (Seebad hebt nicht hervor) – Hinweis neutral formulieren | offen |
| 23.10.2026 | **Menübild je Seite** (Feld an der Seite, Auswahl aus den Fotos, `PhotoSelect`) und optional ein kurzer **Menütext** – Seebad zeigt beides in den Menü-Tafeln; heute nur SEO-Beschreibung und Sprunglinks | offen |
@@ -88,4 +88,7 @@ ## 6. Änderungsprotokoll Vorlagen-Vertrag
| 22.10.2026 | Markengrafiken: `@include('theme::partials.brand', ['name' => 'mark', 'class' => '…'])` (mark, logo, wave-divider, icon-apartment/-sea/-terrace/-location); Farben über `--brand-navy/-teal/-wave/-sun` (navy = Textfarbe) | header, footer, facts, location, image |
| 22.10.2026 | `hero`: `$featuredOffer` (wichtigstes hervorgehobenes Angebot oder null) | sections/hero |
| 22.10.2026 | `offers`: `$display` (grid/list/rotating), `$offers` = `AdvertisedOffer` (Termin, Preis, `bookingUrl()`); rollierend über `data-rotator*` | sections/offers |
| 23.10.2026 | **Neuer Baustein `floor_plan`** (Grundriss interaktiv): Vertrag in THEMES.md §5; Basis-Vorlage `ostsee-licht/views/sections/floor_plan.blade.php` (ohne JS: Flächen springen zur Raumliste), Seebad interaktiv (`theme.js` `initFloorPlans`). Neue Themes brauchen keine eigene Vorlage (Vererbung) | sections/floor_plan |
| 24.10.2026 | **Bildwelt-System steht (Anwendungsseite).** `$theme->motif($slot, $class, $label)` liefert das Inline-SVG des Platzes, `$theme->hasMotif($slot)` sagt, ob der Platz gefüllt ist, `$theme->imageWorld()` nennt die aktive Bildwelt. Bildwelten liegen in `resources/image-worlds/<key>/` (`world.json` + `svg/`), Auswahl an der Website, Überschreibung an der Wohnung. Die Ostsee-Grafiken sind als Bildwelt `ostsee` **kopiert** – `resources/themes/seebad/motifs/` ist unverändert. **Seebad kann jetzt** sein `partials/motif.blade.php` auf `{!! $theme->motif($slot, $class ?? null, $label ?? null) !!}` verkürzen und seinen `motifs/`-Ordner löschen. `php artisan image-worlds:check` zeigt, welcher Platz von welcher Bildwelt gefüllt wird. | sections/*, partials/motif |
| 24.10.2026 | **Marke je Website** (A14/A22): `$theme->brand('logo'|'favicon'|'document_logo')` liefert die URL oder null. Gepflegt unter Webseite › Website › Marke. **Noch offen und ein Fall für euch:** `ostsee-licht/views/layouts/app.blade.php` holt das Favicon aus `public/brand/`, Seebad aus seinen eigenen Assets – beide sollten zuerst `$theme->brand('favicon')` fragen und nur sonst auf ihre eigene Datei zurückfallen. Dasselbe gilt für `ostsee-licht/views/partials/brand.blade.php`, das noch fest verdrahtete Ostsee-Grafiken zeigt (A19). | layouts/app, partials/brand |
| 22.10.2026 | Seiten außerhalb der Bausteine, die das Theme-Layout nutzen: Angebotsseite `resources/views/offer.blade.php`, Bewertung `resources/views/review.blade.php` – beim Theme-Test mitprüfen | layouts/app |
@@ -0,0 +1,20 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1600 150" preserveAspectRatio="xMidYMid meet" role="presentation" aria-hidden="true">
<defs><clipPath id="band-pier-horizon"><rect x="1160" y="20" width="140" height="78"/></clipPath></defs>
<circle cx="1230" cy="98" r="50" fill="var(--brand-sun, #F2C27A)" clip-path="url(#band-pier-horizon)"/>
<g fill="var(--brand-navy, #0B2E55)">
<rect x="1100" y="92" width="380" height="6" rx="1"/>
<rect x="1100" y="80" width="300" height="2.5"/>
<path d="M1108 80 V92 M1126 80 V92 M1144 80 V92 M1162 80 V92 M1180 80 V92 M1198 80 V92 M1216 80 V92 M1234 80 V92 M1252 80 V92 M1270 80 V92 M1288 80 V92 M1306 80 V92 M1324 80 V92 M1342 80 V92 M1360 80 V92 M1378 80 V92" stroke="var(--brand-navy, #0B2E55)" stroke-width="2"/>
<path d="M1112 98 H1117 V112 H1112 Z M1150 98 H1155 V112 H1150 Z M1188 98 H1193 V112 H1188 Z M1226 98 H1231 V112 H1226 Z M1264 98 H1269 V112 H1264 Z M1302 98 H1307 V112 H1302 Z M1340 98 H1345 V112 H1340 Z M1378 98 H1383 V112 H1378 Z M1416 98 H1421 V112 H1416 Z M1454 98 H1459 V112 H1454 Z"/>
<rect x="1410" y="72" width="44" height="20"/>
<path d="M1404 74 L1432 50 L1460 74 Z"/>
<path d="M1430 50 L1432 34 L1434 50 Z"/>
<rect x="1160" y="56" width="2" height="24"/>
<path d="M1162 56 L1174 60 L1162 64 Z"/>
<rect x="1380" y="60" width="2" height="20"/>
<path d="M1382 60 L1392 64 L1382 68 Z"/>
</g>
<path fill="none" stroke="var(--brand-navy, #0B2E55)" stroke-width="3" stroke-linecap="round" d="M1060 44 Q1068 36 1076 44 Q1084 34 1094 40 M1020 64 Q1025 59 1030 64 Q1035 58 1041 61"/>
<path fill="var(--brand-teal, #0286A2)" d="M10 104 C200 70 400 68 600 90 C800 112 1000 112 1200 106 C1350 102 1480 96 1590 80 C1440 130 1260 126 1100 120 C900 114 760 120 600 108 C400 88 200 92 10 104 Z"/>
<path fill="var(--brand-wave, #6DBFC2)" d="M60 122 C240 102 420 104 600 120 C800 136 1000 130 1200 124 C1340 120 1460 116 1540 110 C1400 142 1220 142 1060 136 C900 132 760 136 600 130 C420 118 240 116 60 122 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

@@ -0,0 +1,21 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1600 150" preserveAspectRatio="xMidYMid meet" role="presentation" aria-hidden="true">
<defs><clipPath id="band-sonne-horizon"><rect x="740" y="20" width="120" height="78"/></clipPath></defs>
<circle cx="800" cy="98" r="44" fill="var(--brand-sun, #F2C27A)" clip-path="url(#band-sonne-horizon)"/>
<path fill="var(--brand-sun, #F2C27A)" d="M760 104 H840 A3 3 0 0 1 840 110 H760 A3 3 0 0 1 760 104 Z M776 118 H824 A3 3 0 0 1 824 124 H776 A3 3 0 0 1 776 118 Z"/>
<g fill="var(--brand-reed, #C9A15E)" transform="translate(744 100) scale(-1 1)">
<path d="M0 0 C-4 -20 -14 -38 -30 -50 C-18 -34 -10 -18 -4 0 Z"/>
<path d="M2 0 C2 -22 -2 -42 -12 -62 C-4 -40 -2 -20 -2 0 Z"/>
<path d="M4 0 C8 -18 16 -34 28 -46 C18 -30 10 -16 8 0 Z"/>
<path d="M6 0 C14 -12 24 -22 36 -26 C26 -18 16 -8 10 0 Z"/>
<path d="M-2 0 C-10 -10 -22 -18 -36 -20 C-22 -14 -12 -6 -6 0 Z"/>
</g>
<g fill="var(--brand-reed, #C9A15E)" transform="translate(856 100)">
<path d="M0 0 C-4 -20 -14 -38 -30 -50 C-18 -34 -10 -18 -4 0 Z"/>
<path d="M2 0 C2 -22 -2 -42 -12 -62 C-4 -40 -2 -20 -2 0 Z"/>
<path d="M4 0 C8 -18 16 -34 28 -46 C18 -30 10 -16 8 0 Z"/>
<path d="M6 0 C14 -12 24 -22 36 -26 C26 -18 16 -8 10 0 Z"/>
<path d="M-2 0 C-10 -10 -22 -18 -36 -20 C-22 -14 -12 -6 -6 0 Z"/>
</g>
<path fill="var(--brand-teal, #0286A2)" d="M10 104 C200 66 400 64 600 88 C690 98 750 104 800 100 C850 96 910 88 1000 88 C1200 88 1400 112 1590 74 C1420 128 1220 120 1000 108 C910 104 850 112 800 114 C750 116 690 114 600 106 C400 84 200 88 10 104 Z"/>
<path fill="var(--brand-wave, #6DBFC2)" d="M60 122 C240 100 420 102 600 118 C690 126 750 128 800 126 C850 124 910 116 1000 116 C1180 116 1360 134 1540 110 C1380 142 1200 140 1000 130 C910 126 850 134 800 136 C750 138 690 136 600 130 C420 116 240 114 60 122 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

@@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 66" role="img" aria-label="Rundbogengaube">
<title>Rundbogengaube</title>
<path fill="var(--brand-navy, #13294B)" d="M6 64 V54 A54 54 0 0 1 114 54 V64 Z"/>
<path fill="var(--brand-paper, #F6F1E4)" d="M13 62 V54 A47 47 0 0 1 107 54 V62 Z"/>
<path fill="var(--brand-glass, #9FD3E6)" d="M20 60 V54 A40 40 0 0 1 100 54 V60 Z"/>
<path fill="none" stroke="var(--brand-paper, #F6F1E4)" stroke-width="3.2" stroke-linecap="square" d="M60 14 V60 M20 52 H100 M60 52 L32 25 M60 52 L88 25"/>
<path fill="var(--brand-navy, #13294B)" d="M54 2 H66 L64 12 H56 Z"/>
<path fill="none" stroke="var(--brand-navy, #13294B)" stroke-width="2.5" stroke-linecap="round" d="M0 64 H120"/>
</svg>

After

Width:  |  Height:  |  Size: 739 B

@@ -0,0 +1,16 @@
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="34" role="presentation" aria-hidden="true">
<defs>
<pattern id="gelaender-feld" patternUnits="userSpaceOnUse" width="132" height="34">
<g fill="var(--brand-paper, #F6F1E4)" stroke="var(--brand-navy, #13294B)" stroke-width="1.2">
<rect x="14" y="9" width="4" height="17"/><rect x="26" y="9" width="4" height="17"/><rect x="38" y="9" width="4" height="17"/>
<rect x="50" y="9" width="4" height="17"/><rect x="62" y="9" width="4" height="17"/><rect x="74" y="9" width="4" height="17"/>
<rect x="86" y="9" width="4" height="17"/><rect x="98" y="9" width="4" height="17"/><rect x="110" y="9" width="4" height="17"/>
<rect x="0.6" y="3" width="8" height="30" rx="1"/>
<rect x="0.6" y="5" width="132" height="4"/>
<rect x="0.6" y="26" width="132" height="3.5"/>
<rect x="-1" y="1" width="12" height="3" rx="1"/>
</g>
</pattern>
</defs>
<rect width="100%" height="34" fill="url(#gelaender-feld)"/>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="presentation" aria-hidden="true">
<g fill="var(--brand-paper, #F6F1E4)" stroke="var(--brand-navy, #13294B)" stroke-width="1.6" stroke-linejoin="round">
<path d="M1 1 H47 V7 H7 V47 H1 Z"/>
<path d="M7 30 L30 7 H38 L7 38 Z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 314 B

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 50" role="presentation" aria-hidden="true">
<path fill="none" stroke="var(--brand-navy, #0B2E55)" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" d="M8 26 Q20 12 32 24 Q46 6 62 16 M70 40 Q78 32 86 40 Q94 30 104 36 M88 14 Q93 9 98 14 Q103 8 110 11"/>
</svg>

After

Width:  |  Height:  |  Size: 332 B

@@ -0,0 +1,27 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 180" role="img" aria-label="Bäderbahn Molli">
<title>Bäderbahn Molli</title>
<g fill="var(--brand-wave, #6DBFC2)">
<circle cx="66" cy="54" r="14"/><circle cx="84" cy="44" r="16"/><circle cx="104" cy="40" r="13"/><circle cx="120" cy="34" r="11"/><circle cx="80" cy="60" r="10"/>
</g>
<g fill="var(--brand-navy, #0B2E55)">
<path d="M58 62 H74 L72 70 V92 H60 V70 Z"/>
<rect x="44" y="90" width="66" height="30" rx="8"/>
<rect x="104" y="76" width="34" height="44" rx="2"/>
<rect x="100" y="72" width="42" height="6" rx="2"/>
<rect x="80" y="82" width="10" height="10" rx="5"/>
</g>
<rect x="112" y="84" width="18" height="14" fill="var(--brand-paper, #F6F1E4)"/>
<rect x="40" y="118" width="102" height="8" fill="var(--brand-brick, #A63A2B)"/>
<g fill="var(--brand-paper, #F6F1E4)" stroke="var(--brand-navy, #0B2E55)" stroke-width="2.5">
<rect x="146" y="86" width="74" height="34" rx="3"/>
</g>
<rect x="146" y="108" width="74" height="12" fill="var(--brand-brick, #A63A2B)"/>
<path fill="var(--brand-navy, #0B2E55)" d="M142 82 H224 V88 H142 Z M154 92 H166 V102 H154 Z M172 92 H184 V102 H172 Z M190 92 H202 V102 H190 Z M206 92 H216 V102 H206 Z"/>
<g fill="var(--brand-brick, #A63A2B)" stroke="var(--brand-navy, #0B2E55)" stroke-width="3">
<circle cx="60" cy="132" r="9"/><circle cx="84" cy="132" r="9"/><circle cx="108" cy="132" r="9"/>
<circle cx="160" cy="128" r="6"/><circle cx="206" cy="128" r="6"/>
</g>
<path fill="none" stroke="var(--brand-navy, #0B2E55)" stroke-width="3" stroke-linecap="round" d="M60 132 H108 M24 142 H228"/>
<path fill="var(--brand-teal, #0286A2)" d="M6 156 C50 136 98 132 142 142 C178 150 208 150 234 140 C216 160 182 168 142 164 C102 160 62 150 6 156 Z"/>
<path fill="var(--brand-wave, #6DBFC2)" d="M22 170 C62 158 106 160 142 168 C174 176 202 174 228 166 C208 178 174 180 138 176 C102 172 66 166 22 170 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

@@ -0,0 +1,21 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 180" role="img" aria-label="Mit dem Rad an der Küste">
<title>Mit dem Rad an der Küste</title>
<defs><clipPath id="rad-horizon"><rect x="120" y="20" width="110" height="88"/></clipPath></defs>
<circle cx="172" cy="104" r="40" fill="var(--brand-sun, #F2C27A)" clip-path="url(#rad-horizon)"/>
<path fill="var(--brand-wave, #6DBFC2)" d="M118 108 H234 V118 H118 Z"/>
<path fill="var(--brand-navy, #0B2E55)" d="M200 92 H205 V122 H200 Z M212 96 H217 V122 H212 Z"/>
<path fill="var(--brand-sun, #F2C27A)" opacity="0.55" d="M8 150 C60 128 110 120 160 124 C190 126 214 132 234 140 V150 Z"/>
<g fill="var(--brand-reed, #C9A15E)" transform="translate(26 138)">
<path d="M0 0 C-4 -16 -10 -30 -22 -40 C-12 -28 -6 -14 -4 0 Z"/>
<path d="M2 0 C2 -18 0 -34 -6 -50 C0 -32 0 -16 -2 0 Z"/>
<path d="M4 0 C8 -14 14 -26 24 -36 C16 -24 10 -12 8 0 Z"/>
</g>
<g fill="none" stroke="var(--brand-navy, #0B2E55)" stroke-width="5" stroke-linecap="round" stroke-linejoin="round">
<circle cx="76" cy="116" r="22"/>
<circle cx="146" cy="116" r="22"/>
<path d="M76 116 L100 88 L134 88 L146 116 M100 88 L112 116 L76 116 M112 116 L134 88 M94 78 L108 78 M134 88 L130 74 L142 72"/>
</g>
<path fill="none" stroke="var(--brand-navy, #0B2E55)" stroke-width="3" stroke-linecap="round" d="M150 48 Q158 40 166 48 Q174 38 184 44"/>
<path fill="var(--brand-teal, #0286A2)" d="M6 158 C50 140 98 136 142 146 C178 154 208 154 234 144 C216 164 182 170 142 166 C102 162 62 152 6 158 Z"/>
<path fill="var(--brand-wave, #6DBFC2)" d="M22 172 C62 160 106 162 142 170 C174 178 202 176 228 168 C208 178 174 180 138 178 C102 174 66 168 22 172 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

@@ -0,0 +1,22 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 180" role="img" aria-label="Seebrücke">
<title>Seebrücke</title>
<defs><clipPath id="pier-horizon"><rect x="60" y="20" width="140" height="106"/></clipPath></defs>
<circle cx="128" cy="122" r="52" fill="var(--brand-sun, #F2C27A)" clip-path="url(#pier-horizon)"/>
<g fill="var(--brand-navy, #0B2E55)">
<rect x="22" y="114" width="196" height="7" rx="1"/>
<rect x="22" y="100" width="150" height="3"/>
<path d="M30 100 V114 M48 100 V114 M66 100 V114 M84 100 V114 M102 100 V114 M120 100 V114 M138 100 V114 M156 100 V114" stroke="var(--brand-navy, #0B2E55)" stroke-width="2.5"/>
<path d="M34 121 H40 V146 H34 Z M64 121 H70 V146 H64 Z M94 121 H100 V146 H94 Z M124 121 H130 V146 H124 Z M154 121 H160 V146 H154 Z M184 121 H190 V146 H184 Z M206 121 H212 V146 H206 Z"/>
<rect x="176" y="92" width="38" height="22"/>
<path d="M170 94 L195 72 L220 94 Z"/>
<path d="M193 72 L195 56 L197 72 Z"/>
<rect x="58" y="74" width="2.5" height="26"/>
<path d="M60.5 74 L74 78 L60.5 82 Z"/>
<rect x="148" y="78" width="2.5" height="22"/>
<path d="M150.5 78 L162 82 L150.5 86 Z"/>
</g>
<path fill="var(--brand-paper, #F6F1E4)" d="M182 98 H190 V108 H182 Z M200 98 H208 V108 H200 Z"/>
<path fill="none" stroke="var(--brand-navy, #0B2E55)" stroke-width="3" stroke-linecap="round" d="M34 50 Q42 42 50 50 Q58 40 68 46"/>
<path fill="var(--brand-teal, #0286A2)" d="M6 152 C50 124 98 118 142 132 C178 144 208 142 234 128 C216 154 182 166 142 160 C102 154 62 140 6 152 Z"/>
<path fill="var(--brand-wave, #6DBFC2)" d="M22 168 C62 150 106 152 142 164 C174 174 202 172 228 160 C208 176 174 180 138 174 C102 168 66 160 22 168 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

@@ -0,0 +1,15 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 180" role="img" aria-label="Strand mit Sonne">
<title>Strand mit Sonne</title>
<defs><clipPath id="strand-horizon"><rect x="90" y="30" width="140" height="102"/></clipPath></defs>
<circle cx="150" cy="128" r="50" fill="var(--brand-sun, #F2C27A)" clip-path="url(#strand-horizon)"/>
<path fill="var(--brand-sun, #F2C27A)" d="M112 138 H188 A3 3 0 0 1 188 144 H112 A3 3 0 0 1 112 138 Z M128 150 H172 A3 3 0 0 1 172 156 H128 A3 3 0 0 1 128 150 Z"/>
<path fill="none" stroke="var(--brand-navy, #0B2E55)" stroke-width="3" stroke-linecap="round" d="M156 54 Q164 46 172 54 Q180 44 190 50 M180 76 Q185 71 190 76 Q195 70 201 73"/>
<g fill="var(--brand-reed, #C9A15E)" transform="translate(46 150) scale(1.5)">
<path d="M0 0 C-4 -20 -14 -38 -30 -50 C-18 -34 -10 -18 -4 0 Z"/>
<path d="M2 0 C2 -22 -2 -42 -12 -62 C-4 -40 -2 -20 -2 0 Z"/>
<path d="M4 0 C8 -18 16 -34 28 -46 C18 -30 10 -16 8 0 Z"/>
<path d="M6 0 C14 -12 24 -22 36 -26 C26 -18 16 -8 10 0 Z"/>
</g>
<path fill="var(--brand-teal, #0286A2)" d="M6 152 C50 120 98 114 142 130 C178 143 208 142 234 126 C216 154 182 166 142 160 C102 154 62 140 6 152 Z"/>
<path fill="var(--brand-wave, #6DBFC2)" d="M22 168 C62 150 106 152 142 164 C174 174 202 172 228 160 C208 176 174 180 138 174 C102 168 66 160 22 168 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

@@ -0,0 +1,24 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 180" role="img" aria-label="Küstenwald">
<title>Küstenwald</title>
<defs><clipPath id="wald-horizon"><rect x="140" y="40" width="96" height="84"/></clipPath></defs>
<circle cx="190" cy="120" r="38" fill="var(--brand-sun, #F2C27A)" clip-path="url(#wald-horizon)"/>
<g fill="var(--brand-navy, #0B2E55)">
<path d="M58 140 L62 70 L66 140 Z"/>
<path d="M92 140 L95 56 L99 140 Z"/>
<path d="M124 140 L127 76 L131 140 Z"/>
<path d="M150 140 L152 92 L155 140 Z"/>
<path d="M95 92 L78 80 M95 80 L112 70 M62 96 L48 88 M127 100 L142 90" stroke="var(--brand-navy, #0B2E55)" stroke-width="3" stroke-linecap="round"/>
</g>
<g fill="var(--brand-teal, #0286A2)">
<ellipse cx="62" cy="70" rx="26" ry="16"/><ellipse cx="44" cy="84" rx="18" ry="11"/>
<ellipse cx="96" cy="52" rx="30" ry="18"/><ellipse cx="120" cy="66" rx="20" ry="12"/>
<ellipse cx="128" cy="78" rx="24" ry="14"/><ellipse cx="152" cy="92" rx="16" ry="10"/>
</g>
<g fill="var(--brand-navy, #0B2E55)" opacity="0.85">
<ellipse cx="74" cy="62" rx="16" ry="10"/><ellipse cx="104" cy="44" rx="16" ry="9"/><ellipse cx="136" cy="72" rx="12" ry="8"/>
</g>
<path fill="var(--brand-reed, #C9A15E)" d="M30 140 C60 132 140 130 200 136 C214 138 226 140 234 142 V146 H30 Z"/>
<path fill="none" stroke="var(--brand-navy, #0B2E55)" stroke-width="3" stroke-linecap="round" d="M196 70 Q202 64 208 70 Q214 62 222 66"/>
<path fill="var(--brand-teal, #0286A2)" d="M6 158 C50 140 98 136 142 146 C178 154 208 154 234 144 C216 164 182 170 142 166 C102 162 62 152 6 158 Z"/>
<path fill="var(--brand-wave, #6DBFC2)" d="M22 172 C62 160 106 162 142 170 C174 178 202 176 228 168 C208 178 174 180 138 178 C102 174 66 168 22 172 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

+17
View File
@@ -0,0 +1,17 @@
{
"name": "Ostsee",
"description": "Bänder, Vignetten und Ornamente der Ostseeküste: Sonne, Seebrücke, Möwen, Molli.",
"slots": {
"divider": "band-sonne",
"closing": "band-seebruecke",
"crest": "gaube",
"railing": "gelaender",
"bracket": "kopfband",
"gulls": "moewen",
"vignette.beach": "vignette-strand",
"vignette.pier": "vignette-seebruecke",
"vignette.train": "vignette-molli",
"vignette.bike": "vignette-rad",
"vignette.forest": "vignette-wald"
}
}
@@ -0,0 +1,42 @@
{{--
Contract: $heading, $text, $photo (App\Models\Photo, the plan picture), $rooms (Collection of arrays: key, name,
description, hint, points = "x,y x,y …" in percent of the picture, photos = Collection<Photo>, amenities = Collection<string>).
Base version without JavaScript: the areas on the plan jump to the room descriptions below.
--}}
@if ($photo && $rooms->isNotEmpty())
<section class="mx-auto max-w-7xl px-4 py-16 sm:px-8" aria-labelledby="{{ $sectionId }}-title">
<h2 id="{{ $sectionId }}-title" class="heading-display">{{ $heading }}</h2>
@if ($text)<p class="mt-3 max-w-2xl text-muted">{{ $text }}</p>@endif
<div class="relative mt-8">
@include('theme::partials.image', ['photo' => $photo, 'sizes' => '(min-width: 1280px) 80rem, 100vw', 'class' => 'h-auto w-full'])
<svg viewBox="0 0 100 100" preserveAspectRatio="none" class="absolute inset-0 size-full" aria-label="Räume im Grundriss">
@foreach ($rooms as $room)
<a href="#{{ $room['key'] }}" aria-label="{{ $room['name'] }}">
<polygon points="{{ $room['points'] }}" class="fill-accent/0 stroke-accent transition hover:fill-accent/20" stroke-width="0.25" vector-effect="non-scaling-stroke"><title>{{ $room['name'] }}</title></polygon>
</a>
@endforeach
</svg>
</div>
<ul class="mt-10 grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
@foreach ($rooms as $room)
<li id="{{ $room['key'] }}" class="scroll-mt-24 rounded bg-surface p-6">
@if ($room['photos']->isNotEmpty())
@include('theme::partials.image', ['photo' => $room['photos']->first(), 'sizes' => '(min-width: 1024px) 25vw, 100vw', 'class' => 'mb-4 h-44 w-full rounded-sm object-cover'])
@endif
<h3 class="font-display text-2xl">{{ $room['name'] }}</h3>
@if ($room['description'])<p class="mt-2 text-muted">{{ $room['description'] }}</p>@endif
@if ($room['amenities']->isNotEmpty())
<ul class="mt-3 space-y-1 text-muted">
@foreach ($room['amenities'] as $amenity)
<li class="flex gap-2"><span aria-hidden="true" class="text-accent">·</span>{{ $amenity }}</li>
@endforeach
</ul>
@endif
@if ($room['hint'])<p class="mt-3 border-l-2 border-accent pl-3 text-sm">{{ $room['hint'] }}</p>@endif
</li>
@endforeach
</ul>
</section>
@endif
+47
View File
@@ -50,3 +50,50 @@ function initMenuPanels() {
}
initMenuPanels();
/**
* Floor plan (sections/floor_plan): one room at a time. Areas and room buttons select a room; on narrow
* screens the description below the plan is scrolled into view. Without JavaScript all rooms are listed.
*/
function initFloorPlans() {
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
document.querySelectorAll('[data-floor-plan]').forEach((plan) => {
const rooms = [...plan.querySelectorAll('[data-floor-room]')];
const links = [...plan.querySelectorAll('[data-floor-room-link]')];
if (rooms.length === 0) {
return;
}
const select = (key, scroll) => {
rooms.forEach((room) => {
room.hidden = room.id !== key;
});
links.forEach((link) => {
const active = link.dataset.floorRoomLink === key;
link.toggleAttribute('data-active', active);
if (active) {
link.setAttribute('aria-current', 'true');
} else {
link.removeAttribute('aria-current');
}
});
const room = rooms.find((candidate) => candidate.id === key);
if (scroll && room && room.getBoundingClientRect().top > window.innerHeight) {
room.scrollIntoView({ behavior: reduceMotion ? 'auto' : 'smooth', block: 'nearest' });
}
};
links.forEach((link) => {
link.addEventListener('click', (event) => {
event.preventDefault();
select(link.dataset.floorRoomLink, true);
});
});
const fromHash = rooms.find((room) => `#${room.id}` === window.location.hash);
select((fromHash ?? rooms[0]).id, false);
});
}
initFloorPlans();
@@ -0,0 +1,67 @@
{{--
Contract: $heading, $text, $photo, $rooms (see ostsee-licht/views/sections/floor_plan.blade.php).
theme.js (initFloorPlans) shows one room at a time; without JavaScript all rooms are listed and the areas jump to them.
--}}
@if ($photo && $rooms->isNotEmpty())
<section class="mx-auto max-w-7xl px-4 py-16 sm:px-8 sm:py-20" aria-labelledby="{{ $sectionId }}-title" data-floor-plan>
<div class="flex flex-wrap items-end justify-between gap-x-12 gap-y-3">
<h2 id="{{ $sectionId }}-title" class="heading-display">{{ $heading }}</h2>
@if ($text)<p class="max-w-[44ch] text-muted">{{ $text }}</p>@endif
</div>
<div class="mt-10 flex flex-wrap items-start gap-10">
<div class="min-w-0 flex-[999_1_38rem]">
<div class="border-2 border-ink bg-surface p-2 sm:p-4">
<div class="relative">
@include('theme::partials.image', ['photo' => $photo, 'sizes' => '(min-width: 1024px) 60vw, 100vw', 'class' => 'h-auto w-full'])
<svg viewBox="0 0 100 100" preserveAspectRatio="none" class="absolute inset-0 size-full" role="group" aria-label="Räume im Grundriss">
@foreach ($rooms as $room)
<a href="#{{ $room['key'] }}" data-floor-room-link="{{ $room['key'] }}" aria-label="{{ $room['name'] }}" class="group">
<polygon points="{{ $room['points'] }}" vector-effect="non-scaling-stroke"
class="fill-accent/0 stroke-accent/50 [stroke-width:2] transition group-hover:fill-accent/15 group-focus-visible:fill-accent/20 group-data-[active]:fill-accent/25 group-data-[active]:stroke-accent group-data-[active]:[stroke-width:3]"><title>{{ $room['name'] }}</title></polygon>
</a>
@endforeach
</svg>
</div>
</div>
<nav aria-label="Raum wählen" class="mt-5">
<ul class="flex flex-wrap gap-2.5">
@foreach ($rooms as $room)
<li><a href="#{{ $room['key'] }}" data-floor-room-link="{{ $room['key'] }}"
class="inline-flex min-h-12 items-center rounded-full border-2 border-ink bg-surface px-5 font-semibold hover:bg-ink/5 data-[active]:bg-ink data-[active]:text-ground">{{ $room['name'] }}</a></li>
@endforeach
</ul>
</nav>
</div>
<div class="min-w-0 flex-[1_1_22rem] space-y-12">
@foreach ($rooms as $room)
<article id="{{ $room['key'] }}" data-floor-room class="cartouche scroll-mt-28 px-6 pt-10 pb-7 sm:px-7" aria-labelledby="{{ $room['key'] }}-name">
<span class="absolute -top-0.5 -left-0.5" aria-hidden="true">@include('theme::partials.motif', ['slot' => 'bracket', 'class' => 'size-9'])</span>
<span class="absolute -top-0.5 -right-0.5 -scale-x-100" aria-hidden="true">@include('theme::partials.motif', ['slot' => 'bracket', 'class' => 'size-9'])</span>
@if ($room['photos']->isNotEmpty())
@include('theme::partials.image', ['photo' => $room['photos']->first(), 'sizes' => '(min-width: 1024px) 26rem, 100vw', 'class' => 'mb-5 h-56 w-full rounded object-cover'])
@endif
<h3 id="{{ $room['key'] }}-name" class="font-display text-[2rem] leading-tight">{{ $room['name'] }}</h3>
@if ($room['description'])<p class="mt-2 text-muted">{{ $room['description'] }}</p>@endif
@if ($room['amenities']->isNotEmpty())
<ul class="mt-4 space-y-1.5">
@foreach ($room['amenities'] as $amenity)
<li class="flex gap-3"><x-heroicon-o-check class="mt-1 size-5 shrink-0 text-accent" aria-hidden="true" />{{ $amenity }}</li>
@endforeach
</ul>
@endif
@if ($room['hint'])<p class="mt-5 border-l-[3px] border-accent bg-ground px-4 py-3">{{ $room['hint'] }}</p>@endif
@if ($room['photos']->count() > 1)
<ul class="mt-5 grid grid-cols-3 gap-2">
@foreach ($room['photos']->skip(1) as $more)
<li><a href="{{ $more->url('lg') }}" data-lightbox data-alt="{{ $more->alt_text }}" class="block overflow-hidden rounded">@include('theme::partials.image', ['photo' => $more, 'sizes' => '8rem', 'class' => 'h-20 w-full object-cover'])</a></li>
@endforeach
</ul>
@endif
</article>
@endforeach
</div>
</div>
</section>
@endif
Loaded 100 of 124 files, more files were not shown because too many files have changed in this diff. Show more