Compare commits

...
Author SHA1 Message Date
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
LarsandClaude Opus 5.5 04b5189bd8 Floor plan: rendering (source + WebP 900/1712) and room areas in image coordinates
Seven rooms incl. entrance; the areas use the image's own coordinate system (viewBox 0 0 1712 919),
so an SVG overlay scales exactly with the image. A traced vector version was tested and rejected
(2.7 MB, posterised).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 15:11:17 +02:00
LarsandClaude Opus 5.5 9b8a851ce9 Floor plan in a light 3D view (cutaway): SVG, generator and projected room areas
Generated from the plan coordinates of the scanned floor plan (photo 20); the JSON holds the room
polygons in the same projection for the interactive section. Draft for the planned section
'Interaktiver Grundriss' (STATUS §6).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 12:52:06 +02:00
Lars b3114cdfe3 Merge remote-tracking branch 'origin/main' into theme/seebad
Deploy / test (push) Failing after 2s
Deploy / deploy (push) Skipped
2026-10-23 12:33:33 +02:00
LarsandCursor faf2133232 Record that the staging admin works after the tenancy deploy.
Deploy / test (push) Failing after 3s
Deploy / deploy (push) Skipped
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-23 12:33:26 +02:00
LarsandClaude Opus 5.5 d2f53ceb84 Theme Seebad 0.4.0: menu panels; fix missing chevron icons; render test for all themes
- Menu panels: arrow next to each main menu item opens a panel with the page description (SEO text),
  jump links to the headed sections and a cartouche with booking and phone; Escape/outside click closes,
  focus returns; without JavaScript the menu stays plain links
- Header: booking button hidden between 1280 and 1535 px (too narrow with the arrows), desktop phone removed
- Fix: offers carousel and menu used outline chevron icons that do not exist (500 as soon as offers are shown);
  now mini chevrons
- New test: every installed theme renders all pages with reviews and offers in every display mode
- Wish: menu photo per page (ZUSAMMENARBEIT §5)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 12:33:11 +02:00
LarsandCursor ab1dffc72f Record the tenancy handoff so the next session can start at phase 3.
Deploy / test (push) Failing after 3s
Deploy / deploy (push) Skipped
STATUS section 7 names the deployed release, the pieces that are built, and what must stay untouched.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-23 12:26:29 +02:00
LarsandCursor fc61369c4a Record that stommer.info now runs as the Stommer landlord.
Deploy / test (push) Failing after 3s
Deploy / deploy (push) Skipped
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-23 12:05:57 +02:00
62 changed files with 2587 additions and 152 deletions

No files matched your search

+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`.
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace App\Enums;
/**
* Services the operator can switch on per landlord. The AI services have no function behind them yet.
*/
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',
self::AiOffers => 'KI: Angebote',
self::AiMarketing => 'KI: Marketing',
self::AiGuestMail => 'KI: Gästepost',
};
}
}
@@ -0,0 +1,100 @@
<?php
namespace App\Filament\Operator\Concerns;
use App\Enums\TenantServiceKey;
use App\Models\Tenant;
use App\Models\TenantService;
/**
* 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.
*/
trait EditsTenantServices
{
/**
* @param array<string, mixed> $data
* @return array<string, mixed>
*/
protected function mutateFormDataBeforeFill(array $data): array
{
$tenant = $this->record;
if (! $tenant instanceof Tenant) {
return $data; // creating: there is nothing to read yet
}
$data['services'] = $tenant->services
->mapWithKeys(fn (TenantService $service): array => [$service->service => [
'is_enabled' => $service->is_enabled,
'api_key' => $service->api_key,
]])
->all();
return $data;
}
/**
* @param array<string, mixed> $data
* @return array<string, mixed>
*/
protected function mutateFormDataBeforeCreate(array $data): array
{
return $this->withoutServices($data);
}
/**
* @param array<string, mixed> $data
* @return array<string, mixed>
*/
protected function mutateFormDataBeforeSave(array $data): array
{
return $this->withoutServices($data);
}
protected function afterCreate(): void
{
$this->saveServices();
}
protected function afterSave(): void
{
$this->saveServices();
}
/**
* @param array<string, mixed> $data
* @return array<string, mixed>
*/
private function withoutServices(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::cases() as $service) {
$state = $this->services[$service->value] ?? [];
$tenant->services()->updateOrCreate(
['service' => $service->value],
[
'is_enabled' => (bool) ($state['is_enabled'] ?? false),
'api_key' => filled($state['api_key'] ?? null) ? $state['api_key'] : null,
],
);
}
$tenant->unsetRelation('services');
}
}
+17
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;
@@ -13,6 +14,8 @@
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Resources\Resource;
use Filament\Schemas\Components\Fieldset;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Columns\TextColumn;
@@ -51,6 +54,19 @@ public static function form(Schema $schema): Schema
->label('Aktiv')
->helperText('Ein gesperrter Mandant ist von außen nicht mehr erreichbar. Der Betreiber kommt weiter hinein.')
->default(true),
Section::make('Dienste')
->description('Welche Dienste dieser Mandant nutzen darf. Ein eigener Schlüssel ist freiwillig; bleibt er leer, gilt später der Schlüssel des Betreibers.')
->columnSpanFull()
->schema(array_map(fn (TenantServiceKey $service): Fieldset => Fieldset::make($service->label())
->columns(2)
->schema([
Toggle::make('services.'.$service->value.'.is_enabled')->label('Freigeschaltet'),
TextInput::make('services.'.$service->value.'.api_key')
->label('Eigener API-Schlüssel')
->password()
->revealable()
->maxLength(255),
]), TenantServiceKey::cases())),
]);
}
@@ -60,6 +76,7 @@ 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')->counts(['services' => fn ($query) => $query->where('is_enabled', true)]),
ToggleColumn::make('is_active')->label('Aktiv'),
])
->recordActions([
@@ -2,10 +2,16 @@
namespace App\Filament\Operator\Tenants\Pages;
use App\Filament\Operator\Concerns\EditsTenantServices;
use App\Filament\Operator\TenantResource;
use Filament\Resources\Pages\CreateRecord;
class CreateTenant extends CreateRecord
{
use EditsTenantServices;
protected static string $resource = TenantResource::class;
/** @var array<string, array<string, mixed>> */
public array $services = [];
}
@@ -2,10 +2,16 @@
namespace App\Filament\Operator\Tenants\Pages;
use App\Filament\Operator\Concerns\EditsTenantServices;
use App\Filament\Operator\TenantResource;
use Filament\Resources\Pages\EditRecord;
class EditTenant extends EditRecord
{
use EditsTenantServices;
protected static string $resource = TenantResource::class;
/** @var array<string, array<string, mixed>> */
public array $services = [];
}
+147 -18
View File
@@ -4,7 +4,9 @@
use App\Enums\UserRole;
use App\Filament\Concerns\FollowsAdminMode;
use App\Models\Tenant;
use App\Support\Settings;
use App\Tenancy\TenantConfig;
use BackedEnum;
use Filament\Actions\Action;
use Filament\Forms\Components\Radio;
@@ -23,13 +25,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 +62,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 +72,25 @@ 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,
...$this->periodValues($tenant),
]);
}
@@ -117,6 +149,34 @@ 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('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 +193,89 @@ 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,
...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)
+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']);
}
+9
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.
@@ -115,6 +116,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 {}
+50 -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,17 @@
* 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',
'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 +38,7 @@ public static function stommer(): self
{
return static::query()->firstOrCreate(
['slug' => 'stommer'],
['name' => 'Stommer'],
['name' => 'Stommer'] + TenantDefaults::forLegacyLandlord(encryptBank: false),
);
}
@@ -37,6 +49,11 @@ protected function casts(): array
{
return [
'is_active' => 'boolean',
'bank_account_holder' => 'encrypted',
'bank_iban' => 'encrypted',
'bank_bic' => 'encrypted',
'bank_name' => 'encrypted',
'tax_note' => 'encrypted',
];
}
@@ -56,6 +73,37 @@ 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);
}
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;
}
}
+10 -4
View File
@@ -2,13 +2,14 @@
namespace App\Providers;
use App\Support\Settings;
use App\Support\StripImageMetadata;
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 +19,7 @@ class AppServiceProvider extends ServiceProvider
public function register(): void
{
$this->app->singleton(TenantContext::class);
$this->app->singleton(TenantConfig::class);
}
/**
@@ -25,9 +27,13 @@ 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();
// Operating data of the landlord (addresses, periods) and test mode (every e-mail goes to the test
// recipient only, until switched live). Console and boot know the landlord only if there is exactly one.
try {
$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));
+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();
}
}
+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();
}
}
+64
View File
@@ -0,0 +1,64 @@
<?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 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;
}
private static function bank(mixed $value, bool $encrypt): ?string
{
if (blank($value)) {
return null;
}
return $encrypt ? Crypt::encryptString((string) $value) : (string) $value;
}
}
+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(),
]),
];
}
}
+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();
});
}
};
+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` |
+13 -11
View File
@@ -1,10 +1,10 @@
# Mandantenfähigkeit – Umbauplan
Stand: 23.10.2026 · freigegeben, Phase 1 und 2 im Code auf `feature/mandanten`, Datenbank noch nicht migriert · Anforderungen: [MANDANTEN-ANFORDERUNGEN.md](MANDANTEN-ANFORDERUNGEN.md) · Design: [DESIGN-KONZEPT.md](DESIGN-KONZEPT.md) §7
Stand: 23.10.2026, abends · Phase 1, 2, 3 und der Website-Teil von Phase 4 sind auf `main` und auf stommer.info (Release `20261023195835`) · 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.
Die Umsetzung läuft auf dem Branch `feature/mandanten`. Phasen 1–5 sind der Grundumbau. Marke/Bildwelt (Phase 6) und mehrere Wohnungen je Website (Phase 7) folgen in der festgelegten Reihenfolge und starten erst, wenn die Theme-Sitzung die Vertragsänderung aus [ZUSAMMENARBEIT.md](ZUSAMMENARBEIT.md) §6 übernehmen kann. `resources/themes/**` bleibt bis dahin unangetastet.
Weiterarbeiten auf einem neuen Branch ab `main`. `feature/mandanten` ist zusammengeführt. Phasen 1–5 sind der Grundumbau. Marke/Bildwelt (Phase 6) und mehrere Wohnungen je Website (Phase 7) folgen in der festgelegten Reihenfolge und starten erst, wenn die Theme-Sitzung die Vertragsänderung aus [ZUSAMMENARBEIT.md](ZUSAMMENARBEIT.md) §6 übernehmen kann. `resources/themes/**` bleibt bis dahin unangetastet.
---
@@ -177,7 +177,7 @@ ## 6. Rollen, Admin, Betreiber
| Inhalte | bisher `content` | Bilder, Texte, FAQ, Hinweise, Bewertungen |
| Betreiber | `users.is_operator`, **keine** Mitgliedsrolle | Mandanten anlegen und sperren, ersten Mandanten-Administrator anlegen, Dienste, Domains, Systemzustand, Wechsel in einen Mandanten |
Der Admin nutzt Filaments Mandantenfunktion mit `tenantDomain('{tenant}')` und `resolveTenantUsing`: der Host ist der Schlüssel, die Website mit diesem Host liefert den Mandanten. `User` erfüllt `HasTenants`. `canAccessTenant` ist wahr bei einer Mitgliedschaft oder beim Betreiber.
Filaments `Panel::tenant()` / `tenantDomain()` ist **nicht** eingeschaltet. Der Pfad bleibt `/admin`, ohne zusätzliche Stufe. Der Mandant kommt aus `App\Tenancy\TenantContext` (Singleton), gesetzt von `ResolveTheme`. Ein eingeschaltetes `tenantDomain` würde `BookingResource::getUrl()` und die bestehenden Admin-Tests ändern. Details und die übrigen Bausteine: STATUS.md Abschnitt 7.
Der Betreiber-Bereich ist ein zweites Panel ohne Mandantenfilter, Pfad `/betreiber`, nur für `is_operator`. Dort entstehen Mandanten und der erste Administrator. „In den Mandanten wechseln“ öffnet `https://<host>/admin` und schreibt einen Eintrag (Benutzer, Mandant, Zeitpunkt). Im Mandanten-Admin gilt derselbe Filter wie für jeden anderen; der Betreiber sieht dort nur diesen Mandanten. Hat er dort keine Mitgliedschaft, gelten für den Support die Rechte des Mandanten-Administrators, und der Zugriff bleibt protokolliert.
@@ -205,7 +205,7 @@ ## 7. Domain, Cron, Mails
## 8. Phasen
Jede Phase liegt auf `feature/mandanten`, hat grüne Tests (`php artisan test --compact` auf die betroffenen Dateien, am Ende der Phase die ganze Suite) und ist für sich nach `main` zusammenführbar. Ausgeliefert wird nur aus `main`. `resources/themes/**` wird nicht geändert. Nach dem Zusammenführen schreibt die Sitzung `docs/STATUS.md`. Eine Änderung am Vorlagen-Vertrag gibt es in Phase 1–5 nicht; §6 von ZUSAMMENARBEIT bleibt deshalb in diesen Phasen leer.
Abgeschlossene Phasen liegen auf `main`. Die nächste Phase bekommt einen eigenen Branch ab `main`, grüne Tests (`php artisan test --compact --testsuite=Feature` auf die betroffenen Dateien, am Ende der Phase die Feature-Suite) und ist für sich nach `main` zusammenführbar. `php artisan test` ohne `--testsuite=Feature` bricht ab, weil `tests/Unit` nicht existiert. Ausgeliefert wird nur aus `main`. `resources/themes/**` wird nicht geändert. Nach dem Zusammenführen schreibt die Sitzung `docs/STATUS.md`. Eine Änderung am Vorlagen-Vertrag gibt es in Phase 1–5 nicht; §6 von ZUSAMMENARBEIT bleibt deshalb in diesen Phasen leer.
### Phase 1 – Mandant und Daten
@@ -228,16 +228,18 @@ ### 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 (Dienste am Mandanten-Formular; `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.
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
@@ -288,6 +290,6 @@ ## 9. Betrieb und Abgrenzung
## 10. Freigabe
Phase 1 und 2 sowie der Website-Teil von Phase 4 sind im Code, zusammen mit Seebad 0.3. Die Datenbank auf stommer.info ist noch nicht migriert: Auslieferung aus `main` (das Skript migriert), danach `users:promote-operator` für das eigene Konto. Phase 3 bis 5 folgen und bringen weitere Migrationen. Phase 6 und 7 warten auf eine eigene Freigabe.
Phase 1, 2 und 3 sowie der Website-Teil von Phase 4 sind auf stommer.info (Release `20261023195835`). Die bisherigen Daten gehören zum Mandanten Stommer, `lars@stommer.com` ist Betreiber. Die nächste Codesitzung ist der Rest von Phase 4; Übergabe mit den gebauten Bausteinen: [STATUS.md](STATUS.md) Abschnitt 7. Phase 4 und 5 bringen weitere Migrationen. Phase 6 und 7 warten auf eine eigene Freigabe.
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.
+73 -7
View File
@@ -1,6 +1,6 @@
# Projektstand
Stand: 23.10.2026 · ausgelieferter Stand: siehe neuester Git-Tag `deploy/staging/*` · 217 Feature-Tests grün auf `feature/mandanten`
Stand: 23.10.2026 · ausgelieferter Stand: `deploy/staging/20261023195835` · 235 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“).
@@ -24,7 +24,7 @@ ## 1. Fertig (umgesetzt, getestet, auf stommer.info)
- **Bewertungen:** Einladung per E-Mail, Freigabe im Admin, Anzeige mit Pflichthinweis zur Echtheit.
**Verwaltung (Admin)**
- **Rollen:** Mandanten-Administrator, Vermietung, Inhalte. Auf `feature/mandanten` gilt die Rolle je Mandant; der ausgelieferte Stand hat noch die eine Rolle je Konto.
- **Rollen:** Mandanten-Administrator, Vermietung, Inhalte. Auf stommer.info gilt die Rolle je Mandant. `lars@stommer.com` ist Betreiber und bleibt Mandanten-Administrator.
- **Ansichten:** Die **einfache Ansicht** zeigt Anfragen & Buchungen, Sperrzeiten, **Preise & Angebote**, Gäste, Portal-Aufgaben, Bewertungen und Bilder. Die **Expertenansicht** zeigt alles. Umschalten im Benutzermenü.
- **Sicherheit:** 2FA ist für **alle** Konten Pflicht; Administratoren können die 2FA eines anderen Kontos zurücksetzen und Passwörter neu vergeben.
@@ -52,7 +52,7 @@ ## 2. Stand auf stommer.info (Testbetrieb)
| | |
|---|---|
| Konten | `lars@stommer.com` (Administrator); Konto für Brigitte noch anzulegen (Administrator, **einfache Ansicht**) |
| Konten | `lars@stommer.com` ist Betreiber und Mandanten-Administrator von Stommer (Passwort und 2FA unverändert). Admin unter https://stommer.info/admin am 23.10.2026 geprüft und funktionsfähig. Konto für Brigitte noch anzulegen (Mandanten-Administrator, **einfache Ansicht**) |
| Daten | Wohnung, Preise 2026, 39 Fotos, Seiten, 5 Erscheinungsbilder; **Testbuchung 2026-0002** („E2E Testgast“, angenommenes Angebot) – darf gelöscht werden |
| E-Mail | Betriebsart **Testbetrieb** (System › Betrieb), Testadresse `lars@stommer.com` – alle Mails gingen nur dorthin. Versandweg aber noch `log` (nichts wird zugestellt): `MAIL_MAILER=smtp` + `MAIL_PASSWORD` (Postfach **info@fewo-stommer.de** = Absender) in `shared/.env` selbst eintragen, dann `artisan mail:test` (BETRIEB.md §5a) |
| Cronjob | **noch nicht eingerichtet** – ohne ihn laufen Fristabläufe, Erinnerungen, Kalenderabgleich, Backups nicht automatisch (BETRIEB.md §6) |
@@ -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 liegen auf `feature/mandanten`, zusammen mit Seebad 0.3 (Mandant, Mitgliedschaften, `/betreiber`, Host je Website, Gäste-Links). Cron, Postfach und Absender je Mandant fehlen noch; mit genau einem Mandanten bleibt der bisherige Betrieb. Die Datenbank auf stommer.info ist noch nicht migriert. Plan: `docs/MANDANTEN-PLAN.md`.
- Mandantenfähigkeit: Phase 1, 2, 3 und der Website-Teil von Phase 4 sind auf stommer.info. **Nächste Codesitzung: Rest von Phase 4.** 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:
@@ -88,7 +88,7 @@ ## 4. Nächste Schritte (Vorschlag)
1. Cronjob einrichten; SMTP einschalten und mit `mail:test` prüfen (Mails landen wegen Testbetrieb nur bei Lars); Konto für Brigitte anlegen.
1a. Vor dem Go-Live: System › Betrieb auf „scharf geschaltet“ stellen – erst dann erhalten Gäste die Mails. Beim Go-Live außerdem unter System › Betrieb › Adressen Kontakt-/Antwortadresse und Benachrichtigungen von fewo@stommer.de auf **info@fewo-stommer.de** umstellen (Entscheidung 23.10.2026; Absender ist bereits info@fewo-stommer.de).
2. Brigitte probt Anfrage → Angebot → Annahme mit einem eigenen Test (Angebotslink über die Aktion „Angebotslink“).
3. Testinstanz stommer.info auf den Mandanten heben: aus `main` ausliefern (Migration läuft dabei), danach `users:promote-operator` für `lars@stommer.com`. Vor einem zweiten Mandanten den Host `stommer.info` an der Website eintragen.
3. Vor einem zweiten Mandanten den Host `stommer.info` unter Webseite › Website eintragen. Sonst antwortet diese Adresse ab dann nicht mehr.
4. Rechtstexte und Bedingungen einpflegen, Produktion einrichten, Umzug von WordPress.
## 5. Schnellreferenz Code
@@ -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 | – |
@@ -129,5 +131,69 @@ ## 6. Design-Theme „Seebad“ (Abschnitt der Design-Session)
| Video (selbst gehostet) | Video + Standbild je Baustein | stumm, Poster, nicht bei „Datensparen“ | Speicherplatz Strato |
| Wetter / Wassertemperatur | externe Quelle (Lizenz klären, z. B. DWD Open Data), serverseitig abgerufen und zwischengespeichert | kleine Anzeige | Lizenzfrage |
Bauort: Jeder Baustein ist **Anwendung + Theme**: Klasse in `app/Themes/Sections` (Admin-Formular, Datenaufbereitung) + ggf. Modell/Migration/Filament-Ressource (`FollowsAdminMode`) + Eintrag in `config/themes.php` + Pflicht-Vorlage im Basis-Theme `ostsee-licht` (Test erzwingt das) + eigene Vorlage in `seebad`. Interaktion nur als kleine Verbesserung in `theme.js` (ohne Framework) bzw. Livewire, wenn der Server rechnen muss. Gebaut auf eigenem Branch `feature/bausteine` **nach Phase 1 des Mandanten-Umbaus**, damit neue Tabellen gleich mandantenfähig angelegt werden (vorher: nur Konzept und Admin-Entwürfe). Reihenfolge-Vorschlag: Gut zu wissen → Tipps der Gastgeberin → Grundriss → Kalender → Erzählstrecke/Video → Wetter.
Bauort: Jeder Baustein ist **Anwendung + Theme**: Klasse in `app/Themes/Sections` (Admin-Formular, Datenaufbereitung) + ggf. Modell/Migration/Filament-Ressource (`FollowsAdminMode`) + Eintrag in `config/themes.php` + Pflicht-Vorlage im Basis-Theme `ostsee-licht` (Test erzwingt das) + eigene Vorlage in `seebad`. Interaktion nur als kleine Verbesserung in `theme.js` (ohne Framework) bzw. Livewire, wenn der Server rechnen muss. Gebaut auf eigenem Branch `feature/bausteine`. Phase 1 des Mandanten-Umbaus ist auf `main`; neue Tabellen bekommen `tenant_id` von Anfang an. Vor der ersten geänderten Theme-Datei steht der Eintrag in ZUSAMMENARBEIT.md §6. Reihenfolge-Vorschlag: Gut zu wissen → Tipps der Gastgeberin → Grundriss → Kalender → Erzählstrecke/Video → Wetter.
## 7. Mandanten – Übergabe an die nächste Sitzung
Stand: 23.10.2026, abends · Branch `main` · Plan: [MANDANTEN-PLAN.md](MANDANTEN-PLAN.md) · Anforderungen: [MANDANTEN-ANFORDERUNGEN.md](MANDANTEN-ANFORDERUNGEN.md)
**Hier weitermachen: der Rest von Phase 4** (Scheduler-Schleife über die Mandanten, Portal-Postfach je Mandant, Absender je Versand, iCal-Token). Danach 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.
**Phase 3 ist ausgeliefert** (Release `20261023195835`, 23.10.2026 abends). Die zwei Migrationen sind auf der MariaDB von stommer.info durch, `settings` ist weg, die Werte stehen am Mandanten Stommer.
### Ausgeliefert
| | |
|---|---|
| Server | nur **stommer.info** (Staging). `www.fewo-stommer.de` ist unberührt und bleibt WordPress. |
| Release | `20261023195835`, Git-Tag `deploy/staging/20261023195835`, Commit `f143a4f` (Phase 3) |
| Code danach | Commits auf `main` nach `f143a4f` 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\20261023-215553` (Datenbank-Dump mit noch vorhandener `settings`-Tabelle und Dateien, 29 MB; 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 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. |
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.
- `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.
- `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.
### So ist es gebaut
| Baustein | Verhalten |
|---|---|
| `App\Tenancy\TenantContext` | Singleton in `AppServiceProvider::register`. Ohne Singleton sieht der globale Scope den Mandanten nicht. Gesetzter Kontext filtert. Leerer Kontext bei einer Abfrage, die einen Mandanten verlangt, wirft `TenantContextMissing`. Konsole, Boot und Tests ohne Kontext bleiben ungefiltert. |
| `BelongsToTenant` | Globaler Scope `tenant`. Beim Anlegen gilt: Mandant der Elternzeile (`property_id`, `booking_id`, `channel_id`, `site_id`, `guest_id`), sonst gesetzte `tenant_id`, sonst der Kontext, sonst in Tests ein Mandant „Testmandant“. `User`, `Setting` und `Tenant` gehören nicht dazu. |
| `ResolveTheme` | Liegt in der Web-Gruppe **und** in beiden Filament-Panels, dort nach `StartSession`. Panel-Routen erben die Web-Gruppe nicht. Inaktiver Mandant: 404, außer Pfad `betreiber` oder angemeldeter Betreiber. |
| Host | `ThemeFactory::siteForRequest`. Zuerst `site_domains.host`, dann `sites.domain`, beides klein geschrieben. Ein Mandant: Standard-Website auf jeder Adresse. Zwei Mandanten: nur der eingetragene Host, sonst 404. Die Konsole (`site()`) antwortet nicht mit 404. |
| `sites.domain` | Bleibt das Admin-Feld. `Site::saved` schreibt den Host nach `site_domains` und entfernt den vorherigen Host dieser Website. Leere Domain: keine Host-Zeile. |
| Gäste-Links | `Site::withOrigin` setzt `URL::forceRootUrl` **und** `URL::forceScheme` (das Schema würde sonst das der laufenden Anfrage). Genutzt für Angebot, Annahme, Ablehnung, Bewertung, Werbe-Einwilligung. Ohne Host gilt `APP_URL`. `URL::forceRootUrl(APP_URL)` außerhalb von local/testing bleibt der Schutz vor dem Strato-Pfad `/releases/…/public` und wird nicht zur Mandantenerkennung. |
| Nummern und Gäste | Buchungsnummer je Mandant und Jahr, eindeutig `(tenant_id, reference)`, weitergezählt ab der höchsten `YYYY-####`. Dieselbe E-Mail bei zwei Mandanten ergibt zwei Gäste. E-Mail ist nicht eindeutig. Index `(tenant_id, email)`. |
| 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}`. |
| `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. |
| 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`, `TenantSettingsTest.php`, `OperationsModeTest.php`. Zuletzt 235 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
- 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.
- 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) |
+2
View File
@@ -76,6 +76,7 @@ ## 5. Wünsche der Design-Session an die Anwendung
| 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 | 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 |
## 6. Änderungsprotokoll Vorlagen-Vertrag
@@ -87,4 +88,5 @@ ## 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 |
| 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,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
+1 -1
View File
@@ -30,7 +30,7 @@ ## Eigene Vorlagen
| Datei | Zweck |
|---|---|
| `layouts/app` | Grundgerüst (größere Grundschrift, Lightbox mit großer Schließen-Fläche) |
| `partials/header` | Logo-Bildmarke, Menü, Telefon (ab 1536 px), „Verfügbarkeit prüfen“; Handy-Menü als dunkle Tafel mit großen Links, Anruf-Taste und Seebrücken-Band |
| `partials/header` | Logo-Bildmarke, Menü mit **Menü-Tafeln** (Pfeil neben dem Menüpunkt: Seitenbeschreibung aus dem SEO-Text, Sprunglinks zu den Abschnitten mit Überschrift, Kartusche mit Buchung und Telefon; Escape/Klick daneben schließt; ohne JS normale Links), „Verfügbarkeit prüfen“ (bis 1279 px und ab 1536 px – dazwischen zu eng, Buchung dann im Titelbereich und in den Tafeln); Handy-Menü als dunkle Tafel mit großen Links, Anruf-Taste und Seebrücken-Band |
| `partials/footer` | Seebrücken-Band, Bildmarke, Kontakt, Rechtliches |
| `partials/banner` | Hinweis-Banner mit Möwen |
| `partials/mobile-booking-bar` | „Verfügbarkeit prüfen“ und Anruf-Taste |
+91
View File
@@ -6,3 +6,94 @@ import '../ostsee-licht/theme.js';
// Logo, favicon (resources/themes/seebad/img) – addressed in Blade via Vite::asset().
import.meta.glob(['./img/**'], { eager: true, query: '?url' });
/**
* Menu panels (partials/header): the arrow next to a menu item opens a panel with jump links into the page.
* Without JavaScript the arrows stay hidden and the menu items are plain links.
*/
function initMenuPanels() {
const header = document.querySelector('[data-menu]');
const toggles = [...document.querySelectorAll('[data-menu-toggle]')];
if (!header || toggles.length === 0) {
return;
}
const panelOf = (toggle) => document.getElementById(toggle.getAttribute('aria-controls'));
const close = (toggle) => {
toggle.setAttribute('aria-expanded', 'false');
panelOf(toggle).hidden = true;
};
toggles.forEach((toggle) => {
toggle.hidden = false;
toggle.addEventListener('click', () => {
const open = toggle.getAttribute('aria-expanded') === 'true';
toggles.filter((other) => other !== toggle).forEach(close);
toggle.setAttribute('aria-expanded', String(!open));
panelOf(toggle).hidden = open;
});
});
document.addEventListener('keydown', (event) => {
const open = toggles.find((toggle) => toggle.getAttribute('aria-expanded') === 'true');
if (event.key === 'Escape' && open) {
close(open);
open.focus();
}
});
document.addEventListener('click', (event) => {
if (!header.contains(event.target)) {
toggles.forEach(close);
}
});
window.matchMedia('(min-width: 80rem)').addEventListener('change', () => toggles.forEach(close));
}
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();
+1 -1
View File
@@ -1,7 +1,7 @@
{
"key": "seebad",
"name": "Seebad",
"version": "0.3.0",
"version": "0.4.0",
"parent": "ostsee-licht",
"description": "Ruhiges Magazin für Paare: Logo und Bäderstil-Details des Hauses (Rundbogengaube, Balkongeländer, Kopfbänder), große gut lesbare Schrift",
"assets": {
@@ -1,5 +1,23 @@
@php($phone = (string) config('fewo.owner.phone'))
<header class="relative z-20">
@php
$phone = (string) config('fewo.owner.phone');
// Menu panels: jump links to the headed sections of each page (sections limited to appearances are left out).
$menuEntries = $theme->menu('main')->values()->map(fn ($page, $position) => [
'page' => $page,
'panel' => 'menu-panel-'.$position,
'anchors' => collect($page->sections ?? [])
->map(fn ($section, $index) => [
'label' => $section['data']['heading'] ?? null,
'id' => ($section['type'] ?? '').'-'.$index.'-title',
'type' => $section['type'] ?? '',
'limited' => ! empty($section['data']['appearances'] ?? []),
])
->filter(fn ($anchor) => filled($anchor['label']) && ! $anchor['limited']
&& ! in_array($anchor['type'], ['hero', 'booking', 'contact', 'rich_text', 'offers', 'reviews'], true))
->take(6)
->values(),
]);
@endphp
<header class="relative z-20" data-menu>
<div class="mx-auto flex max-w-7xl items-center justify-between gap-6 px-4 py-4 sm:px-8 lg:py-5">
<a href="{{ route('home') }}" class="flex min-w-0 items-center gap-3 sm:shrink-0" aria-label="{{ $theme->site->name }} – Startseite">
@include('theme::partials.logo', ['class' => 'h-12 w-auto shrink-0 lg:h-16', 'sizes' => '(min-width: 1024px) 9.5rem, 7rem'])
@@ -7,20 +25,24 @@
</a>
<nav aria-label="Hauptnavigation" class="hidden xl:block">
<ul class="flex gap-6 text-lg whitespace-nowrap xl:gap-7">
@foreach ($theme->menu('main') as $item)
<li><a href="{{ $item->url() }}" @class(['underline-offset-8 hover:underline', 'underline decoration-accent decoration-2' => url()->current() === $item->url()]) @if (url()->current() === $item->url()) aria-current="page" @endif>{{ $item->label() }}</a></li>
<ul class="flex gap-4 text-lg whitespace-nowrap 2xl:gap-6">
@foreach ($menuEntries as $entry)
@php($item = $entry['page'])
<li class="flex items-center gap-0.5">
<a href="{{ $item->url() }}" @class(['underline-offset-8 hover:underline', 'underline decoration-accent decoration-2' => url()->current() === $item->url()]) @if (url()->current() === $item->url()) aria-current="page" @endif>{{ $item->label() }}</a>
@if ($entry['anchors']->isNotEmpty())
<button type="button" data-menu-toggle aria-controls="{{ $entry['panel'] }}" aria-expanded="false" aria-label="Übersicht „{{ $item->label() }}“" hidden
class="flex size-9 items-center justify-center rounded-md hover:bg-ink/5 aria-expanded:bg-ink/5 aria-expanded:[&_svg]:rotate-180">
<x-heroicon-m-chevron-down class="size-5 transition" aria-hidden="true" />
</button>
@endif
</li>
@endforeach
</ul>
</nav>
<div class="flex items-center gap-2 sm:gap-4">
@if ($phone)
<a href="tel:{{ preg_replace('/[^0-9+]/', '', $phone) }}" class="hidden items-center gap-2 font-semibold whitespace-nowrap hover:text-accent 2xl:flex">
<x-heroicon-o-phone class="size-5" aria-hidden="true" />{{ $phone }}
</a>
@endif
<a href="{{ route('booking.create') }}" class="btn-accent hidden whitespace-nowrap sm:inline-flex">Verfügbarkeit prüfen</a>
<a href="{{ route('booking.create') }}" class="btn-accent hidden whitespace-nowrap sm:inline-flex xl:hidden 2xl:inline-flex">Verfügbarkeit prüfen</a>
<details class="group xl:hidden">
<summary class="flex size-12 cursor-pointer list-none items-center justify-center rounded-md border border-line bg-surface [&::-webkit-details-marker]:hidden" aria-label="Menü">
@@ -48,4 +70,35 @@
</details>
</div>
</div>
@foreach ($menuEntries->filter(fn ($entry) => $entry['anchors']->isNotEmpty()) as $entry)
@php($item = $entry['page'])
<div id="{{ $entry['panel'] }}" data-menu-panel hidden class="absolute inset-x-0 top-full border-y border-line bg-surface shadow-lg shadow-ink/10">
<div class="mx-auto grid max-w-7xl grid-cols-[1.15fr_1fr_0.9fr] items-start gap-12 px-8 pt-10 pb-12">
<div>
<p class="font-display text-[2.25rem] leading-tight">{{ $item->label() }}</p>
@if ($item->seo_description)<p class="mt-3 max-w-[42ch] text-muted">{{ $item->seo_description }}</p>@endif
<a href="{{ $item->url() }}" class="mt-5 inline-block border-b-2 border-accent pb-0.5 font-semibold hover:text-accent">Zur Seite „{{ $item->label() }}“</a>
</div>
<nav aria-label="Auf der Seite „{{ $item->label() }}“">
<p class="eyebrow">Auf dieser Seite</p>
<ul class="divide-y divide-line border-y border-line">
@foreach ($entry['anchors'] as $anchor)
<li><a href="{{ $item->url() }}#{{ $anchor['id'] }}" class="block py-2.5 text-lg hover:text-accent">{{ $anchor['label'] }}</a></li>
@endforeach
</ul>
</nav>
<div class="cartouche mt-6 px-6 pt-12 pb-7 text-center">
<span class="absolute -top-8 left-1/2 -translate-x-1/2 bg-surface px-2" aria-hidden="true">@include('theme::partials.motif', ['slot' => 'crest', 'class' => 'h-12 w-auto'])</span>
<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>
<p class="font-display text-[1.625rem] leading-tight">Ihr Wunschtermin?</p>
<a href="{{ route('booking.create') }}" class="btn-accent mt-4">Verfügbarkeit prüfen</a>
@if ($phone)
<a href="tel:{{ preg_replace('/[^0-9+]/', '', $phone) }}" class="mt-3 flex items-center justify-center gap-2 font-semibold hover:text-accent"><x-heroicon-o-phone class="size-5" aria-hidden="true" />{{ $phone }}</a>
@endif
</div>
</div>
</div>
@endforeach
</header>
@@ -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
@@ -9,8 +9,8 @@
<h2 id="{{ $sectionId }}-title" class="heading-display">{{ $heading }}</h2>
@if ($rotating)
<div class="flex gap-2">
<button type="button" data-rotator-prev class="flex size-12 items-center justify-center rounded-md border-2 border-ink hover:bg-ink/5" aria-label="Vorheriges Angebot"><x-heroicon-o-chevron-left class="size-5" aria-hidden="true" /></button>
<button type="button" data-rotator-next class="flex size-12 items-center justify-center rounded-md border-2 border-ink hover:bg-ink/5" aria-label="Nächstes Angebot"><x-heroicon-o-chevron-right class="size-5" aria-hidden="true" /></button>
<button type="button" data-rotator-prev class="flex size-12 items-center justify-center rounded-md border-2 border-ink hover:bg-ink/5" aria-label="Vorheriges Angebot"><x-heroicon-m-chevron-left class="size-5" aria-hidden="true" /></button>
<button type="button" data-rotator-next class="flex size-12 items-center justify-center rounded-md border-2 border-ink hover:bg-ink/5" aria-label="Nächstes Angebot"><x-heroicon-m-chevron-right class="size-5" aria-hidden="true" /></button>
</div>
@endif
</div>
@@ -0,0 +1,115 @@
{{--
Room area editor (FloorPlanForm): click the corners of a room on the plan picture; stored as "x,y x,y …" in
percent of the picture. The other rooms are shown as blue outlines for orientation.
--}}
@php
$planPhoto = \App\Models\Photo::query()->find($get('../../photo_id'));
$currentRoomId = $get('id');
$otherAreas = collect($get('../../rooms') ?? [])
->reject(fn ($room): bool => ($room['id'] ?? null) === $currentRoomId)
->map(fn ($room): string => collect(\App\Models\FloorPlan::points($room['points'] ?? null))->map(fn ($point): string => $point[0].','.$point[1])->implode(' '))
->filter()
->values();
@endphp
<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
@if (! $planPhoto)
<p style="padding:.75rem 1rem;border-radius:.5rem;background:#fef3c7;color:#92400e">Bitte oben zuerst das Grundriss-Bild wählen.</p>
@else
<div
x-data="{
state: $wire.$entangle('{{ $getStatePath() }}'),
dragging: null,
pairs() {
return String(this.state ?? '').trim().split(/\s+/)
.filter((pair) => /^\d+(\.\d+)?,\d+(\.\d+)?$/.test(pair))
.map((pair) => pair.split(',').map(Number))
},
write(pairs) { this.state = pairs.map(([x, y]) => x + ',' + y).join(' ') },
clamp(value) { return Math.min(100, Math.max(0, Math.round(value * 10) / 10)) },
position(event) {
const box = this.$refs.plan.getBoundingClientRect()
return [this.clamp((event.clientX - box.left) / box.width * 100), this.clamp((event.clientY - box.top) / box.height * 100)]
},
midpoints() {
const pairs = this.pairs()
if (pairs.length < 2) return []
return pairs.map((a, index) => {
const b = pairs[(index + 1) % pairs.length]
return { index, x: this.clamp((a[0] + b[0]) / 2), y: this.clamp((a[1] + b[1]) / 2) }
}).slice(0, pairs.length === 2 ? 1 : pairs.length)
},
add(event) {
this.write([...this.pairs(), this.position(event)])
},
startDrag(index, event) {
this.dragging = index
event.target.setPointerCapture(event.pointerId)
},
drag(event) {
if (this.dragging === null) return
const pairs = this.pairs()
pairs[this.dragging] = this.position(event)
this.write(pairs)
},
endDrag() { this.dragging = null },
insert(index) {
const pairs = this.pairs()
const middle = this.midpoints().find((point) => point.index === index)
pairs.splice(index + 1, 0, [middle.x, middle.y])
this.write(pairs)
},
remove(index) {
const pairs = this.pairs()
pairs.splice(index, 1)
this.write(pairs)
},
nudge(index, dx, dy, event) {
const step = event.shiftKey ? 1 : 0.2
const pairs = this.pairs()
pairs[index] = [this.clamp(pairs[index][0] + dx * step), this.clamp(pairs[index][1] + dy * step)]
this.write(pairs)
},
undo() { this.write(this.pairs().slice(0, -1)) },
clear() { this.state = '' },
}"
>
<div x-ref="plan" x-on:click="add($event)" x-on:pointermove="drag($event)" x-on:pointerup="endDrag()" x-on:pointercancel="endDrag()"
style="position:relative;cursor:crosshair;user-select:none;touch-action:none;border:1px solid #e4e4e7;border-radius:.5rem;overflow:hidden">
<img src="{{ $planPhoto->url('lg') }}" alt="" draggable="false" style="display:block;width:100%;height:auto">
<svg viewBox="0 0 100 100" preserveAspectRatio="none" style="position:absolute;inset:0;width:100%;height:100%;pointer-events:none" aria-hidden="true">
@foreach ($otherAreas as $area)
<polygon points="{{ $area }}" fill="rgba(37,99,235,.10)" stroke="#2563eb" stroke-width="1.5" vector-effect="non-scaling-stroke" />
@endforeach
<polygon x-bind:points="pairs().map((pair) => pair.join(',')).join(' ')" fill="rgba(217,119,6,.28)" stroke="#d97706" stroke-width="2.5" vector-effect="non-scaling-stroke" />
</svg>
<template x-for="point in midpoints()" x-bind:key="'m' + point.index">
<button type="button" x-on:click.stop="insert(point.index)" x-bind:aria-label="'Punkt zwischen Ecke ' + (point.index + 1) + ' und der nächsten einfügen'" title="Punkt einfügen"
x-bind:style="`position:absolute;left:${point.x}%;top:${point.y}%;width:18px;height:18px;margin:-9px 0 0 -9px;padding:0;border-radius:999px;border:1.5px solid #d97706;background:rgba(255,255,255,.85);color:#b45309;font:600 13px/1 sans-serif;cursor:copy`">+</button>
</template>
<template x-for="(pair, index) in pairs()" x-bind:key="'p' + index">
<button type="button"
x-on:pointerdown.stop="startDrag(index, $event)"
x-on:click.stop
x-on:dblclick.stop="remove(index)"
x-on:keydown.arrow-left.prevent="nudge(index, -1, 0, $event)"
x-on:keydown.arrow-right.prevent="nudge(index, 1, 0, $event)"
x-on:keydown.arrow-up.prevent="nudge(index, 0, -1, $event)"
x-on:keydown.arrow-down.prevent="nudge(index, 0, 1, $event)"
x-on:keydown.delete.prevent="remove(index)"
x-bind:aria-label="'Ecke ' + (index + 1) + ' – ziehen oder mit den Pfeiltasten verschieben, Entf löscht'"
x-bind:title="'Ecke ' + (index + 1)"
x-bind:style="`position:absolute;left:${pair[0]}%;top:${pair[1]}%;width:16px;height:16px;margin:-8px 0 0 -8px;padding:0;background:${dragging === index ? '#d97706' : '#fff'};border:2px solid #d97706;border-radius:3px;cursor:${dragging === index ? 'grabbing' : 'grab'};touch-action:none`"></button>
</template>
</div>
<div style="display:flex;flex-wrap:wrap;align-items:center;gap:.5rem;margin-top:.5rem">
<span style="font-size:.875rem;color:#52525b" x-text="pairs().length + (pairs().length === 1 ? ' Eckpunkt' : ' Eckpunkte')"></span>
<x-filament::button size="sm" color="gray" x-on:click="undo()" x-bind:disabled="pairs().length === 0">Letzten Punkt entfernen</x-filament::button>
<x-filament::button size="sm" color="danger" outlined x-on:click="clear()" x-bind:disabled="pairs().length === 0">Fläche leeren</x-filament::button>
</div>
<p style="margin-top:.25rem;font-size:.875rem;color:#71717a">
Neue Ecke: auf das Bild klicken. Ecke verschieben: Punkt mit der Maus ziehen oder anklicken und mit den Pfeiltasten bewegen (mit Umschalt in größeren Schritten).
Ecke einfügen: „+“ auf einer Kante. Ecke löschen: Doppelklick auf den Punkt oder Entf. Blau umrandet: die anderen Räume.
</p>
</div>
@endif
</x-dynamic-component>
Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

@@ -0,0 +1,11 @@
{
"viewBox": "0 46 869 344",
"areas": {
"terrasse": "78.0,159.0 130.0,159.0 160.0,288.0 108.0,288.0",
"wohnen": "135.0,159.0 470.0,159.0 489.0,240.7 329.0,240.7 350.0,331.0 240.0,331.0 163.0,279.4",
"kueche": "329.0,240.7 489.0,240.7 510.0,331.0 350.0,331.0",
"diele": "470.0,159.0 618.0,159.0 637.0,240.7 489.0,240.7",
"bad": "492.0,240.7 620.0,240.7 641.0,331.0 513.0,331.0",
"schlafen": "627.0,197.7 799.0,197.7 830.0,331.0 645.0,331.0 628.0,257.9"
}
}
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 46 869 344" role="img" aria-label="Grundriss der Ferienwohnung in leichter 3D-Ansicht"><title>Grundriss der Ferienwohnung</title><polygon points="24.0,133.2 128.0,133.2 178.4,349.9 74.4,349.9" fill="#CFE3C1" stroke="#CFE3C1" stroke-width="0" stroke-linejoin="round"/><polygon points="78.0,159.0 130.0,159.0 160.0,288.0 108.0,288.0" fill="#C9976A" stroke="#B8B2A6" stroke-width="0.8" stroke-linejoin="round"/><polygon points="135.0,159.0 470.0,159.0 489.0,240.7 329.0,240.7 350.0,331.0 240.0,331.0 163.0,279.4" fill="#E7D2AD" stroke="#B8B2A6" stroke-width="0.8" stroke-linejoin="round"/><polygon points="329.0,240.7 489.0,240.7 510.0,331.0 350.0,331.0" fill="#E9E7E1" stroke="#B8B2A6" stroke-width="0.8" stroke-linejoin="round"/><polygon points="470.0,159.0 618.0,159.0 637.0,240.7 489.0,240.7" fill="#E9E7E1" stroke="#B8B2A6" stroke-width="0.8" stroke-linejoin="round"/><polygon points="492.0,240.7 620.0,240.7 641.0,331.0 513.0,331.0" fill="#DCEFF5" stroke="#B8B2A6" stroke-width="0.8" stroke-linejoin="round"/><polygon points="627.0,197.7 799.0,197.7 830.0,331.0 645.0,331.0 628.0,257.9" fill="#EAD9BC" stroke="#B8B2A6" stroke-width="0.8" stroke-linejoin="round"/><path d="M84.0 159.0 L114.0 288.0" stroke="#A97B52" stroke-width="0.8"/><path d="M93.0 159.0 L123.0 288.0" stroke="#A97B52" stroke-width="0.8"/><path d="M102.0 159.0 L132.0 288.0" stroke="#A97B52" stroke-width="0.8"/><path d="M111.0 159.0 L141.0 288.0" stroke="#A97B52" stroke-width="0.8"/><path d="M120.0 159.0 L150.0 288.0" stroke="#A97B52" stroke-width="0.8"/><path d="M129.0 159.0 L159.0 288.0" stroke="#A97B52" stroke-width="0.8"/><path d="M331.4 242.4 L351.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M347.4 242.4 L367.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M363.4 242.4 L383.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M379.4 242.4 L399.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M395.4 242.4 L415.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M411.4 242.4 L431.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M427.4 242.4 L447.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M443.4 242.4 L463.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M459.4 242.4 L479.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M475.4 242.4 L495.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M331.4 242.4 L487.4 242.4" stroke="#CFCBC2" stroke-width="0.6"/><path d="M334.6 256.2 L490.6 256.2" stroke="#CFCBC2" stroke-width="0.6"/><path d="M337.8 269.9 L493.8 269.9" stroke="#CFCBC2" stroke-width="0.6"/><path d="M341.0 283.7 L497.0 283.7" stroke="#CFCBC2" stroke-width="0.6"/><path d="M344.2 297.5 L500.2 297.5" stroke="#CFCBC2" stroke-width="0.6"/><path d="M347.4 311.2 L503.4 311.2" stroke="#CFCBC2" stroke-width="0.6"/><path d="M350.6 325.0 L506.6 325.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M494.4 242.4 L514.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M510.4 242.4 L530.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M526.4 242.4 L546.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M542.4 242.4 L562.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M558.4 242.4 L578.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M574.4 242.4 L594.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M590.4 242.4 L610.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M606.4 242.4 L626.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M494.4 242.4 L618.4 242.4" stroke="#CFCBC2" stroke-width="0.6"/><path d="M497.6 256.2 L621.6 256.2" stroke="#CFCBC2" stroke-width="0.6"/><path d="M500.8 269.9 L624.8 269.9" stroke="#CFCBC2" stroke-width="0.6"/><path d="M504.0 283.7 L628.0 283.7" stroke="#CFCBC2" stroke-width="0.6"/><path d="M507.2 297.5 L631.2 297.5" stroke="#CFCBC2" stroke-width="0.6"/><path d="M510.4 311.2 L634.4 311.2" stroke="#CFCBC2" stroke-width="0.6"/><path d="M513.6 325.0 L637.6 325.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M472.4 160.7 L490.6 239.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M488.4 160.7 L506.6 239.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M504.4 160.7 L522.6 239.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M520.4 160.7 L538.6 239.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M536.4 160.7 L554.6 239.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M552.4 160.7 L570.6 239.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M568.4 160.7 L586.6 239.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M584.4 160.7 L602.6 239.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M600.4 160.7 L618.6 239.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M472.4 160.7 L616.4 160.7" stroke="#CFCBC2" stroke-width="0.6"/><path d="M475.6 174.5 L619.6 174.5" stroke="#CFCBC2" stroke-width="0.6"/><path d="M478.8 188.2 L622.8 188.2" stroke="#CFCBC2" stroke-width="0.6"/><path d="M482.0 202.0 L626.0 202.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M485.2 215.8 L629.2 215.8" stroke="#CFCBC2" stroke-wLine truncated

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

@@ -0,0 +1,12 @@
{
"viewBox": "0 0 1712 919",
"areas": {
"terrasse": "45,200 140,200 140,515 45,515",
"wohnen": "178,200 848,200 848,370 520,370 520,592 262,592 160,478 178,440",
"kueche": "520,370 848,370 848,592 520,592",
"diele": "850,200 1195,200 1265,262 1200,345 1140,400 1140,378 850,378",
"eingang": "1300,82 1515,82 1515,265 1270,265 1210,205 1210,150",
"bad": "852,380 1135,380 1135,595 852,595",
"schlafen": "1275,268 1528,268 1528,606 1140,606 1140,400 1208,345"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

+174
View File
@@ -0,0 +1,174 @@
"""Isometric-like cutaway of the holiday flat (oblique projection), generated from plan coordinates (800 x 548 scan).
Output: SVG with floors, low walls and simple furniture; also prints the projected room polygons for click areas.
"""
import json
import sys
SHEAR, SQUASH = 0.2, 0.86 # oblique projection: X = x + SHEAR * y, Y = SQUASH * y - z
OX, OY = 40, 30 # margin
NAVY, PAPER, LINE = '#13294B', '#FBFAF7', '#13294B'
def project(x, y, z=0.0):
return x + SHEAR * y, SQUASH * y - z
shapes = [] # (depth, svg)
def poly(points, fill, stroke=LINE, width=1.2, extra=''):
pts = ' '.join(f'{round(px + OX, 1)},{round(py + OY, 1)}' for px, py in points)
return f'<polygon points="{pts}" fill="{fill}" stroke="{stroke}" stroke-width="{width}" stroke-linejoin="round"{extra}/>'
def signed_area(points):
return sum(points[i][0] * points[(i + 1) % len(points)][1] - points[(i + 1) % len(points)][0] * points[i][1] for i in range(len(points))) / 2
def prism(base, height, top, side, front=None, depth=None, z0=0.0, outline=LINE):
"""Convex prism over a plan polygon; side faces drawn back-to-front with back-face culling."""
front = front or side
faces = []
n = len(base)
for i in range(n):
(x1, y1), (x2, y2) = base[i], base[(i + 1) % n]
quad = [project(x1, y1, z0), project(x2, y2, z0), project(x2, y2, z0 + height), project(x1, y1, z0 + height)]
if signed_area(quad) <= 0:
continue
colour = front if abs(y1 - y2) < 1e-6 else side
faces.append((max(y1, y2), poly(quad, colour, outline, 1.1)))
faces.sort(key=lambda f: f[0])
svg = ''.join(f for _, f in faces) + poly([project(x, y, z0 + height) for x, y in base], top, outline, 1.1)
shapes.append((depth if depth is not None else max(y for _, y in base) + 0.001 * min(x for x, _ in base), svg))
def box(x, y, w, d, h, top, side, front=None, z0=0.0, depth=None):
prism([(x, y), (x + w, y), (x + w, y + d), (x, y + d)], h, top, side, front, depth, z0)
def wall(x1, y1, x2, y2, t=6, h=22):
dx, dy = x2 - x1, y2 - y1
length = (dx * dx + dy * dy) ** 0.5
nx, ny = -dy / length * t / 2, dx / length * t / 2
base = [(x1 + nx, y1 + ny), (x2 + nx, y2 + ny), (x2 - nx, y2 - ny), (x1 - nx, y1 - ny)]
if signed_area(base) < 0:
base.reverse()
prism(base, h, NAVY, '#FFFFFF', '#F1EFEA')
# Rooms (same polygons as the click areas in the scan).
ROOMS = {
'terrasse': [(8, 150), (60, 150), (60, 300), (8, 300)],
'wohnen': [(65, 150), (400, 150), (400, 245), (240, 245), (240, 350), (130, 350), (65, 290)],
'kueche': [(240, 245), (400, 245), (400, 350), (240, 350)],
'diele': [(400, 150), (548, 150), (548, 245), (400, 245)],
'bad': [(403, 245), (531, 245), (531, 350), (403, 350)],
'schlafen': [(548, 195), (720, 195), (720, 350), (535, 350), (535, 265)],
}
FLOORS = {'terrasse': '#C9976A', 'wohnen': '#E7D2AD', 'kueche': '#E9E7E1', 'diele': '#E9E7E1', 'bad': '#DCEFF5', 'schlafen': '#EAD9BC'}
floor_svg = []
# lawn around the terrace and along the front
floor_svg.append(poly([project(-40, 120), project(64, 120), project(64, 372), project(-40, 372)], '#CFE3C1', '#CFE3C1', 0))
for key, points in ROOMS.items():
floor_svg.append(poly([project(x, y) for x, y in points], FLOORS[key], '#B8B2A6', 0.8))
# deck planks and tile grids
for x in range(14, 60, 9):
floor_svg.append(f'<path d="M{project(x, 150)[0] + OX:.1f} {project(x, 150)[1] + OY:.1f} L{project(x, 300)[0] + OX:.1f} {project(x, 300)[1] + OY:.1f}" stroke="#A97B52" stroke-width="0.8"/>')
for (x0, y0, x1, y1) in ((242, 247, 398, 348), (405, 247, 529, 348), (402, 152, 546, 243)):
step = 16
for x in range(x0, x1, step):
floor_svg.append(f'<path d="M{project(x, y0)[0] + OX:.1f} {project(x, y0)[1] + OY:.1f} L{project(x, y1)[0] + OX:.1f} {project(x, y1)[1] + OY:.1f}" stroke="#CFCBC2" stroke-width="0.6"/>')
for y in range(y0, y1, step):
floor_svg.append(f'<path d="M{project(x0, y)[0] + OX:.1f} {project(x0, y)[1] + OY:.1f} L{project(x1, y)[0] + OX:.1f} {project(x1, y)[1] + OY:.1f}" stroke="#CFCBC2" stroke-width="0.6"/>')
# Walls (outer and inner, with openings).
for seg in [
(65, 148, 238, 148), (238, 148, 548, 148), # north
(548, 148, 548, 195), (548, 195, 720, 195), # entry corner, bedroom north
(720, 195, 720, 352), # east
]:
wall(*seg)
# Front walls are cut low (architectural model), so the rooms stay visible.
for seg in [
(720, 352, 610, 352), (560, 352, 130, 352), # south (gap = bedroom window)
(130, 352, 65, 290), # diagonal
(65, 290, 65, 262), (65, 182, 65, 148), # west (gap = terrace door)
]:
wall(*seg, h=7)
for seg in [
(400, 148, 400, 200), # living / hall partial
(400, 245, 440, 245), (472, 245, 531, 245), # bath north with door
(403, 245, 403, 352), (531, 245, 531, 352), # bath west/east
(540, 195, 540, 252), (540, 292, 540, 352), # bedroom west with door
]:
wall(*seg)
# Furniture
WOOD, WHITE, LEATHER, GLASS = '#B7895C', '#FFFFFF', '#2A4C7A', '#BFE4EE'
box(238, 154, 116, 18, 28, '#F4F1EA', '#E6E1D6') # Schrankbett cabinet
box(405, 154, 132, 18, 28, '#F4F1EA', '#E6E1D6') # hall wardrobe
box(100, 160, 104, 34, 15, LEATHER, '#1F3B61') # sofa
box(100, 160, 104, 10, 26, LEATHER, '#1F3B61', depth=162) # sofa back
box(118, 208, 74, 34, 9, GLASS, '#9CCFDD') # glass table
box(150, 258, 46, 40, 15, LEATHER, '#1F3B61') # relax chair
box(84, 300, 52, 26, 20, WHITE, '#E9E6DF') # TV cabinet
box(262, 252, 32, 92, 13, '#3A3A3A', '#2A2A2A') # dining table
for cx, cy in ((246, 262), (246, 318), (298, 262), (298, 318)):
box(cx, cy, 14, 14, 9, '#5B5B5B', '#444444') # chairs
box(368, 250, 32, 100, 17, '#F7F6F2', '#E4E1D9') # kitchen counter (east)
box(300, 322, 68, 28, 17, '#F7F6F2', '#E4E1D9') # kitchen counter (south)
box(410, 262, 30, 34, 12, WHITE, '#E7EEF1') # toilet
box(410, 310, 30, 30, 18, WHITE, '#E7EEF1') # wash basin
box(478, 300, 48, 48, 30, '#E3F4F8', '#C6E6EE') # shower glass
box(605, 238, 110, 106, 11, '#FFFFFF', '#E9E4DA') # bed
box(605, 238, 110, 8, 24, WOOD, '#9C7149', depth=239) # headboard
for px in (612, 662):
box(px, 250, 44, 18, 15, '#F4F4F4', '#E2E2E2') # pillows
box(580, 238, 22, 22, 15, WOOD, '#9C7149') # nightstands
box(580, 320, 22, 22, 15, WOOD, '#9C7149')
box(18, 196, 30, 30, 11, '#3A3A3A', '#2A2A2A') # terrace table
for cx, cy in ((8, 204), (50, 204)):
box(cx, cy, 10, 12, 14, '#4A4A4A', '#333333') # terrace chairs
# hob and sink on the kitchen counter
extras = []
for hx, hy in ((378, 268), (390, 268), (378, 282), (390, 282)):
X, Y = project(hx, hy, 17)
extras.append(f'<ellipse cx="{X + OX:.1f}" cy="{Y + OY:.1f}" rx="4.2" ry="3.4" fill="#2A2A2A"/>')
X, Y = project(384, 318, 17)
extras.append(f'<rect x="{X + OX - 9:.1f}" y="{Y + OY - 7:.1f}" width="18" height="12" rx="2" fill="#C9D3D8" stroke="#8A979E" stroke-width="0.8"/>')
shapes.append((351, ''.join(extras)))
# room names on the floors
LABELS = {'wohnen': (180, 330, 'Wohnbereich'), 'kueche': (334, 300, 'Küche'), 'diele': (470, 232, 'Diele'), 'bad': (468, 264, 'Bad'), 'schlafen': (660, 300, 'Schlafzimmer'), 'terrasse': (34, 292, 'Terrasse')}
labels = []
for key, (lx, ly, text) in LABELS.items():
X, Y = project(lx, ly)
labels.append(f'<text x="{X + OX:.1f}" y="{Y + OY:.1f}" font-family="Newsreader, Georgia, serif" font-size="15" fill="#13294B" text-anchor="middle">{text}</text>')
shapes.sort(key=lambda s: s[0])
# rhododendron bushes on the lawn
bush = []
for cx, cy, r in ((-14, 172, 20), (-18, 236, 18), (-10, 300, 22)):
X, Y = project(cx, cy, 10)
bush.append(f'<ellipse cx="{X + OX:.1f}" cy="{Y + OY:.1f}" rx="{r}" ry="{r * 0.75:.1f}" fill="#4E7A52"/>')
for i, (dx, dy) in enumerate(((-8, -5), (4, -8), (9, 2), (-3, 4), (-10, 5), (6, 8))):
bush.append(f'<circle cx="{X + OX + dx * r / 20:.1f}" cy="{Y + OY + dy * r / 20:.1f}" r="{3.2 if i % 2 else 4:.1f}" fill="#D9578B"/>')
xs, ys = [], []
for x in (-40, 730):
for y in (100, 395):
for z in (0, 60):
px, py = project(x, y, z)
xs.append(px + OX); ys.append(py + OY)
width, height = round(max(xs) + 20), round(max(ys) + 20)
min_y = round(min(ys) - 10)
svg = (f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 {min_y} {width} {height - min_y}" role="img" aria-label="Grundriss der Ferienwohnung in leichter 3D-Ansicht">'
'<title>Grundriss der Ferienwohnung</title>' + ''.join(floor_svg) + ''.join(s for _, s in shapes) + ''.join(bush) + ''.join(labels) + '</svg>')
open(sys.argv[1], 'w', encoding='utf-8').write(svg)
areas = {key: ' '.join(f'{round(project(x, y)[0] + OX, 1)},{round(project(x, y)[1] + OY, 1)}' for x, y in pts) for key, pts in ROOMS.items()}
print(json.dumps({'viewBox': f'0 {min_y} {width} {height - min_y}', 'areas': areas}, indent=1))
+89
View File
@@ -0,0 +1,89 @@
[
{
"id": "terrasse",
"name": "Terrasse",
"description": "Eigene, überdachte Terrasse mit Gartenmöbeln. Im Frühsommer blühen die Rhododendren direkt davor.",
"hint": "Über den Garten stufenlos erreichbar.",
"points": "2.6,21.8 8.2,21.8 8.2,56.0 2.6,56.0",
"photo_ids": [
21
],
"amenity_ids": [],
"is_visible": true
},
{
"id": "wohnen",
"name": "Wohnbereich",
"description": "Helles Wohnzimmer mit Fensterfront zur Terrasse. Das Schrankbett bietet Platz für eine dritte Person.",
"hint": null,
"points": "10.4,21.8 49.5,21.8 49.5,40.3 30.4,40.3 30.4,64.4 15.3,64.4 9.3,52.0 10.4,47.9",
"photo_ids": [
2,
1,
6
],
"amenity_ids": [],
"is_visible": true
},
{
"id": "kueche",
"name": "Küche & Essplatz",
"description": "Einbauküche zum Selbstversorgen mit Essplatz für vier.",
"hint": null,
"points": "30.4,40.3 49.5,40.3 49.5,64.4 30.4,64.4",
"photo_ids": [
9,
8
],
"amenity_ids": [],
"is_visible": true
},
{
"id": "diele",
"name": "Diele",
"description": "Großer Einbauschrank. Von hier geht es zu Bad, Schlafzimmer und Eingang.",
"hint": null,
"points": "49.6,21.8 69.8,21.8 73.9,28.5 70.1,37.5 66.6,43.5 66.6,41.1 49.6,41.1",
"photo_ids": [
11
],
"amenity_ids": [],
"is_visible": true
},
{
"id": "eingang",
"name": "Eingangsbereich",
"description": "Eigene Wohnungstür mit Fußabtreter.",
"hint": "Eingang im Erdgeschoss mit einer Stufe.",
"points": "75.9,8.9 88.5,8.9 88.5,28.8 74.2,28.8 70.7,22.3 70.7,16.3",
"photo_ids": [],
"amenity_ids": [],
"is_visible": true
},
{
"id": "bad",
"name": "Bad",
"description": "Bad mit Glasdusche (90 × 90 cm) und beleuchtetem Spiegelschrank.",
"hint": "Flache Dusche mit kleiner Kante – die Wohnung ist nicht rollstuhlgerecht.",
"points": "49.8,41.3 66.3,41.3 66.3,64.7 49.8,64.7",
"photo_ids": [
16,
17
],
"amenity_ids": [],
"is_visible": true
},
{
"id": "schlafen",
"name": "Schlafzimmer",
"description": "Ruhiges Schlafzimmer zur Gartenseite mit Kingsize-Bett.",
"hint": null,
"points": "74.5,29.2 89.3,29.2 89.3,65.9 66.6,65.9 66.6,43.5 70.6,37.5",
"photo_ids": [
13,
14
],
"amenity_ids": [],
"is_visible": true
}
]
+123
View File
@@ -0,0 +1,123 @@
<?php
namespace Tests\Feature;
use App\Enums\UserRole;
use App\Filament\Resources\FloorPlans\FloorPlanResource;
use App\Filament\Resources\FloorPlans\Pages\CreateFloorPlan;
use App\Models\Amenity;
use App\Models\FloorPlan;
use App\Models\Page;
use App\Models\Photo;
use App\Models\Property;
use App\Models\Site;
use App\Models\User;
use Carbon\CarbonImmutable;
use Database\Seeders\PropertySeeder;
use Database\Seeders\SiteSeeder;
use Database\Seeders\WebsiteContentSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
use Tests\TestCase;
class FloorPlanTest extends TestCase
{
use RefreshDatabase;
private Property $property;
protected function setUp(): void
{
parent::setUp();
$this->travelTo(CarbonImmutable::parse('2026-10-22 10:00'));
$this->seed([PropertySeeder::class, WebsiteContentSeeder::class, SiteSeeder::class]);
$this->withoutVite();
$this->property = Property::sole();
}
public function test_floor_plan_belongs_to_the_landlord_of_its_apartment(): void
{
$plan = FloorPlan::factory()->for($this->property)->create();
$this->assertSame($this->property->tenant_id, $plan->tenant_id);
$this->assertTrue($this->property->floorPlan->is($plan));
}
public function test_area_points_are_parsed_in_percent_and_invalid_pairs_are_dropped(): void
{
$this->assertSame([[10.0, 20.5], [50.0, 20.5], [50.0, 65.0]], FloorPlan::points(' 10,20.5 50,20.5 50,65 abc 150,3 '));
$this->assertSame([], FloorPlan::points(null));
}
public function test_section_shows_visible_rooms_with_area_photo_equipment_and_hint(): void
{
$roomPhoto = Photo::factory()->create(['alt_text' => 'Glasdusche im Bad']);
$shower = Amenity::factory()->for($this->property)->create(['name' => 'Dusche mit niedrigem Einstieg']);
FloorPlan::factory()->for($this->property)->create([
'photo_id' => Photo::factory()->create(['alt_text' => 'Grundriss der Wohnung'])->id,
'rooms' => [
['id' => 'a', 'name' => 'Bad', 'description' => 'Bad mit Glasdusche.', 'hint' => 'Flache Dusche mit kleiner Kante.', 'points' => '50,40 66,40 66,65', 'photo_ids' => [$roomPhoto->id], 'amenity_ids' => [$shower->id], 'is_visible' => true],
['id' => 'b', 'name' => 'Abstellkammer', 'points' => '1,1 2,1 2,2', 'is_visible' => false],
['id' => 'c', 'name' => 'Ohne Fläche', 'points' => '1,1 2,2', 'is_visible' => true],
],
]);
$this->placeSectionOnApartmentPage();
$this->get('/wohnung')
->assertOk()
->assertSee('Der Grundriss')
->assertSee('points="50,40 66,40 66,65"', false)
->assertSee('id="raum-bad-1"', false)
->assertSee('Bad mit Glasdusche.')
->assertSee('Flache Dusche mit kleiner Kante.')
->assertSee('Dusche mit niedrigem Einstieg')
->assertSee('Glasdusche im Bad')
->assertDontSee('Abstellkammer')
->assertDontSee('Ohne Fläche');
}
public function test_section_shows_nothing_without_a_floor_plan(): void
{
$this->placeSectionOnApartmentPage();
$this->get('/wohnung')->assertOk()->assertDontSee('Der Grundriss');
}
public function test_content_editor_creates_a_floor_plan_and_a_room_needs_an_area(): void
{
$this->actingAs(User::factory()->role(UserRole::Content)->create());
$planPhoto = Photo::factory()->create();
$this->get(FloorPlanResource::getUrl('index'))->assertOk();
Livewire::test(CreateFloorPlan::class)
->fillForm([
'property_id' => $this->property->id,
'photo_id' => $planPhoto->id,
'rooms' => ['diele' => ['id' => 'x', 'name' => 'Diele', 'points' => '10,10 20,10', 'is_visible' => true]],
])
->call('create')
->assertHasFormErrors(['rooms.diele.points']);
Livewire::test(CreateFloorPlan::class)
->fillForm([
'property_id' => $this->property->id,
'photo_id' => $planPhoto->id,
'rooms' => ['diele' => ['id' => 'x', 'name' => 'Diele', 'points' => '10,10 20,10 20,30 10,30', 'is_visible' => true]],
])
->call('create')
->assertHasNoFormErrors();
$plan = FloorPlan::sole();
$this->assertSame($this->property->tenant_id, $plan->tenant_id);
$this->assertSame(['Diele'], $plan->visibleRooms()->pluck('name')->all());
}
private function placeSectionOnApartmentPage(): void
{
$page = Site::sole()->pages()->where('slug', 'wohnung')->sole();
$page->update(['sections' => [...$page->sections, ['type' => 'floor_plan', 'data' => ['heading' => 'Der Grundriss']]]]);
$this->assertInstanceOf(Page::class, $page);
}
}
@@ -0,0 +1,72 @@
<?php
namespace Tests\Feature;
use App\Enums\ReviewStatus;
use App\Models\FloorPlan;
use App\Models\Page;
use App\Models\Property;
use App\Models\Review;
use App\Models\Site;
use App\Models\SpecialOffer;
use App\Themes\ThemeRegistry;
use Carbon\CarbonImmutable;
use Database\Seeders\PropertySeeder;
use Database\Seeders\SiteSeeder;
use Database\Seeders\WebsiteContentSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
/**
* Every installed theme must render every page with real content in every display mode – a template that only
* breaks when data exists (e.g. offers shown as a carousel) would otherwise go unnoticed until it is live.
*/
class InstalledThemesRenderTest extends TestCase
{
use RefreshDatabase;
private const PAGES = ['/', '/wohnung', '/kuehlungsborn', '/buchen', '/kontakt', '/impressum', '/datenschutz'];
protected function setUp(): void
{
parent::setUp();
$this->travelTo(CarbonImmutable::parse('2026-10-22 10:00'));
$this->seed([PropertySeeder::class, WebsiteContentSeeder::class, SiteSeeder::class]);
$this->withoutVite();
$property = Property::sole();
Review::factory()->for($property)->count(2)->create(['status' => ReviewStatus::Approved]);
SpecialOffer::factory()->for($property)->create(['name' => 'Herbstwochen', 'is_featured' => true]);
SpecialOffer::factory()->for($property)->create(['name' => 'Ab 5 Nächten', 'min_nights' => 5]);
FloorPlan::factory()->for($property)->create();
$apartment = Page::query()->where('slug', 'wohnung')->sole();
$apartment->update(['sections' => [...$apartment->sections, ['type' => 'floor_plan', 'data' => ['heading' => 'Der Grundriss']]]]);
}
public function test_every_installed_theme_renders_all_pages_with_offers_in_every_display_mode(): void
{
$site = Site::sole();
$home = Page::query()->where('slug', Page::HOME)->sole();
foreach (array_keys(app(ThemeRegistry::class)->all()) as $themeKey) {
$site->update(['theme' => $themeKey]);
foreach (['grid', 'list', 'rotating'] as $display) {
$home->update(['sections' => array_map(
fn (array $section): array => $section['type'] === 'offers' ? [...$section, 'data' => [...$section['data'], 'display' => $display]] : $section,
$home->sections,
)]);
$this->get('/')->assertOk()->assertSee('Herbstwochen');
}
foreach (self::PAGES as $path) {
$this->get($path)->assertOk();
}
$this->get('/wohnung')->assertSee('Der Grundriss')->assertSee('Wohnbereich');
}
}
}
+67 -5
View File
@@ -8,13 +8,17 @@
use App\Mail\NewReservation;
use App\Mail\ReservationReceived;
use App\Models\Property;
use App\Models\Tenant;
use App\Models\User;
use App\Pricing\StayRequest;
use App\Support\Settings;
use App\Tenancy\TenantConfig;
use App\Tenancy\TenantContext;
use Carbon\CarbonImmutable;
use Database\Seeders\PropertySeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Mail\MailManager;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Mail;
use Livewire\Livewire;
use Tests\TestCase;
@@ -26,6 +30,7 @@ class OperationsModeTest extends TestCase
public function test_new_installations_start_in_test_mode_with_the_notification_address(): void
{
config(['fewo.mail_redirect_to' => null, 'fewo.notification_email' => 'fewo@example.com']);
$this->landlord(['notification_emails' => null, 'test_recipient' => null]);
$this->assertFalse(Settings::isLive());
$this->assertSame('fewo@example.com', Settings::mailRedirect());
@@ -34,7 +39,7 @@ public function test_new_installations_start_in_test_mode_with_the_notification_
public function test_in_test_mode_every_mail_goes_to_the_test_recipient_only(): void
{
config(['fewo.mail_redirect_to' => null, 'mail.default' => 'array']);
Settings::save([Settings::MODE => Settings::MODE_TEST, Settings::TEST_RECIPIENT => 'test@example.com']);
$this->landlord(['operating_mode' => Settings::MODE_TEST, 'test_recipient' => 'test@example.com']);
Mail::raw('Hallo', fn ($message) => $message->to('gast@example.com')->cc('vermieterin@example.com')->subject('Angebot'));
@@ -45,7 +50,7 @@ public function test_in_test_mode_every_mail_goes_to_the_test_recipient_only():
public function test_switched_live_mails_reach_their_real_recipients(): void
{
config(['fewo.mail_redirect_to' => null, 'mail.default' => 'array']);
Settings::save([Settings::MODE => Settings::MODE_LIVE]);
$this->landlord(['operating_mode' => Settings::MODE_LIVE]);
Mail::raw('Hallo', fn ($message) => $message->to('gast@example.com')->subject('Angebot'));
@@ -54,9 +59,12 @@ public function test_switched_live_mails_reach_their_real_recipients(): void
$this->assertNull(Settings::mailRedirect());
}
public function test_addresses_of_the_internal_communication_are_set_in_the_admin(): void
public function test_addresses_and_landlord_data_of_the_internal_communication_are_set_in_the_admin(): void
{
config(['fewo.mail_redirect_to' => null]);
$this->seed(PropertySeeder::class);
$tenant = Tenant::query()->where('slug', 'stommer')->firstOrFail();
app(TenantContext::class)->set($tenant);
$this->actingAs(User::factory()->create());
Livewire::test(Operations::class)
@@ -65,14 +73,16 @@ public function test_addresses_of_the_internal_communication_are_set_in_the_admi
->set('data.contact_email', 'info@example.com')
->set('data.sender_name', 'FeWo Test')
->set('data.sender_email', 'versand@example.com')
->set('data.owner_name', 'Brigitte Beispiel')
->set('data.bank_iban', 'DE02120300000000202051')
->call('save')
->assertHasNoErrors();
$this->assertSame(['brigitte@example.com', 'lars@example.com'], Settings::notificationRecipients());
$this->assertSame(['info@example.com', 'versand@example.com', 'FeWo Test'], [config('fewo.owner.email'), config('mail.from.address'), config('mail.from.name')]);
$this->assertSame(['Brigitte Beispiel', 'DE02120300000000202051'], [config('fewo.owner.name'), config('fewo.bank.iban')]);
Mail::fake();
$this->seed(PropertySeeder::class);
$booking = app(CreateReservation::class)->handle(Property::sole(), new StayRequest(CarbonImmutable::parse('2026-12-01'), CarbonImmutable::parse('2026-12-05'), 2), ['first_name' => 'Erika', 'last_name' => 'Muster', 'email' => 'erika@example.com']);
Mail::assertSent(NewReservation::class, fn (NewReservation $mail): bool => $mail->hasTo('brigitte@example.com') && $mail->hasTo('lars@example.com'));
@@ -80,8 +90,45 @@ public function test_addresses_of_the_internal_communication_are_set_in_the_admi
$this->assertNotNull($booking);
}
public function test_the_bank_details_are_stored_encrypted(): void
{
$tenant = $this->landlord(['bank_iban' => 'DE02120300000000202051']);
$stored = DB::table('tenants')->where('id', $tenant->id)->value('bank_iban');
$this->assertNotSame('DE02120300000000202051', $stored);
$this->assertSame('DE02120300000000202051', $tenant->fresh()->bank_iban);
}
public function test_a_landlord_cannot_relax_a_retention_period_or_the_bot_protection(): void
{
config(['fewo.guest_retention_years' => 10, 'fewo.spam.per_ip_per_hour' => 5, 'fewo.spam.min_seconds' => 4]);
$this->landlord([
'guest_retention_years' => 25,
'spam_per_ip_per_hour' => 50,
'spam_min_seconds' => 1,
'deposit_due_days' => 21,
]);
$this->assertSame(10, config('fewo.guest_retention_years'));
$this->assertSame(5, config('fewo.spam.per_ip_per_hour'));
$this->assertSame(4, config('fewo.spam.min_seconds'));
$this->assertSame(21, config('fewo.deposit_due_days'));
}
public function test_a_landlord_may_tighten_a_retention_period(): void
{
config(['fewo.guest_retention_years' => 10, 'fewo.spam.min_seconds' => 4]);
$this->landlord(['guest_retention_years' => 3, 'spam_min_seconds' => 9]);
$this->assertSame(3, config('fewo.guest_retention_years'));
$this->assertSame(9, config('fewo.spam.min_seconds'));
}
public function test_invalid_notification_addresses_are_rejected(): void
{
$this->landlord();
$this->actingAs(User::factory()->create());
Livewire::test(Operations::class)
@@ -93,7 +140,7 @@ public function test_invalid_notification_addresses_are_rejected(): void
public function test_server_override_always_wins(): void
{
config(['fewo.mail_redirect_to' => 'server@example.com']);
Settings::save([Settings::MODE => Settings::MODE_LIVE]);
$this->landlord(['operating_mode' => Settings::MODE_LIVE]);
$this->assertSame('server@example.com', Settings::mailRedirect());
}
@@ -101,6 +148,7 @@ public function test_server_override_always_wins(): void
public function test_administrator_switches_the_mode_in_the_admin_and_sees_the_banner(): void
{
config(['fewo.mail_redirect_to' => null]);
$this->landlord();
$this->actingAs(User::factory()->create());
$this->get(Operations::getUrl())->assertOk()->assertSee('Testbetrieb:');
@@ -118,4 +166,18 @@ public function test_administrator_switches_the_mode_in_the_admin_and_sees_the_b
$this->actingAs(User::factory()->role(UserRole::Rentals)->create());
$this->get(Operations::getUrl())->assertForbidden();
}
/**
* The only landlord, with the operating data under test applied to the configuration.
*
* @param array<string, mixed> $attributes
*/
private function landlord(array $attributes = []): Tenant
{
$tenant = Tenant::factory()->create($attributes);
app(TenantContext::class)->set($tenant);
app(TenantConfig::class)->refresh();
return $tenant;
}
}
+155
View File
@@ -0,0 +1,155 @@
<?php
namespace Tests\Feature;
use App\Enums\TenantServiceKey;
use App\Filament\Operator\Tenants\Pages\EditTenant;
use App\Models\Tenant;
use App\Models\User;
use App\Support\Content;
use App\Support\Settings;
use App\Tenancy\TenantConfig;
use App\Tenancy\TenantContext;
use Filament\Facades\Filament;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Livewire\Livewire;
use Tests\TestCase;
/**
* Phase 3: operating data and texts belong to the landlord, not to the installation.
*/
class TenantSettingsTest extends TestCase
{
use RefreshDatabase;
public function test_each_landlord_has_its_own_imprint_bank_and_operating_mode(): void
{
config(['fewo.mail_redirect_to' => null]);
$first = Tenant::factory()->create([
'bank_iban' => 'DE02120300000000202051',
'operating_mode' => Settings::MODE_LIVE,
'owner_name' => 'Brigitte Beispiel',
]);
$second = Tenant::factory()->create([
'bank_iban' => 'DE02500105170137075030',
'operating_mode' => Settings::MODE_TEST,
'test_recipient' => 'test@zweiter.example',
'owner_name' => 'Zweiter Vermieter',
]);
$context = app(TenantContext::class);
$context->set($first);
Content::save(['legal.imprint' => 'Impressum des ersten Vermieters']);
$this->assertSame('Impressum des ersten Vermieters', Content::get('legal.imprint'));
$this->assertSame('DE02120300000000202051', config('fewo.bank.iban'));
$this->assertSame('Brigitte Beispiel', config('fewo.owner.name'));
$this->assertTrue(Settings::isLive());
$this->assertNull(Settings::mailRedirect());
$context->set($second);
$this->assertNull(Content::get('legal.imprint'));
Content::save(['legal.imprint' => 'Impressum des zweiten Vermieters']);
$this->assertSame('DE02500105170137075030', config('fewo.bank.iban'));
$this->assertSame('Zweiter Vermieter', config('fewo.owner.name'));
$this->assertFalse(Settings::isLive());
$this->assertSame('test@zweiter.example', Settings::mailRedirect());
$context->set($first);
$this->assertSame('Impressum des ersten Vermieters', Content::get('legal.imprint'));
}
public function test_without_a_landlord_the_configuration_of_the_installation_applies(): void
{
config(['fewo.owner.name' => 'Aus der Konfiguration']);
$first = Tenant::factory()->create(['owner_name' => 'Brigitte Beispiel']);
Tenant::factory()->create();
$context = app(TenantContext::class);
$context->set($first);
$this->assertSame('Brigitte Beispiel', config('fewo.owner.name'));
$context->forget();
$this->assertSame('Aus der Konfiguration', config('fewo.owner.name'));
$this->assertNull(Settings::tenant());
}
public function test_the_operator_switches_services_per_landlord_and_an_empty_key_is_allowed(): void
{
$tenant = Tenant::factory()->create();
$tenant->services()->create(['service' => TenantServiceKey::PortalSync->value, 'is_enabled' => true, 'api_key' => null]);
$tenant->services()->create(['service' => TenantServiceKey::AiOffers->value, 'is_enabled' => true, 'api_key' => 'sk-beispiel']);
$sync = $tenant->services()->where('service', TenantServiceKey::PortalSync->value)->sole();
$ai = $tenant->services()->where('service', TenantServiceKey::AiOffers->value)->sole();
$this->assertTrue($sync->is_enabled);
$this->assertNull($sync->api_key);
$this->assertSame('sk-beispiel', $ai->api_key);
$this->assertSame(0, Tenant::factory()->create()->services()->count());
}
public function test_an_own_service_key_is_stored_encrypted(): void
{
$tenant = Tenant::factory()->create();
$service = $tenant->services()->create(['service' => TenantServiceKey::AiMarketing->value, 'is_enabled' => true, 'api_key' => 'sk-geheim']);
$this->assertNotSame('sk-geheim', DB::table('tenant_services')->where('id', $service->id)->value('api_key'));
$this->assertSame('sk-geheim', $service->fresh()->api_key);
}
public function test_the_operator_switches_a_service_on_the_tenant_form(): void
{
$tenant = Tenant::factory()->create();
app(TenantContext::class)->set($tenant);
$operator = User::factory()->create();
$operator->forceFill(['is_operator' => true])->saveQuietly();
$this->actingAs($operator);
Filament::setCurrentPanel('operator');
Livewire::test(EditTenant::class, ['record' => $tenant->getRouteKey()])
->fillForm([
'services.'.TenantServiceKey::PortalSync->value.'.is_enabled' => true,
'services.'.TenantServiceKey::AiOffers->value.'.is_enabled' => true,
'services.'.TenantServiceKey::AiOffers->value.'.api_key' => 'sk-beispiel',
])
->call('save')
->assertHasNoErrors();
$this->assertTrue($tenant->services()->where('service', TenantServiceKey::PortalSync->value)->sole()->is_enabled);
$this->assertNull($tenant->services()->where('service', TenantServiceKey::PortalSync->value)->sole()->api_key);
$this->assertSame('sk-beispiel', $tenant->services()->where('service', TenantServiceKey::AiOffers->value)->sole()->api_key);
$this->assertFalse($tenant->services()->where('service', TenantServiceKey::AiGuestMail->value)->sole()->is_enabled);
}
/**
* The data a new landlord starts with comes from the installation, never from the landlord that happens
* to be current – otherwise the migration would copy one landlord's address into the next one.
*/
public function test_the_defaults_of_a_new_landlord_come_from_the_configuration_not_from_the_current_one(): void
{
config(['fewo.owner.name' => 'Aus der Konfiguration', 'fewo.owner.email' => 'konfiguration@example.com']);
$current = Tenant::factory()->create(['owner_name' => 'Erster Vermieter', 'contact_email' => 'erster@example.com']);
app(TenantContext::class)->set($current);
$this->assertSame('Erster Vermieter', config('fewo.owner.name'));
$next = Tenant::factory()->create();
$this->assertSame('Aus der Konfiguration', $next->owner_name);
$this->assertSame('konfiguration@example.com', $next->contact_email);
}
public function test_the_landlord_of_the_context_decides_the_sender(): void
{
$tenant = Tenant::factory()->create(['sender_email' => 'versand@vermieter.example', 'sender_name' => 'Vermieter']);
app(TenantContext::class)->set($tenant);
app(TenantConfig::class)->refresh();
$this->assertSame(['versand@vermieter.example', 'Vermieter'], [config('mail.from.address'), config('mail.from.name')]);
}
}
+37
View File
@@ -8,6 +8,7 @@
use App\Filament\Resources\Amenities\AmenityResource;
use App\Filament\Resources\Faqs\FaqResource;
use App\Filament\Resources\Notices\NoticeResource;
use App\Filament\Resources\Photos\Pages\CreatePhoto;
use App\Filament\Resources\Photos\Pages\ListPhotos;
use App\Filament\Resources\Photos\PhotoResource;
use App\Filament\Resources\Properties\PropertyResource;
@@ -87,6 +88,42 @@ public function test_several_photos_are_uploaded_at_once(): void
$this->assertSame(['Wohn zimmer', 'Kueche'], Photo::orderBy('sort_order')->pluck('alt_text')->all());
}
public function test_photo_uploaded_in_the_admin_is_stored_on_the_public_disk(): void
{
Storage::fake('local');
Livewire::test(CreatePhoto::class)
->fillForm([
'image' => [UploadedFile::fake()->image('grundriss.png', 1600, 900)],
'alt_text' => 'Grundriss mit Teppichen',
'category' => PhotoCategory::Apartment,
])
->call('create')
->assertHasNoFormErrors();
$media = Photo::query()->where('alt_text', 'Grundriss mit Teppichen')->sole()->getFirstMedia(Photo::COLLECTION);
$this->assertSame(['public', 'public'], [$media->disk, $media->conversions_disk]);
Storage::disk('public')->assertExists($media->id.'/'.$media->file_name);
$this->assertSame([], Storage::disk('local')->allFiles());
}
public function test_migration_moves_photos_from_the_private_disk_to_the_public_disk(): void
{
Storage::fake('local');
$photo = Photo::factory()->create();
$media = $photo->addMedia(UploadedFile::fake()->image('alt.jpg', 1200, 800))->toMediaCollection(Photo::COLLECTION, 'local');
Storage::disk('local')->assertExists($media->id.'/alt.jpg');
(require database_path('migrations/2026_10_23_171001_move_photo_media_to_the_public_disk.php'))->up();
$media->refresh();
$this->assertSame(['public', 'public'], [$media->disk, $media->conversions_disk]);
Storage::disk('public')->assertExists($media->id.'/alt.jpg');
Storage::disk('public')->assertExists($media->id.'/conversions/alt-lg.webp');
Storage::disk('local')->assertMissing($media->id.'/alt.jpg');
$this->assertStringEndsWith('/conversions/alt-lg.webp', $photo->fresh()->url('lg'));
}
public function test_notices_are_visible_only_within_their_dates(): void
{
$this->travelTo(CarbonImmutable::parse('2026-11-10'));