Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8eae37e11d | ||
|
|
92ccf40312 | ||
|
|
6d8f1d6692 | ||
|
|
abf0e9004b | ||
|
|
3a0bb6e40f | ||
|
|
361acfa12a | ||
|
|
c459f7f83c | ||
|
|
4e66add1f0 | ||
|
|
f686996122 | ||
|
|
2c5b5fc2d7 | ||
|
|
9cd39f791f | ||
|
|
c55937d20e | ||
|
|
c2cf632ad5 | ||
|
|
f2e78446a8 | ||
|
|
03ad4667ac | ||
|
|
d9383cf3e5 | ||
|
|
e0e8c1d856 |
No files matched your search
@@ -1,105 +1,62 @@
|
||||
# Tests on every push; deployment to Strato for tags "v*" or by hand (Gitea › Actions › Deploy › Run workflow).
|
||||
# Needs a Gitea act_runner (e.g. on the private server) and these repository secrets:
|
||||
# DEPLOY_SSH_KEY private key whose public key is stored at Strato (SFTP & SSH)
|
||||
# DEPLOY_HOST package-specific SSH server, e.g. 51539426.ssh.w1.strato.hosting (not ssh.strato.de)
|
||||
# DEPLOY_USER SSH user from the Strato customer login
|
||||
# DEPLOY_PATH e.g. fewo-production
|
||||
# DEPLOY_PHP e.g. /opt/RZphp84/bin/php-cli
|
||||
# DEPLOY_URL e.g. https://www.fewo-stommer.de
|
||||
name: Deploy
|
||||
|
||||
name: Deploy FeWo mit PipelineManager
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ['v*']
|
||||
branches: [develop, main]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
environment:
|
||||
description: Ziel
|
||||
type: choice
|
||||
options: [production, staging]
|
||||
default: production
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
mariadb:
|
||||
image: mariadb:11.8
|
||||
env:
|
||||
MARIADB_DATABASE: fewo_test
|
||||
MARIADB_ROOT_PASSWORD: test
|
||||
ports: ['3306:3306']
|
||||
options: >-
|
||||
--health-cmd="healthcheck.sh --connect --innodb_initialized"
|
||||
--health-interval=5s --health-timeout=5s --health-retries=20
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.4'
|
||||
extensions: mbstring, intl, gd, exif, zip, pdo_sqlite, sqlite3, pdo_mysql, fileinfo, openssl
|
||||
tools: composer:v2
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
cache: npm
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
composer install --no-interaction --no-progress --prefer-dist
|
||||
npm ci --no-audit --no-fund
|
||||
npm run build
|
||||
cp .env.example .env
|
||||
php artisan key:generate
|
||||
|
||||
- name: Tests (SQLite)
|
||||
run: php artisan test --compact
|
||||
|
||||
- name: Tests (MariaDB 11.8, wie auf Strato)
|
||||
env:
|
||||
DB_CONNECTION: mariadb
|
||||
DB_HOST: 127.0.0.1
|
||||
DB_PORT: '3306'
|
||||
DB_DATABASE: fewo_test
|
||||
DB_USERNAME: root
|
||||
DB_PASSWORD: test
|
||||
run: php artisan test --compact
|
||||
|
||||
deploy:
|
||||
needs: test
|
||||
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
|
||||
# Raspi5-Paperless: existing host runner; all PHP/Node work happens inside the image.
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
PIPELINE_IMAGE: pipeline-manager:0.1.0
|
||||
PIPELINE_HOME: /home/lars/docker/pipeline-manager
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.4'
|
||||
extensions: mbstring, intl, gd, exif, zip, fileinfo, openssl
|
||||
tools: composer:v2
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
cache: npm
|
||||
|
||||
- name: SSH key
|
||||
- name: Anwendung im Manager-Container vorbereiten und testen
|
||||
id: build
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
printf '%s\n' "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key
|
||||
chmod 600 ~/.ssh/deploy_key
|
||||
ssh-keyscan -H "${{ secrets.DEPLOY_HOST }}" >> ~/.ssh/known_hosts
|
||||
set -eu
|
||||
case "$GITHUB_REF" in
|
||||
refs/heads/develop) TARGET=staging ;;
|
||||
refs/heads/main) TARGET=production ;;
|
||||
*) echo 'Unzulässiger Branch'; exit 1 ;;
|
||||
esac
|
||||
docker image inspect "$PIPELINE_IMAGE" >/dev/null
|
||||
STATUS=0
|
||||
docker run --rm --user "$(id -u):$(id -g)" \
|
||||
-v "$(pwd -P):/workspace:ro" "$PIPELINE_IMAGE" \
|
||||
pipeline-manager check --environment "$TARGET" || STATUS=$?
|
||||
if [ "$STATUS" = 3 ]; then
|
||||
echo 'enabled=false' >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
test "$STATUS" = 0
|
||||
umask 077
|
||||
mkdir -p "$PIPELINE_HOME/cache/composer" "$PIPELINE_HOME/cache/npm" "$PIPELINE_HOME/backups" .pipeline
|
||||
docker run --rm --user "$(id -u):$(id -g)" --cpus=2 --memory=2g --pids-limit=512 \
|
||||
-e HOME=/tmp \
|
||||
-v "$(pwd -P):/workspace" \
|
||||
-v "$PIPELINE_HOME/cache:/cache" "$PIPELINE_IMAGE" \
|
||||
pipeline-manager prepare
|
||||
echo "target=$TARGET" >> "$GITHUB_OUTPUT"
|
||||
echo 'enabled=true' >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Deploy
|
||||
- name: Sichern und nach Strato übertragen
|
||||
if: steps.build.outputs.enabled == 'true'
|
||||
env:
|
||||
TARGET: ${{ steps.build.outputs.target }}
|
||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
|
||||
DEPLOY_PHP: ${{ secrets.DEPLOY_PHP }}
|
||||
DEPLOY_URL: ${{ secrets.DEPLOY_URL }}
|
||||
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
DEPLOY_KNOWN_HOSTS: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
|
||||
run: |
|
||||
export DEPLOY_SSH_KEY="$HOME/.ssh/deploy_key"
|
||||
bash scripts/deploy.sh "${{ inputs.environment || 'production' }}" deploy
|
||||
set -eu
|
||||
docker run --rm --user "$(id -u):$(id -g)" --cpus=1 --memory=512m --pids-limit=128 \
|
||||
-e GITHUB_REF -e GITHUB_SHA -e DEPLOY_HOST -e DEPLOY_USER -e DEPLOY_SSH_KEY -e DEPLOY_KNOWN_HOSTS \
|
||||
-v "$(pwd -P):/workspace:ro" \
|
||||
-v "$PIPELINE_HOME/backups:/backups" "$PIPELINE_IMAGE" \
|
||||
pipeline-manager deploy --environment "$TARGET" --backup-root /backups
|
||||
@@ -24,6 +24,7 @@
|
||||
/storage/*.key
|
||||
/storage/pail
|
||||
/vendor
|
||||
/.pipeline/
|
||||
_ide_helper.php
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
@@ -32,3 +33,4 @@ Thumbs.db
|
||||
# Deployment settings with access data
|
||||
/scripts/deploy.*.env
|
||||
!/scripts/deploy.example.env
|
||||
storage/app/private/exports/
|
||||
@@ -38,7 +38,7 @@ public static function mailboxIsStale(): bool
|
||||
return false;
|
||||
}
|
||||
|
||||
$lastSuccess = Cache::get(MailboxReader::LAST_SUCCESS_KEY);
|
||||
$lastSuccess = Cache::get(MailboxReader::key(MailboxReader::LAST_SUCCESS_KEY));
|
||||
|
||||
return $lastSuccess === null
|
||||
|| CarbonImmutable::parse($lastSuccess)->lessThan(now()->subMinutes(config('fewo.mailbox.stale_after_minutes')));
|
||||
@@ -56,7 +56,7 @@ private function monitorMailbox(): int
|
||||
return 0;
|
||||
}
|
||||
|
||||
Mail::to(Settings::notificationRecipients())->send(new MailboxAlert(Cache::get(MailboxReader::LAST_ERROR_KEY)));
|
||||
Mail::to(Settings::notificationRecipients())->send(new MailboxAlert(Cache::get(MailboxReader::key(MailboxReader::LAST_ERROR_KEY))));
|
||||
Cache::forever(self::MAILBOX_ALERTED_KEY, true);
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Channels\Mail;
|
||||
|
||||
use App\Channels\ChannelSyncException;
|
||||
use App\Support\Settings;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Throwable;
|
||||
@@ -17,11 +18,31 @@ class MailboxReader
|
||||
{
|
||||
public const LAST_SUCCESS_KEY = 'mailbox:last_success_at';
|
||||
|
||||
/**
|
||||
* The state of one landlord's mailbox. Without the landlord in the key, two landlords would report
|
||||
* each other's last success and alerts would be raised for the wrong one.
|
||||
*/
|
||||
public static function key(string $base): string
|
||||
{
|
||||
return $base.':'.(Settings::tenant()?->id ?? 0);
|
||||
}
|
||||
|
||||
public const LAST_ERROR_KEY = 'mailbox:last_error';
|
||||
|
||||
/**
|
||||
* The mailbox of the current landlord. Each landlord reads their own; an empty one means the fast path
|
||||
* is off for them.
|
||||
*
|
||||
* @return array<string, mixed>|null
|
||||
*/
|
||||
public static function configuration(): ?array
|
||||
{
|
||||
return Settings::tenant()?->mailbox();
|
||||
}
|
||||
|
||||
public static function isConfigured(): bool
|
||||
{
|
||||
return filled(config('fewo.mailbox.host')) && filled(config('fewo.mailbox.username'));
|
||||
return self::configuration() !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,7 +53,11 @@ public static function isConfigured(): bool
|
||||
*/
|
||||
public function fetch(array $senders): array
|
||||
{
|
||||
$config = config('fewo.mailbox');
|
||||
$config = self::configuration();
|
||||
|
||||
if ($config === null) {
|
||||
throw new ChannelSyncException('Für diesen Mandanten ist kein Postfach hinterlegt.');
|
||||
}
|
||||
|
||||
try {
|
||||
$client = (new ClientManager)->make([
|
||||
@@ -62,13 +87,13 @@ public function fetch(array $senders): array
|
||||
|
||||
$client->disconnect();
|
||||
} catch (Throwable $exception) {
|
||||
Cache::forever(self::LAST_ERROR_KEY, $exception->getMessage());
|
||||
Cache::forever(self::key(self::LAST_ERROR_KEY), $exception->getMessage());
|
||||
|
||||
throw new ChannelSyncException('Postfach konnte nicht gelesen werden: '.$exception->getMessage(), previous: $exception);
|
||||
}
|
||||
|
||||
Cache::forever(self::LAST_SUCCESS_KEY, now()->toIso8601String());
|
||||
Cache::forget(self::LAST_ERROR_KEY);
|
||||
Cache::forever(self::key(self::LAST_SUCCESS_KEY), now()->toIso8601String());
|
||||
Cache::forget(self::key(self::LAST_ERROR_KEY));
|
||||
|
||||
return $mails;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\ImageWorlds\ImageWorldManifest;
|
||||
use App\ImageWorlds\ImageWorldRegistry;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
#[Signature('image-worlds:check')]
|
||||
#[Description('Check every picture world: does each slot in the manifest have its SVG file?')]
|
||||
class CheckImageWorlds extends Command
|
||||
{
|
||||
/**
|
||||
* A slot without a file is not an error at runtime – templates simply get no decoration. That makes it
|
||||
* easy to miss, so it is reported here instead of silently leaving a page bare.
|
||||
*/
|
||||
public function handle(ImageWorldRegistry $registry): int
|
||||
{
|
||||
$worlds = $registry->all();
|
||||
|
||||
if ($worlds === []) {
|
||||
$this->warn('Keine Bildwelt gefunden.');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
$incomplete = 0;
|
||||
|
||||
foreach ($worlds as $world) {
|
||||
$missing = $world->missingFiles();
|
||||
|
||||
if ($missing === []) {
|
||||
$this->info(sprintf('✓ %s (%s): %d Plätze', $world->name, $world->key, count($world->slots)));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$incomplete++;
|
||||
$this->error(sprintf('✗ %s (%s): ohne Datei – %s', $world->name, $world->key, implode(', ', $missing)));
|
||||
}
|
||||
|
||||
$this->newLine();
|
||||
$this->line($this->slotOverview($worlds));
|
||||
|
||||
return $incomplete === 0 ? self::SUCCESS : self::FAILURE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Which slot is filled by which world – so a template author sees what they may rely on.
|
||||
*
|
||||
* @param array<string, ImageWorldManifest> $worlds
|
||||
*/
|
||||
private function slotOverview(array $worlds): string
|
||||
{
|
||||
$slots = [];
|
||||
|
||||
foreach ($worlds as $world) {
|
||||
foreach (array_keys($world->slots) as $slot) {
|
||||
$slots[$slot][] = $world->key;
|
||||
}
|
||||
}
|
||||
|
||||
ksort($slots);
|
||||
|
||||
return collect($slots)
|
||||
->map(fn (array $keys, string $slot): string => sprintf(' %-18s %s', $slot, implode(', ', $keys)))
|
||||
->implode(PHP_EOL);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Tenancy\TenantArchive;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use function Laravel\Prompts\confirm;
|
||||
|
||||
#[Signature('tenants:delete {slug : Kurzname des Mandanten} {--keep-export : Nicht vorher exportieren} {--force : Ohne Rückfrage}')]
|
||||
#[Description('Export a landlord and then remove them with all their data and files')]
|
||||
class DeleteTenant extends Command
|
||||
{
|
||||
/**
|
||||
* Exports first, unless told otherwise: a deletion that cannot be undone should leave something behind.
|
||||
*/
|
||||
public function handle(TenantArchive $archive): int
|
||||
{
|
||||
$tenant = Tenant::query()->where('slug', $this->argument('slug'))->first();
|
||||
|
||||
if ($tenant === null) {
|
||||
$this->error('Kein Mandant mit dem Kurznamen '.$this->argument('slug').'.');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
if (! $this->option('keep-export')) {
|
||||
$path = $archive->export($tenant, storage_path('app/private/exports'));
|
||||
$this->info('Export geschrieben: '.$path);
|
||||
}
|
||||
|
||||
if (! $this->option('force') && ! confirm('Mandant '.$tenant->name.' mit allen Daten und Dateien endgültig löschen?', default: false)) {
|
||||
$this->line('Abgebrochen.');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
$removed = $archive->delete($tenant);
|
||||
|
||||
foreach ($removed as $table => $count) {
|
||||
$this->line(sprintf(' %-22s %d', $table, $count));
|
||||
}
|
||||
|
||||
$this->info('Mandant '.$tenant->name.' gelöscht.');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -3,22 +3,26 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Actions\ExpireReservations;
|
||||
use App\Models\Tenant;
|
||||
use App\Tenancy\TenantRunner;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
#[Signature('bookings:expire-holds')]
|
||||
#[Description('Mark reservations with an elapsed hold time as expired and notify the landlord')]
|
||||
#[Description('Mark reservations with an elapsed hold time as expired and notify the landlord – once per landlord')]
|
||||
class ExpireReservationHolds extends Command
|
||||
{
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(ExpireReservations $expireReservations): int
|
||||
public function handle(ExpireReservations $expireReservations, TenantRunner $runner): int
|
||||
{
|
||||
$count = $expireReservations->handle();
|
||||
$runner->each(function (Tenant $tenant) use ($expireReservations): void {
|
||||
$count = $expireReservations->handle();
|
||||
|
||||
$this->info("{$count} Vormerkung(en) abgelaufen.");
|
||||
$this->info("{$tenant->name}: {$count} Vormerkung(en) abgelaufen.");
|
||||
});
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Tenancy\TenantArchive;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
#[Signature('tenants:export {slug : Kurzname des Mandanten} {--to= : Zielordner, sonst storage/app/private/exports}')]
|
||||
#[Description('Write all data and files of one landlord into a zip archive')]
|
||||
class ExportTenant extends Command
|
||||
{
|
||||
public function handle(TenantArchive $archive): int
|
||||
{
|
||||
$tenant = Tenant::query()->where('slug', $this->argument('slug'))->first();
|
||||
|
||||
if ($tenant === null) {
|
||||
$this->error('Kein Mandant mit dem Kurznamen '.$this->argument('slug').'.');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$path = $archive->export($tenant, (string) ($this->option('to') ?: storage_path('app/private/exports')));
|
||||
|
||||
$this->info('Export von '.$tenant->name.': '.$path.' ('.$this->size($path).')');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
private function size(string $path): string
|
||||
{
|
||||
$bytes = (int) (filesize($path) ?: 0);
|
||||
|
||||
return $bytes > 1048576
|
||||
? round($bytes / 1048576, 1).' MB'
|
||||
: round($bytes / 1024).' KB';
|
||||
}
|
||||
}
|
||||
@@ -7,53 +7,64 @@
|
||||
use App\Channels\Mail\MailboxReader;
|
||||
use App\Enums\TenantServiceKey;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Tenant;
|
||||
use App\Tenancy\TenantFeatures;
|
||||
use App\Tenancy\TenantRunner;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
#[Signature('channels:fetch-mail')]
|
||||
#[Description('Read booking notifications of the portals from the mailbox and block recognised bookings immediately')]
|
||||
#[Description('Read booking notifications of the portals from each landlord\'s mailbox and block recognised bookings immediately')]
|
||||
class FetchPortalMail extends Command
|
||||
{
|
||||
/**
|
||||
* Execute the console command.
|
||||
* Execute the console command. Every landlord has their own mailbox, so every landlord gets their own
|
||||
* run – one landlord's credentials are never used to read another one's mail.
|
||||
*/
|
||||
public function handle(MailboxReader $reader, ProcessPortalMail $processPortalMail): int
|
||||
public function handle(MailboxReader $reader, ProcessPortalMail $processPortalMail, TenantRunner $runner): int
|
||||
{
|
||||
if (! MailboxReader::isConfigured()) {
|
||||
$this->line('Kein Postfach konfiguriert (FEWO_MAILBOX_HOST).');
|
||||
$runner->each(fn (Tenant $tenant) => $this->fetchForCurrentLandlord($reader, $processPortalMail, $tenant));
|
||||
|
||||
return self::SUCCESS;
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
private function fetchForCurrentLandlord(MailboxReader $reader, ProcessPortalMail $processPortalMail, Tenant $tenant): void
|
||||
{
|
||||
if (! app(TenantFeatures::class)->enabled(TenantServiceKey::PortalMail, $tenant)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! MailboxReader::isConfigured()) {
|
||||
$this->line("{$tenant->name}: kein Postfach hinterlegt.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$senders = Channel::query()->active()->get()
|
||||
->filter(fn (Channel $channel): bool => app(TenantFeatures::class)->enabled(TenantServiceKey::PortalMail, $channel->tenant))
|
||||
->flatMap(fn (Channel $channel): array => $processPortalMail->senders($channel))
|
||||
->unique()
|
||||
->values()
|
||||
->all();
|
||||
|
||||
if ($senders === []) {
|
||||
$this->line('Für kein Portal sind Absender hinterlegt.');
|
||||
$this->line("{$tenant->name}: für kein Portal sind Absender hinterlegt.");
|
||||
|
||||
return self::SUCCESS;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$mails = $reader->fetch($senders);
|
||||
} catch (ChannelSyncException $exception) {
|
||||
$this->error($exception->getMessage());
|
||||
$this->error("{$tenant->name}: {$exception->getMessage()}");
|
||||
|
||||
return self::FAILURE;
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($mails as $mail) {
|
||||
if ($record = $processPortalMail->handle($mail)) {
|
||||
$this->info("{$record->channel->name}: {$record->type->getLabel()} → {$record->status->getLabel()} ({$record->subject})");
|
||||
$this->info("{$tenant->name} – {$record->channel->name}: {$record->type->getLabel()} → {$record->status->getLabel()} ({$record->subject})");
|
||||
}
|
||||
}
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -4,18 +4,27 @@
|
||||
|
||||
use App\Actions\SyncChannel;
|
||||
use App\Models\Channel;
|
||||
use App\Tenancy\TenantRunner;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
#[Signature('channels:sync {channel? : ID of a single channel}')]
|
||||
#[Description('Import the occupations of all active portals (or one) and report conflicts')]
|
||||
#[Description('Import the occupations of all active portals (or one) and report conflicts – once per landlord')]
|
||||
class SyncChannels extends Command
|
||||
{
|
||||
/**
|
||||
* Execute the console command.
|
||||
* Execute the console command. Runs per landlord so that conflict mails carry the right sender and
|
||||
* reach the right people.
|
||||
*/
|
||||
public function handle(SyncChannel $syncChannel): int
|
||||
public function handle(SyncChannel $syncChannel, TenantRunner $runner): int
|
||||
{
|
||||
$runner->each(fn () => $this->syncCurrentLandlord($syncChannel));
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
private function syncCurrentLandlord(SyncChannel $syncChannel): void
|
||||
{
|
||||
$channels = Channel::query()->active()
|
||||
->when($this->argument('channel'), fn ($query, $id) => $query->whereKey($id))
|
||||
@@ -29,7 +38,5 @@ public function handle(SyncChannel $syncChannel): int
|
||||
? $this->info("✓ {$channel->name}: {$log->events} Belegungen, +{$log->added} ~{$log->changed} -{$log->removed}, Konflikte: {$log->conflicts}")
|
||||
: $this->error("✗ {$channel->name}: {$log->message}");
|
||||
}
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Documents;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\Site;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
@@ -22,7 +23,15 @@ public function generate(Booking $booking, bool $draft = false): string
|
||||
? "contracts/Angebot-{$booking->reference}-v{$booking->offer_version}.pdf"
|
||||
: "contracts/Mietvertrag-{$booking->reference}.pdf";
|
||||
|
||||
Storage::disk(self::DISK)->put($path, Pdf::loadView('pdf.contract', ['booking' => $booking, 'draft' => $draft])->setPaper('a4')->output());
|
||||
// The logo is embedded as a file: the PDF is rendered on the server and must not depend on
|
||||
// fetching anything over the network. Each website has its own (A14).
|
||||
$logo = $booking->website()?->brandPath(Site::BRAND_DOCUMENT_LOGO);
|
||||
|
||||
Storage::disk(self::DISK)->put($path, Pdf::loadView('pdf.contract', [
|
||||
'booking' => $booking,
|
||||
'draft' => $draft,
|
||||
'logo' => $logo,
|
||||
])->setPaper('a4')->output());
|
||||
$booking->update([$draft ? 'offer_path' : 'contract_path' => $path]);
|
||||
|
||||
return $path;
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
* The service switches of the tenant form. They live in their own table, so the form state is read and
|
||||
* written separately from the landlord's own columns. Only wired services are written – a switch for a
|
||||
* service nothing asks about would promise something that does not happen.
|
||||
*
|
||||
* Holds no Filament hooks; EditsTenantSetup calls these.
|
||||
*/
|
||||
trait EditsTenantServices
|
||||
{
|
||||
@@ -17,7 +19,7 @@ trait EditsTenantServices
|
||||
* @param array<string, mixed> $data
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function mutateFormDataBeforeFill(array $data): array
|
||||
private function fillServices(array $data): array
|
||||
{
|
||||
$tenant = $this->record;
|
||||
|
||||
@@ -40,35 +42,7 @@ protected function mutateFormDataBeforeFill(array $data): array
|
||||
* @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
|
||||
private function takeServices(array $data): array
|
||||
{
|
||||
$this->services = is_array($data['services'] ?? null) ? $data['services'] : [];
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Operator\Concerns;
|
||||
|
||||
/**
|
||||
* Everything the operator sets up for a landlord that does not live in the tenants table itself:
|
||||
* the websites with their entry addresses, and the services that are unlocked.
|
||||
*/
|
||||
trait EditsTenantSetup
|
||||
{
|
||||
use EditsTenantServices;
|
||||
use EditsTenantWebsites;
|
||||
|
||||
/** @var array<string, array<string, mixed>> */
|
||||
public array $services = [];
|
||||
|
||||
/** @var list<array<string, mixed>> */
|
||||
public array $websites = [];
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function mutateFormDataBeforeFill(array $data): array
|
||||
{
|
||||
return $this->fillWebsites($this->fillServices($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
return $this->takeWebsites($this->takeServices($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function mutateFormDataBeforeSave(array $data): array
|
||||
{
|
||||
return $this->takeWebsites($this->takeServices($data));
|
||||
}
|
||||
|
||||
protected function afterCreate(): void
|
||||
{
|
||||
$this->saveServices();
|
||||
$this->saveWebsites();
|
||||
}
|
||||
|
||||
protected function afterSave(): void
|
||||
{
|
||||
$this->saveServices();
|
||||
$this->saveWebsites();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Operator\Concerns;
|
||||
|
||||
use App\Models\Page;
|
||||
use App\Models\Site;
|
||||
use App\Models\SiteDomain;
|
||||
use App\Models\Tenant;
|
||||
use App\Tenancy\TenantContext;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
/**
|
||||
* The websites of a landlord and the addresses they answer on. These belong to the operator: the webspace
|
||||
* and the hosting are the operator's, and a landlord must not be able to point an address at themselves.
|
||||
*
|
||||
* Wiring a new domain to this directory stays a manual step at the hoster. What is kept here is the other
|
||||
* half: which host belongs to which website, and through it to which landlord.
|
||||
*
|
||||
* Holds no Filament hooks; EditsTenantSetup calls these.
|
||||
*/
|
||||
trait EditsTenantWebsites
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function fillWebsites(array $data): array
|
||||
{
|
||||
$tenant = $this->record;
|
||||
|
||||
if (! $tenant instanceof Tenant) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
$data['websites'] = $tenant->sites()->withoutGlobalScope('tenant')->with('domains')->get()
|
||||
->map(fn (Site $site): array => [
|
||||
'id' => $site->id,
|
||||
'name' => $site->name,
|
||||
'hosts' => $site->domains->pluck('host')->all(),
|
||||
])
|
||||
->all();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function takeWebsites(array $data): array
|
||||
{
|
||||
$this->websites = is_array($data['websites'] ?? null) ? array_values($data['websites']) : [];
|
||||
|
||||
$this->normaliseWebsites();
|
||||
|
||||
unset($data['websites']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans the entered addresses and refuses what already belongs elsewhere, before anything is written.
|
||||
*/
|
||||
private function normaliseWebsites(): void
|
||||
{
|
||||
$seen = [];
|
||||
|
||||
foreach ($this->websites as $index => $website) {
|
||||
$hosts = [];
|
||||
|
||||
foreach ((array) ($website['hosts'] ?? []) as $host) {
|
||||
$host = SiteDomain::normalise(is_string($host) ? $host : null);
|
||||
|
||||
if ($host === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($host, $seen, true)) {
|
||||
throw ValidationException::withMessages([
|
||||
'data.websites' => 'Die Adresse '.$host.' ist mehrfach eingetragen.',
|
||||
]);
|
||||
}
|
||||
|
||||
$seen[] = $host;
|
||||
$hosts[] = $host;
|
||||
}
|
||||
|
||||
$this->websites[$index]['hosts'] = $hosts;
|
||||
}
|
||||
|
||||
$this->refuseForeignHosts($seen);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $hosts
|
||||
*/
|
||||
private function refuseForeignHosts(array $hosts): void
|
||||
{
|
||||
$ownIds = collect($this->websites)->pluck('id')->filter()->all();
|
||||
|
||||
$taken = SiteDomain::query()
|
||||
->whereIn('host', $hosts)
|
||||
->whereNotIn('site_id', $ownIds ?: [0])
|
||||
->pluck('host');
|
||||
|
||||
if ($taken->isNotEmpty()) {
|
||||
throw ValidationException::withMessages([
|
||||
'data.websites' => 'Gehört bereits zu einer anderen Website: '.$taken->implode(', '),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the websites. A website that is new gets an empty home page straight away, because a website
|
||||
* without one answers 404 and the landlord would have no way in.
|
||||
*/
|
||||
private function saveWebsites(): void
|
||||
{
|
||||
$tenant = $this->record;
|
||||
|
||||
if (! $tenant instanceof Tenant) {
|
||||
return;
|
||||
}
|
||||
|
||||
app(TenantContext::class)->run($tenant, function () use ($tenant): void {
|
||||
$keep = [];
|
||||
|
||||
foreach ($this->websites as $website) {
|
||||
$name = trim((string) ($website['name'] ?? ''));
|
||||
|
||||
if ($name === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$hosts = (array) ($website['hosts'] ?? []);
|
||||
$site = $this->siteFor($tenant, $website['id'] ?? null, $name, $hosts);
|
||||
|
||||
$keep[] = $site->id;
|
||||
|
||||
$site->domains()->whereNotIn('host', $hosts ?: [''])->delete();
|
||||
|
||||
foreach ($hosts as $host) {
|
||||
SiteDomain::query()->updateOrCreate(['host' => $host], ['site_id' => $site->id]);
|
||||
}
|
||||
}
|
||||
|
||||
$tenant->sites()->whereNotIn('id', $keep ?: [0])->each(fn (Site $site) => $site->delete());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $hosts
|
||||
*/
|
||||
private function siteFor(Tenant $tenant, mixed $id, string $name, array $hosts): Site
|
||||
{
|
||||
$site = $id ? Site::query()->whereKey($id)->first() : null;
|
||||
|
||||
if ($site !== null) {
|
||||
$site->update(['name' => $name, 'domain' => $hosts[0] ?? null]);
|
||||
|
||||
return $site;
|
||||
}
|
||||
|
||||
$site = Site::query()->create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'name' => $name,
|
||||
'domain' => $hosts[0] ?? null,
|
||||
'is_default' => $tenant->sites()->count() === 0,
|
||||
'theme' => config('themes.base'),
|
||||
]);
|
||||
|
||||
Page::query()->create([
|
||||
'site_id' => $site->id,
|
||||
'slug' => Page::HOME,
|
||||
'title' => $name,
|
||||
'sections' => [],
|
||||
'is_published' => true,
|
||||
]);
|
||||
|
||||
return $site;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Operator\Pages;
|
||||
|
||||
use App\Support\SystemSettings;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas\Components\Actions;
|
||||
use Filament\Schemas\Components\EmbeddedSchema;
|
||||
use Filament\Schemas\Components\Form;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Text;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
|
||||
/**
|
||||
* The settings of the whole installation. They are the baseline every landlord is bound by, and a
|
||||
* landlord's admin never reaches this page.
|
||||
*
|
||||
* Empty means: the value from the server's .env applies again. Database credentials and APP_KEY are not
|
||||
* here and cannot be – they are needed to open the database and to decrypt what is stored in it.
|
||||
*/
|
||||
class SystemSettingsPage extends Page
|
||||
{
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedAdjustmentsHorizontal;
|
||||
|
||||
protected static ?string $navigationLabel = 'Einstellungen';
|
||||
|
||||
protected static ?string $title = 'Systemweite Einstellungen';
|
||||
|
||||
protected static ?string $slug = 'einstellungen';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
/** @var array<string, mixed> */
|
||||
public array $data = [];
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->form->fill(collect(SystemSettings::EDITABLE)
|
||||
->mapWithKeys(fn (array $definition, string $key): array => [self::field($key) => SystemSettings::get($key)])
|
||||
->all());
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
$sections = collect(SystemSettings::EDITABLE)
|
||||
->groupBy(fn (array $definition): string => $definition[2], preserveKeys: true)
|
||||
->map(fn ($group, string $section) => Section::make($section)
|
||||
->columns(2)
|
||||
->schema($group->keys()->map(fn (string $key) => $this->field_($key))->all()));
|
||||
|
||||
return $schema
|
||||
->statePath('data')
|
||||
->components([
|
||||
Text::make('Leer lassen heißt: der Wert aus der .env des Servers gilt wieder. Datenbank-Zugang und APP_KEY stehen bewusst nicht hier – sie werden gebraucht, um die Datenbank überhaupt zu öffnen und das Gespeicherte zu entschlüsseln.'),
|
||||
...$sections->values()->all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function content(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
Form::make([EmbeddedSchema::make('form')])
|
||||
->id('form')
|
||||
->livewireSubmitHandler('save')
|
||||
->footer([Actions::make([Action::make('save')->label('Speichern')->submit('save')])]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
$data = $this->form->getState();
|
||||
|
||||
SystemSettings::save(collect(SystemSettings::EDITABLE)
|
||||
->mapWithKeys(fn (array $definition, string $key): array => [$key => $data[self::field($key)] ?? null])
|
||||
->all());
|
||||
|
||||
Notification::make()->title('Gespeichert')->success()->send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Config keys contain dots, which Filament would read as nesting.
|
||||
*/
|
||||
private static function field(string $key): string
|
||||
{
|
||||
return str_replace('.', '__', $key);
|
||||
}
|
||||
|
||||
private function field_(string $key): TextInput|Select
|
||||
{
|
||||
[$label, $kind, , $help] = SystemSettings::EDITABLE[$key];
|
||||
$name = self::field($key);
|
||||
|
||||
if ($kind === 'mailer') {
|
||||
return Select::make($name)
|
||||
->label($label)
|
||||
->helperText($help)
|
||||
->options(['smtp' => 'SMTP (echter Versand)', 'log' => 'Nur Logdatei (kein Versand)', 'array' => 'Verwerfen (nur für Tests)']);
|
||||
}
|
||||
|
||||
$field = TextInput::make($name)->label($label)->helperText($help);
|
||||
|
||||
return match ($kind) {
|
||||
'int' => $field->numeric()->integer()->minValue(0),
|
||||
'secret' => $field->password()->revealable()->autocomplete(false),
|
||||
default => $field,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,10 @@
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\TagsInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Resources\Resource;
|
||||
@@ -52,9 +56,38 @@ public static function form(Schema $schema): Schema
|
||||
->unique(ignoreRecord: true)
|
||||
->maxLength(255),
|
||||
Toggle::make('is_active')
|
||||
->label('Aktiv')
|
||||
->helperText('Ein gesperrter Mandant ist von außen nicht mehr erreichbar. Der Betreiber kommt weiter hinein.')
|
||||
->default(true),
|
||||
->label('Zugang freigeschaltet')
|
||||
->helperText('Ausgeschaltet sehen Besucher statt der Webseite nur den Hinweis unten. Der Betreiber kommt weiter hinein.')
|
||||
->default(true)
|
||||
->live(),
|
||||
Textarea::make('suspended_message')
|
||||
->label('Hinweis bei gesperrtem Zugang')
|
||||
->placeholder('Diese Webseite ist zurzeit nicht erreichbar. Bitte versuchen Sie es später noch einmal.')
|
||||
->helperText('Leer = der Standardtext. Wird mit Status 503 ausgeliefert, damit Suchmaschinen die Seite nicht aus dem Index werfen.')
|
||||
->rows(2)
|
||||
->columnSpanFull(),
|
||||
Section::make('Einsprungsadressen')
|
||||
->description('Unter welchen Adressen dieser Mandant antwortet. Die Adresse muss zusätzlich beim Hoster einmalig auf dieses Verzeichnis gelegt werden – das passiert nicht hier. Ab dem zweiten Mandanten bekommt jede nicht eingetragene Adresse eine Fehlerseite.')
|
||||
->columnSpanFull()
|
||||
->schema([
|
||||
Repeater::make('websites')
|
||||
->label('Websites')
|
||||
->addActionLabel('Weitere Website')
|
||||
->defaultItems(1)
|
||||
->itemLabel(fn (array $state): ?string => $state['name'] ?? null)
|
||||
->schema([
|
||||
Hidden::make('id'),
|
||||
TextInput::make('name')
|
||||
->label('Name der Website')
|
||||
->required()
|
||||
->maxLength(120),
|
||||
TagsInput::make('hosts')
|
||||
->label('Adressen')
|
||||
->placeholder('beispiel.de')
|
||||
->helperText('Jede Schreibweise ist eine eigene Adresse: „www.beispiel.de“ und „beispiel.de“ sind zwei. Die erste gilt als Hauptadresse und steht in Links an Gäste.')
|
||||
->nestedRecursiveRules(['string', 'max:190']),
|
||||
]),
|
||||
]),
|
||||
Section::make('Dienste')
|
||||
->description('Was dieser Mandant nutzen darf. Ein gesperrter Dienst verschwindet auch aus seinem Admin – die Rolle eines Benutzers kann das nicht aufwiegen.')
|
||||
->columnSpanFull()
|
||||
|
||||
@@ -2,16 +2,13 @@
|
||||
|
||||
namespace App\Filament\Operator\Tenants\Pages;
|
||||
|
||||
use App\Filament\Operator\Concerns\EditsTenantServices;
|
||||
use App\Filament\Operator\Concerns\EditsTenantSetup;
|
||||
use App\Filament\Operator\TenantResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTenant extends CreateRecord
|
||||
{
|
||||
use EditsTenantServices;
|
||||
use EditsTenantSetup;
|
||||
|
||||
protected static string $resource = TenantResource::class;
|
||||
|
||||
/** @var array<string, array<string, mixed>> */
|
||||
public array $services = [];
|
||||
}
|
||||
@@ -2,16 +2,13 @@
|
||||
|
||||
namespace App\Filament\Operator\Tenants\Pages;
|
||||
|
||||
use App\Filament\Operator\Concerns\EditsTenantServices;
|
||||
use App\Filament\Operator\Concerns\EditsTenantSetup;
|
||||
use App\Filament\Operator\TenantResource;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTenant extends EditRecord
|
||||
{
|
||||
use EditsTenantServices;
|
||||
use EditsTenantSetup;
|
||||
|
||||
protected static string $resource = TenantResource::class;
|
||||
|
||||
/** @var array<string, array<string, mixed>> */
|
||||
public array $services = [];
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Filament\Operator\TenantResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class ListTenants extends ListRecords
|
||||
{
|
||||
@@ -13,7 +14,9 @@ class ListTenants extends ListRecords
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
CreateAction::make()
|
||||
->label('Neuen Mandanten anlegen')
|
||||
->icon(Heroicon::OutlinedPlus),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,17 @@
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Enums\TenantServiceKey;
|
||||
use App\Enums\UserRole;
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
use App\Models\Tenant;
|
||||
use App\Support\Settings;
|
||||
use App\Tenancy\TenantConfig;
|
||||
use App\Tenancy\TenantFeatures;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TagsInput;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
@@ -90,6 +93,12 @@ public function mount(): void
|
||||
'bank_iban' => $tenant->bank_iban,
|
||||
'bank_bic' => $tenant->bank_bic,
|
||||
'tax_note' => $tenant->tax_note,
|
||||
'mailbox_host' => $tenant->mailbox_host,
|
||||
'mailbox_port' => $tenant->mailbox_port,
|
||||
'mailbox_username' => $tenant->mailbox_username,
|
||||
'mailbox_password' => $tenant->mailbox_password,
|
||||
'mailbox_encryption' => $tenant->mailbox_encryption,
|
||||
'mailbox_folder' => $tenant->mailbox_folder,
|
||||
...$this->periodValues($tenant),
|
||||
]);
|
||||
}
|
||||
@@ -172,6 +181,22 @@ public function form(Schema $schema): Schema
|
||||
->maxLength(255)
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
Section::make('Portal-Postfach')
|
||||
->description('Aus diesem Postfach werden die Buchungsmails der Portale gelesen, damit ein Termin sofort gesperrt wird. Leerer Server = ausgeschaltet. Das Passwort liegt verschlüsselt in der Datenbank.')
|
||||
->columns(2)
|
||||
->collapsed()
|
||||
->visible(fn (): bool => app(TenantFeatures::class)->enabled(TenantServiceKey::PortalMail))
|
||||
->schema([
|
||||
TextInput::make('mailbox_host')->label('IMAP-Server')->maxLength(190),
|
||||
TextInput::make('mailbox_port')->label('Port')->numeric()->integer()->placeholder('993'),
|
||||
TextInput::make('mailbox_username')->label('Benutzer')->maxLength(190),
|
||||
TextInput::make('mailbox_password')->label('Passwort')->password()->revealable()->autocomplete(false)->maxLength(190),
|
||||
Select::make('mailbox_encryption')
|
||||
->label('Verschlüsselung')
|
||||
->options(['ssl' => 'SSL', 'tls' => 'TLS', 'starttls' => 'STARTTLS'])
|
||||
->placeholder('SSL'),
|
||||
TextInput::make('mailbox_folder')->label('Ordner')->placeholder('INBOX')->maxLength(190),
|
||||
]),
|
||||
Section::make('Fristen und Grenzen')
|
||||
->description('Leer bedeutet: die Vorgabe des Systems gilt. Löschfristen und Bot-Schutz lassen sich verschärfen, aber nicht über die Vorgabe hinaus lockern.')
|
||||
->columns(3)
|
||||
@@ -212,6 +237,12 @@ public function save(): void
|
||||
'bank_iban' => $data['bank_iban'] ?? null,
|
||||
'bank_bic' => $data['bank_bic'] ?? null,
|
||||
'tax_note' => $data['tax_note'] ?? null,
|
||||
'mailbox_host' => $data['mailbox_host'] ?? null,
|
||||
'mailbox_port' => filled($data['mailbox_port'] ?? null) ? (int) $data['mailbox_port'] : null,
|
||||
'mailbox_username' => $data['mailbox_username'] ?? null,
|
||||
'mailbox_password' => $data['mailbox_password'] ?? null,
|
||||
'mailbox_encryption' => $data['mailbox_encryption'] ?? null,
|
||||
'mailbox_folder' => $data['mailbox_folder'] ?? null,
|
||||
...array_map(fn (mixed $value): ?int => filled($value) ? (int) $value : null, $this->periodInput($data)),
|
||||
]);
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public static function configure(Schema $schema): Schema
|
||||
->schema([
|
||||
Builder::make('sections')
|
||||
->hiddenLabel()
|
||||
->blocks(fn (): array => app(SectionRegistry::class)->blocks())
|
||||
->blocks(fn (callable $get): array => app(SectionRegistry::class)->blocks($get('site_id')))
|
||||
->addActionLabel('Baustein hinzufügen')
|
||||
->collapsible()
|
||||
->collapsed()
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\Properties\Schemas;
|
||||
|
||||
use App\Filament\Forms\Components\EuroInput;
|
||||
use App\ImageWorlds\ImageWorldRegistry;
|
||||
use App\Models\Site;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
@@ -52,6 +53,11 @@ public static function configure(Schema $schema): Schema
|
||||
->label('Website')
|
||||
->options(fn (): array => Site::query()->pluck('name', 'id')->all())
|
||||
->placeholder('keine'),
|
||||
Select::make('image_world')
|
||||
->label('Bildwelt')
|
||||
->options(fn (): array => app(ImageWorldRegistry::class)->options())
|
||||
->placeholder('wie die Website')
|
||||
->helperText('Nur setzen, wenn diese Wohnung anders aussehen soll als die Website – etwa eine Bergwohnung auf einer Küsten-Website.'),
|
||||
Toggle::make('is_active')
|
||||
->label('Aktiv (auf der Webseite buchbar)')
|
||||
->default(true),
|
||||
|
||||
@@ -3,13 +3,11 @@
|
||||
namespace App\Filament\Resources\Sites\Concerns;
|
||||
|
||||
use App\Models\Site;
|
||||
use App\Models\SiteDomain;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
/**
|
||||
* The further hostnames of a website. The field "Domain" stays the main address used for guest links;
|
||||
* everything entered here answers as well. Needed as soon as there is a second landlord, because from
|
||||
* then on an unknown host is a 404 and "www" is a host of its own.
|
||||
* Shows the hostnames of a website in the landlord's admin. Read only: addresses are given out by the
|
||||
* operator, because every address also has to be wired to this directory at the hoster, and because a
|
||||
* landlord must not be able to point somebody else's address at their own website.
|
||||
*/
|
||||
trait EditsSiteHosts
|
||||
{
|
||||
@@ -25,112 +23,11 @@ protected function mutateFormDataBeforeFill(array $data): array
|
||||
return $data;
|
||||
}
|
||||
|
||||
$primary = SiteDomain::normalise($site->domain);
|
||||
|
||||
$data['extra_hosts'] = $site->domains()
|
||||
->where('host', '!=', (string) $site->domain)
|
||||
->pluck('host')
|
||||
->reject(fn (string $host): bool => $host === $primary)
|
||||
->values()
|
||||
->all();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
return $this->withoutHosts($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function mutateFormDataBeforeSave(array $data): array
|
||||
{
|
||||
return $this->withoutHosts($data);
|
||||
}
|
||||
|
||||
protected function afterCreate(): void
|
||||
{
|
||||
$this->saveHosts();
|
||||
}
|
||||
|
||||
protected function afterSave(): void
|
||||
{
|
||||
$this->saveHosts();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function withoutHosts(array $data): array
|
||||
{
|
||||
$hosts = is_array($data['extra_hosts'] ?? null) ? $data['extra_hosts'] : [];
|
||||
|
||||
$this->extraHosts = array_values(array_filter(array_map(
|
||||
fn (mixed $host): string => SiteDomain::normalise(is_string($host) ? $host : null),
|
||||
$hosts,
|
||||
)));
|
||||
|
||||
$this->refuseForeignHosts();
|
||||
|
||||
unset($data['extra_hosts']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* A hostname that already answers for another website must not be taken over – otherwise one landlord
|
||||
* could pull another landlord's visitors onto their own site just by typing that address here.
|
||||
*/
|
||||
private function refuseForeignHosts(): void
|
||||
{
|
||||
$site = $this->record;
|
||||
|
||||
$taken = SiteDomain::query()
|
||||
->whereIn('host', $this->extraHosts)
|
||||
->when($site instanceof Site, fn ($query) => $query->where('site_id', '!=', $site->id))
|
||||
->pluck('host');
|
||||
|
||||
if ($taken->isNotEmpty()) {
|
||||
throw ValidationException::withMessages([
|
||||
'data.extra_hosts' => 'Gehört bereits zu einer anderen Website: '.$taken->implode(', '),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
private function saveHosts(): void
|
||||
{
|
||||
$site = $this->record;
|
||||
|
||||
if (! $site instanceof Site) {
|
||||
return;
|
||||
}
|
||||
|
||||
$primary = SiteDomain::normalise($site->domain);
|
||||
|
||||
$wanted = collect($this->extraHosts)
|
||||
->filter()
|
||||
->when(filled($primary), fn ($hosts) => $hosts->push($primary))
|
||||
->unique()
|
||||
->values();
|
||||
|
||||
$site->domains()->whereNotIn('host', $wanted->all())->delete();
|
||||
|
||||
foreach ($wanted as $host) {
|
||||
// Never take a host away from another website: that would hand one landlord's visitors to another.
|
||||
$owner = SiteDomain::query()->where('host', $host)->value('site_id');
|
||||
|
||||
if ($owner !== null && $owner !== $site->id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SiteDomain::query()->updateOrCreate(['host' => $host], ['site_id' => $site->id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,10 @@
|
||||
|
||||
namespace App\Filament\Resources\Sites\Pages;
|
||||
|
||||
use App\Filament\Resources\Sites\Concerns\EditsSiteHosts;
|
||||
use App\Filament\Resources\Sites\SiteResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateSite extends CreateRecord
|
||||
{
|
||||
use EditsSiteHosts;
|
||||
|
||||
protected static string $resource = SiteResource::class;
|
||||
|
||||
/** @var list<string> */
|
||||
public array $extraHosts = [];
|
||||
}
|
||||
@@ -13,9 +13,6 @@ class EditSite extends EditRecord
|
||||
|
||||
protected static string $resource = SiteResource::class;
|
||||
|
||||
/** @var list<string> */
|
||||
public array $extraHosts = [];
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
namespace App\Filament\Resources\Sites\Schemas;
|
||||
|
||||
use App\Filament\Resources\Appearances\Schemas\AppearanceForm;
|
||||
use App\ImageWorlds\ImageWorldRegistry;
|
||||
use App\Models\Site;
|
||||
use App\Themes\ThemeRegistry;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
|
||||
use Filament\Forms\Components\TagsInput;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
@@ -28,15 +30,14 @@ public static function configure(Schema $schema): Schema
|
||||
TextInput::make('name')->label('Name')->required()->maxLength(120),
|
||||
TextInput::make('domain')
|
||||
->label('Hauptadresse')
|
||||
->placeholder('www.fewo-stommer.de')
|
||||
->helperText('Steht in Links an Gäste. Leer = Standard-Website, solange es nur diesen Mandanten gibt. Ab dem zweiten Mandanten antwortet nur eine eingetragene Adresse, alles andere bekommt 404.')
|
||||
->unique(ignoreRecord: true)
|
||||
->maxLength(190),
|
||||
->helperText('Steht in Links an Gäste. Adressen werden vom Betreiber vergeben, weil sie beim Hoster eingerichtet werden müssen.')
|
||||
->disabled()
|
||||
->dehydrated(false),
|
||||
TagsInput::make('extra_hosts')
|
||||
->label('Weitere Adressen')
|
||||
->placeholder('stommer.info')
|
||||
->helperText('Jede Schreibweise ist eine eigene Adresse: „www.beispiel.de“ und „beispiel.de“ sind zwei. Alle hier eingetragenen liefern dieselbe Website. Enter nach jeder Adresse.')
|
||||
->nestedRecursiveRules(['string', 'max:190'])
|
||||
->label('Antwortet außerdem auf')
|
||||
->placeholder('keine weitere Adresse')
|
||||
->disabled()
|
||||
->dehydrated(false)
|
||||
->columnSpanFull(),
|
||||
Select::make('theme')
|
||||
->label('Theme')
|
||||
@@ -51,8 +52,35 @@ public static function configure(Schema $schema): Schema
|
||||
->icon('heroicon-o-eye')
|
||||
->url(fn (Get $get): string => URL::temporarySignedRoute('home', now()->addDay(), ['theme' => $get('theme') ?: config('themes.base')]), shouldOpenInNewTab: true),
|
||||
),
|
||||
Select::make('image_world')
|
||||
->label('Bildwelt')
|
||||
->options(fn (): array => app(ImageWorldRegistry::class)->options())
|
||||
->placeholder('Vorgabe der Installation')
|
||||
->helperText(fn (Get $get): ?string => app(ImageWorldRegistry::class)->get($get('image_world'))?->description
|
||||
?: 'Bänder, Vignetten und Ornamente dieser Website. Eine Wohnung kann eine andere Bildwelt tragen.'),
|
||||
Toggle::make('is_default')->label('Standard-Website')->inline(false),
|
||||
]),
|
||||
Section::make('Marke')
|
||||
->description('Logo, Favicon und das Logo für E-Mails und den Mietvertrag. Gehört dem Vermieter, nicht dem Theme – jede Website hat ihre eigene.')
|
||||
->columns(3)
|
||||
->collapsible()
|
||||
->schema([
|
||||
SpatieMediaLibraryFileUpload::make('logo')
|
||||
->label('Logo')
|
||||
->collection(Site::BRAND_LOGO)
|
||||
->acceptedFileTypes(['image/svg+xml', 'image/png', 'image/webp'])
|
||||
->helperText('SVG bevorzugt – bleibt in jeder Größe scharf.'),
|
||||
SpatieMediaLibraryFileUpload::make('favicon')
|
||||
->label('Favicon')
|
||||
->collection(Site::BRAND_FAVICON)
|
||||
->acceptedFileTypes(['image/svg+xml', 'image/png', 'image/x-icon'])
|
||||
->helperText('Das kleine Zeichen im Browser-Tab.'),
|
||||
SpatieMediaLibraryFileUpload::make('document_logo')
|
||||
->label('Logo für E-Mail und Vertrag')
|
||||
->collection(Site::BRAND_DOCUMENT_LOGO)
|
||||
->acceptedFileTypes(['image/png', 'image/jpeg'])
|
||||
->helperText('Als PNG oder JPG – E-Mail-Programme und der PDF-Druck zeichnen kein SVG.'),
|
||||
]),
|
||||
Section::make('Farben des Themes')
|
||||
->description('Grundfarben dieser Website; saisonale Erscheinungsbilder können einzelne Farben zusätzlich ändern.')
|
||||
->columns(3)
|
||||
|
||||
@@ -51,8 +51,8 @@ public function health(Request $request): JsonResponse
|
||||
$mailbox = [
|
||||
'configured' => MailboxReader::isConfigured(),
|
||||
'ok' => ! MonitorChannels::mailboxIsStale(),
|
||||
'last_success_at' => Cache::get(MailboxReader::LAST_SUCCESS_KEY),
|
||||
'last_error' => Cache::get(MailboxReader::LAST_ERROR_KEY),
|
||||
'last_success_at' => Cache::get(MailboxReader::key(MailboxReader::LAST_SUCCESS_KEY)),
|
||||
'last_error' => Cache::get(MailboxReader::key(MailboxReader::LAST_ERROR_KEY)),
|
||||
];
|
||||
|
||||
$ok = $channels->every(fn (array $channel): bool => $channel['ok']) && $mailbox['ok'];
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Models\Site;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
use App\Tenancy\TenantContext;
|
||||
@@ -9,6 +10,7 @@
|
||||
use App\Themes\ThemeFactory;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
@@ -36,15 +38,45 @@ public function handle(Request $request, Closure $next): Response
|
||||
|
||||
if ($tenant !== null) {
|
||||
if (! $tenant->is_active && ! $this->operatorMayPass($request)) {
|
||||
abort(404);
|
||||
return $this->suspended($tenant);
|
||||
}
|
||||
|
||||
$context->set($tenant);
|
||||
}
|
||||
|
||||
$this->useSiteOrigin($theme->site);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Links must carry the address the visitor came in on. AppServiceProvider forces APP_URL for every
|
||||
* generated URL, because on Strato the document root is a release folder; with one landlord that was
|
||||
* harmless, but a second website on its own domain would otherwise send every visitor to the first
|
||||
* landlord's host. The forced root stays – only its value becomes the website that was resolved.
|
||||
*/
|
||||
private function useSiteOrigin(Site $site): void
|
||||
{
|
||||
$origin = $site->exists ? $site->origin() : null;
|
||||
|
||||
if ($origin === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
URL::forceRootUrl($origin);
|
||||
URL::forceScheme(parse_url($origin, PHP_URL_SCHEME) ?: 'https');
|
||||
}
|
||||
|
||||
/**
|
||||
* What a visitor of a suspended landlord sees: a plain notice instead of a dead link.
|
||||
*/
|
||||
private function suspended(Tenant $tenant): Response
|
||||
{
|
||||
return response()->view('suspended', [
|
||||
'message' => $tenant->suspended_message ?: 'Diese Webseite ist zurzeit nicht erreichbar. Bitte versuchen Sie es später noch einmal.',
|
||||
], 503);
|
||||
}
|
||||
|
||||
/**
|
||||
* A suspended landlord stays reachable for the operator, and the operator panel itself stays open.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\ImageWorlds;
|
||||
|
||||
use JsonException;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* One picture world ("Bildwelt"): a folder with a world.json and SVG files, exactly like a theme is a
|
||||
* folder with a theme.json. Themes ask for a slot (divider, vignette.beach …), never for a file, so a
|
||||
* website can be dressed in "Ostsee" or later in "Berge" without touching a single template (A18/A19).
|
||||
*/
|
||||
class ImageWorldManifest
|
||||
{
|
||||
/**
|
||||
* @param array<string, string> $slots slot => file name without .svg
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly string $key,
|
||||
public readonly string $name,
|
||||
public readonly ?string $description,
|
||||
public readonly string $path,
|
||||
public readonly array $slots,
|
||||
) {}
|
||||
|
||||
public static function fromFile(string $file): self
|
||||
{
|
||||
try {
|
||||
$data = json_decode((string) file_get_contents($file), true, 512, JSON_THROW_ON_ERROR);
|
||||
} catch (JsonException $exception) {
|
||||
throw new RuntimeException('Bildwelt '.$file.' ist kein gültiges JSON: '.$exception->getMessage());
|
||||
}
|
||||
|
||||
$path = dirname($file);
|
||||
$key = basename($path);
|
||||
|
||||
return new self(
|
||||
key: $key,
|
||||
name: is_string($data['name'] ?? null) ? $data['name'] : $key,
|
||||
description: is_string($data['description'] ?? null) ? $data['description'] : null,
|
||||
path: $path,
|
||||
slots: array_filter(
|
||||
is_array($data['slots'] ?? null) ? $data['slots'] : [],
|
||||
fn (mixed $file, mixed $slot): bool => is_string($slot) && is_string($file),
|
||||
ARRAY_FILTER_USE_BOTH,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The file behind a slot, or null when this world does not fill it. A missing slot is not an error:
|
||||
* a template asks for decoration and simply gets none.
|
||||
*/
|
||||
public function fileFor(string $slot): ?string
|
||||
{
|
||||
$name = $this->slots[$slot] ?? null;
|
||||
|
||||
if ($name === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$file = $this->path.DIRECTORY_SEPARATOR.'svg'.DIRECTORY_SEPARATOR.$name.'.svg';
|
||||
|
||||
return is_file($file) ? $file : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
public function missingFiles(): array
|
||||
{
|
||||
return array_values(array_filter(
|
||||
array_keys($this->slots),
|
||||
fn (string $slot): bool => $this->fileFor($slot) === null,
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\ImageWorlds;
|
||||
|
||||
/**
|
||||
* Discovers the picture worlds below config('image-worlds.paths'), the same way themes are discovered.
|
||||
*/
|
||||
class ImageWorldRegistry
|
||||
{
|
||||
/** @var array<string, ImageWorldManifest>|null */
|
||||
private ?array $worlds = null;
|
||||
|
||||
/**
|
||||
* @return array<string, ImageWorldManifest>
|
||||
*/
|
||||
public function all(): array
|
||||
{
|
||||
if ($this->worlds === null) {
|
||||
$this->worlds = [];
|
||||
|
||||
foreach (config('image-worlds.paths') as $path) {
|
||||
foreach (glob(rtrim($path, '/\\').'/*/world.json') ?: [] as $file) {
|
||||
$manifest = ImageWorldManifest::fromFile($file);
|
||||
$this->worlds[$manifest->key] = $manifest;
|
||||
}
|
||||
}
|
||||
|
||||
ksort($this->worlds);
|
||||
}
|
||||
|
||||
return $this->worlds;
|
||||
}
|
||||
|
||||
public function get(?string $key): ?ImageWorldManifest
|
||||
{
|
||||
if ($key === null || $key === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->all()[$key] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Key => name, for a select in the admin.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function options(): array
|
||||
{
|
||||
return array_map(fn (ImageWorldManifest $world): string => $world->name, $this->all());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\ImageWorlds;
|
||||
|
||||
use App\Themes\Theme;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Renders the graphic behind a slot. Inline SVG, so the graphics take the text colour and need no second
|
||||
* request; the ids inside are made unique per call, because two copies of the same gradient on one page
|
||||
* would otherwise refer to the same definition and one of them would lose its colours.
|
||||
*
|
||||
* Which world applies: the apartment overrules the website (A20), the website overrules the installation.
|
||||
*/
|
||||
class MotifRenderer
|
||||
{
|
||||
/** @var array<string, string> */
|
||||
private array $cache = [];
|
||||
|
||||
public function render(string $slot, ?string $class = null, ?string $label = null): HtmlString
|
||||
{
|
||||
$world = $this->world();
|
||||
$file = $world?->fileFor($slot);
|
||||
|
||||
if ($file === null) {
|
||||
return new HtmlString(''); // a template asks for decoration and gets none
|
||||
}
|
||||
|
||||
$svg = $this->cache[$file] ??= (string) file_get_contents($file);
|
||||
|
||||
if ($svg === '') {
|
||||
return new HtmlString('');
|
||||
}
|
||||
|
||||
$unique = 'm'.Str::lower(Str::random(6));
|
||||
|
||||
$svg = (string) preg_replace(['/\s(role|aria-label|aria-hidden)="[^"]*"/', '/<title>.*?<\/title>/s'], '', $svg);
|
||||
$svg = (string) preg_replace(['/id="([^"]+)"/', '/url\(#([^)]+)\)/'], ['id="$1-'.$unique.'"', 'url(#$1-'.$unique.')'], $svg);
|
||||
|
||||
$attributes = 'class="'.e((string) $class).'" '.($label !== null
|
||||
? 'role="img" aria-label="'.e($label).'"'
|
||||
: 'aria-hidden="true" focusable="false"');
|
||||
|
||||
return new HtmlString((string) preg_replace('/<svg\s/', '<svg '.$attributes.' ', $svg, 1));
|
||||
}
|
||||
|
||||
public function has(string $slot): bool
|
||||
{
|
||||
return $this->world()?->fileFor($slot) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The picture world in force for what is being rendered right now.
|
||||
*/
|
||||
public function world(): ?ImageWorldManifest
|
||||
{
|
||||
$registry = app(ImageWorldRegistry::class);
|
||||
$theme = app()->bound(Theme::class) ? app(Theme::class) : null;
|
||||
|
||||
return $registry->get($theme?->property()?->image_world)
|
||||
?? $registry->get($theme?->site->image_world)
|
||||
?? $registry->get(config('image-worlds.default'));
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
'site_id',
|
||||
'name',
|
||||
'slug',
|
||||
'image_world',
|
||||
'address',
|
||||
'size_sqm',
|
||||
'max_guests',
|
||||
|
||||
@@ -12,16 +12,18 @@
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
|
||||
/**
|
||||
* A website: domain, theme with its settings, pages and appearances, and the properties it shows.
|
||||
* Today there is one site; more sites allow other landlords to use the system under their own domain.
|
||||
*/
|
||||
#[Fillable(['name', 'domain', 'is_default', 'theme', 'theme_settings', 'locale'])]
|
||||
class Site extends Model
|
||||
#[Fillable(['name', 'domain', 'is_default', 'theme', 'image_world', 'theme_settings', 'locale'])]
|
||||
class Site extends Model implements HasMedia
|
||||
{
|
||||
/** @use HasFactory<SiteFactory> */
|
||||
use BelongsToTenant, HasFactory;
|
||||
use BelongsToTenant, HasFactory, InteractsWithMedia;
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
@@ -83,6 +85,57 @@ public function signedRoute(string $name, mixed $parameters = []): string
|
||||
/**
|
||||
* Keep the single domain field and the host table on the same hostname.
|
||||
*/
|
||||
/**
|
||||
* The brand of this website: the graphics that identify the landlord, not the decoration of the theme.
|
||||
* Kept per website so a second landlord never inherits the first one's logo in their contract (A14/A22).
|
||||
*/
|
||||
public const BRAND_LOGO = 'logo';
|
||||
|
||||
public const BRAND_FAVICON = 'favicon';
|
||||
|
||||
public const BRAND_DOCUMENT_LOGO = 'document_logo';
|
||||
|
||||
public function registerMediaCollections(): void
|
||||
{
|
||||
// The brand is shown on the public website and in mails, so it lives on the public disk.
|
||||
$this->addMediaCollection(self::BRAND_LOGO)
|
||||
->useDisk('public')
|
||||
->singleFile()
|
||||
->acceptsMimeTypes(['image/svg+xml', 'image/png', 'image/webp']);
|
||||
|
||||
$this->addMediaCollection(self::BRAND_FAVICON)
|
||||
->useDisk('public')
|
||||
->singleFile()
|
||||
->acceptsMimeTypes(['image/svg+xml', 'image/png', 'image/x-icon']);
|
||||
|
||||
// Mail clients and the PDF renderer do not draw SVG, so this one is a pixel image.
|
||||
$this->addMediaCollection(self::BRAND_DOCUMENT_LOGO)
|
||||
->useDisk('public')
|
||||
->singleFile()
|
||||
->acceptsMimeTypes(['image/png', 'image/jpeg']);
|
||||
}
|
||||
|
||||
/**
|
||||
* The URL of a brand graphic, or null when this website has none.
|
||||
*/
|
||||
public function brandUrl(string $collection): ?string
|
||||
{
|
||||
$media = $this->getFirstMedia($collection);
|
||||
|
||||
return $media?->getUrl() ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The absolute path of a brand graphic – mails and the contract PDF embed the file, they cannot fetch
|
||||
* a URL from a server that may not be reachable from where the PDF is rendered.
|
||||
*/
|
||||
public function brandPath(string $collection): ?string
|
||||
{
|
||||
$path = $this->getFirstMedia($collection)?->getPath();
|
||||
|
||||
return is_string($path) && is_file($path) ? $path : null;
|
||||
}
|
||||
|
||||
public function syncDomainHost(): void
|
||||
{
|
||||
if (! $this->wasRecentlyCreated && ! $this->wasChanged('domain')) {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* One setting of the whole installation, read through App\Support\SystemSettings. Belongs to no landlord;
|
||||
* only the operator ever writes it. Secrets are stored encrypted by the service, not by a cast, because
|
||||
* the value column also holds plain numbers.
|
||||
*/
|
||||
#[Fillable(['key', 'value', 'is_secret'])]
|
||||
class SystemSetting extends Model
|
||||
{
|
||||
/** @var list<string> */
|
||||
protected $hidden = ['value'];
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'is_secret' => 'boolean',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,8 @@
|
||||
'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',
|
||||
'operating_mode', 'test_recipient', 'suspended_message',
|
||||
'mailbox_host', 'mailbox_port', 'mailbox_encryption', 'mailbox_username', 'mailbox_password', 'mailbox_folder',
|
||||
'deposit_due_days', 'review_request_after_days', 'guest_retention_years', 'retention_inquiry_months',
|
||||
'retention_portal_email_excerpt_days', 'retention_attribution_months',
|
||||
'spam_min_seconds', 'spam_per_ip_per_hour', 'spam_per_email_per_day', 'spam_open_requests_per_email', 'spam_max_links',
|
||||
@@ -54,6 +55,7 @@ protected function casts(): array
|
||||
'bank_bic' => 'encrypted',
|
||||
'bank_name' => 'encrypted',
|
||||
'tax_note' => 'encrypted',
|
||||
'mailbox_password' => 'encrypted',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -89,6 +91,28 @@ public function serviceUsages(): HasMany
|
||||
return $this->hasMany(ServiceUsage::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* The mailbox this landlord reads portal notifications from, or null when they have none. An empty
|
||||
* host means the fast path is simply off for them.
|
||||
*
|
||||
* @return array{host: string, port: int, encryption: string, username: string, password: ?string, folder: string}|null
|
||||
*/
|
||||
public function mailbox(): ?array
|
||||
{
|
||||
if (blank($this->mailbox_host) || blank($this->mailbox_username)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'host' => (string) $this->mailbox_host,
|
||||
'port' => (int) ($this->mailbox_port ?: 993),
|
||||
'encryption' => (string) ($this->mailbox_encryption ?: 'ssl'),
|
||||
'username' => (string) $this->mailbox_username,
|
||||
'password' => $this->mailbox_password,
|
||||
'folder' => (string) ($this->mailbox_folder ?: 'INBOX'),
|
||||
];
|
||||
}
|
||||
|
||||
public function isLive(): bool
|
||||
{
|
||||
return $this->operating_mode === 'live';
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
use App\Models\User;
|
||||
|
||||
/**
|
||||
* Landlords are created and suspended by the operator. Deleting one is a later, separate step.
|
||||
* Landlords are created and suspended by the operator. Deleting one is deliberately not an action in the
|
||||
* panel: it removes data and files for good. It happens through `php artisan tenants:delete <slug>`, which
|
||||
* writes an export first and asks before it acts.
|
||||
*/
|
||||
class TenantPolicy
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Support\StripImageMetadata;
|
||||
use App\Support\SystemSettings;
|
||||
use App\Tenancy\TenantConfig;
|
||||
use App\Tenancy\TenantContext;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
@@ -27,9 +28,12 @@ public function register(): void
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
// 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.
|
||||
// Settings of the installation first (they become the baseline a landlord may tighten), then the
|
||||
// operating data of the landlord: addresses, periods and test mode, which sends every e-mail to the
|
||||
// test recipient only until a landlord is switched live. Console and boot know the landlord only if
|
||||
// there is exactly one.
|
||||
try {
|
||||
SystemSettings::apply();
|
||||
$this->app->make(TenantConfig::class)->refresh();
|
||||
} catch (Throwable) {
|
||||
// no database yet (package discovery, first install)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Providers\Filament;
|
||||
|
||||
use App\Filament\Operator\Pages\SystemOverview;
|
||||
use App\Filament\Operator\Pages\SystemSettingsPage;
|
||||
use App\Http\Middleware\ResolveTheme;
|
||||
use Filament\Auth\MultiFactor\App\AppAuthentication;
|
||||
use Filament\Http\Middleware\Authenticate;
|
||||
@@ -42,6 +43,7 @@ public function panel(Panel $panel): Panel
|
||||
->pages([
|
||||
Dashboard::class,
|
||||
SystemOverview::class,
|
||||
SystemSettingsPage::class,
|
||||
])
|
||||
->widgets([
|
||||
AccountWidget::class,
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use App\Models\SystemSetting;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Settings of the whole installation, owned by the operator. They are laid over the configuration at boot,
|
||||
* before any landlord is known, so `config('fewo.*')` keeps being the one place the rest of the code reads.
|
||||
*
|
||||
* This is not the old `settings` table in a new coat: that one held a single landlord's operating data,
|
||||
* which now lives on `tenants`. What is kept here belongs to no landlord and is never reachable from a
|
||||
* landlord's admin.
|
||||
*
|
||||
* Database credentials and APP_KEY cannot be kept here. They are needed to open the database and to decrypt
|
||||
* what is in it, so they have to be readable before any of this exists – they stay in the server's .env.
|
||||
*/
|
||||
class SystemSettings
|
||||
{
|
||||
/**
|
||||
* Editable keys: config key => [label, kind, section, help]. The kind decides the form field and
|
||||
* whether the value is stored encrypted.
|
||||
*
|
||||
* @var array<string, array{0: string, 1: string, 2: string, 3: string}>
|
||||
*/
|
||||
public const EDITABLE = [
|
||||
'fewo.guest_retention_years' => ['Gästedaten löschen nach (Jahre)', 'int', 'Löschfristen', 'Obergrenze für alle Mandanten; ein Mandant kann kürzer löschen.'],
|
||||
'fewo.retention.inquiry_months' => ['Nicht gebuchte Anfragen löschen nach (Monate)', 'int', 'Löschfristen', ''],
|
||||
'fewo.retention.portal_email_excerpt_days' => ['Portal-Mail-Auszug löschen nach (Tage)', 'int', 'Löschfristen', ''],
|
||||
'fewo.retention.attribution_months' => ['Herkunftsangaben löschen nach (Monate)', 'int', 'Löschfristen', ''],
|
||||
|
||||
'fewo.spam.min_seconds' => ['Mindestzeit im Formular (Sekunden)', 'int', 'Bot-Schutz', 'Untergrenze; ein Mandant kann länger warten lassen.'],
|
||||
'fewo.spam.per_ip_per_hour' => ['Anfragen je IP und Stunde', 'int', 'Bot-Schutz', ''],
|
||||
'fewo.spam.per_email_per_day' => ['Anfragen je E-Mail und Tag', 'int', 'Bot-Schutz', ''],
|
||||
'fewo.spam.open_requests_per_email' => ['Gleichzeitig offene Anfragen je E-Mail', 'int', 'Bot-Schutz', ''],
|
||||
'fewo.spam.max_links' => ['Erlaubte Links im Text', 'int', 'Bot-Schutz', ''],
|
||||
'fewo.spam.total_per_hour' => ['Anfragen aller Websites zusammen, je Stunde', 'int', 'Bot-Schutz', 'Flutgrenze über alle Mandanten. Kein Mandant kann sie anheben.'],
|
||||
|
||||
'fewo.channels.stale_after_minutes' => ['Portal-Abgleich gilt als veraltet nach (Minuten)', 'int', 'Portale', ''],
|
||||
'fewo.channels.task_reminder_after_minutes' => ['Erinnerung an Portal-Aufgaben nach (Minuten)', 'int', 'Portale', ''],
|
||||
|
||||
'fewo.backup.keep' => ['Aufbewahrte Datenbank-Sicherungen', 'int', 'Sicherung', 'Eine Sicherung der ganzen Datenbank, über alle Mandanten.'],
|
||||
|
||||
'mail.default' => ['Versandweg', 'mailer', 'E-Mail-Versand', '„log“ schreibt jede E-Mail nur in die Logdatei und versendet nichts.'],
|
||||
'mail.mailers.smtp.host' => ['SMTP-Server', 'text', 'E-Mail-Versand', ''],
|
||||
'mail.mailers.smtp.port' => ['SMTP-Port', 'int', 'E-Mail-Versand', ''],
|
||||
'mail.mailers.smtp.username' => ['SMTP-Benutzer', 'text', 'E-Mail-Versand', 'Die Absenderadresse eines Mandanten muss zu diesem Postfach passen, sonst lehnt Strato ab.'],
|
||||
'mail.mailers.smtp.password' => ['SMTP-Passwort', 'secret', 'E-Mail-Versand', ''],
|
||||
'fewo.mail_redirect_to' => ['Harte Umleitung aller E-Mails', 'text', 'E-Mail-Versand', 'Gefüllt: JEDE E-Mail dieses Servers geht nur hierhin, auch bei scharf geschalteten Mandanten. Leer: die Betriebsart jedes Mandanten entscheidet allein.'],
|
||||
|
||||
'fewo.scheduler_token' => ['Scheduler-Token', 'secret', 'Schnittstellen', 'Für GET /automation/scheduler. Leer = abgeschaltet.'],
|
||||
'fewo.channels.health_token' => ['Health-Token', 'secret', 'Schnittstellen', 'Für GET /health/sync. Leer = abgeschaltet.'],
|
||||
'fewo.automation.webhook_url' => ['Automation: Adresse', 'text', 'Schnittstellen', ''],
|
||||
'fewo.automation.secret' => ['Automation: Geheimnis', 'secret', 'Schnittstellen', ''],
|
||||
];
|
||||
|
||||
private const CACHE_KEY = 'system-settings';
|
||||
|
||||
/**
|
||||
* What the server configured, before anything stored was laid over it. Captured once per process.
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
private static array $baseline = [];
|
||||
|
||||
/**
|
||||
* Lays the stored values over the configuration. Called at boot before any landlord is resolved, so
|
||||
* TenantConfig takes these as its baseline.
|
||||
*/
|
||||
public static function apply(): void
|
||||
{
|
||||
$stored = self::stored();
|
||||
$values = [];
|
||||
|
||||
foreach (array_keys(self::EDITABLE) as $key) {
|
||||
if (! array_key_exists($key, self::$baseline)) {
|
||||
self::$baseline[$key] = config($key);
|
||||
}
|
||||
|
||||
// A key the operator cleared has to give the .env value back in the same request, not only
|
||||
// after the next boot – otherwise an emptied field looks saved while the old value still acts.
|
||||
$values[$key] = array_key_exists($key, $stored)
|
||||
? self::cast($key, $stored[$key])
|
||||
: self::$baseline[$key];
|
||||
}
|
||||
|
||||
config($values);
|
||||
}
|
||||
|
||||
/**
|
||||
* The value in force: what the operator stored, else what the server's .env configured.
|
||||
*/
|
||||
public static function get(string $key): mixed
|
||||
{
|
||||
$stored = self::stored();
|
||||
|
||||
return array_key_exists($key, $stored) ? self::cast($key, $stored[$key]) : config($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $values config key => value; null or "" falls back to the .env again
|
||||
*/
|
||||
public static function save(array $values): void
|
||||
{
|
||||
foreach ($values as $key => $value) {
|
||||
if (! array_key_exists($key, self::EDITABLE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$isSecret = self::EDITABLE[$key][1] === 'secret';
|
||||
|
||||
if (blank($value)) {
|
||||
SystemSetting::query()->where('key', $key)->delete();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
SystemSetting::query()->updateOrCreate(
|
||||
['key' => $key],
|
||||
['value' => $isSecret ? encrypt((string) $value) : (string) $value, 'is_secret' => $isSecret],
|
||||
);
|
||||
}
|
||||
|
||||
Cache::forget(self::CACHE_KEY);
|
||||
self::apply();
|
||||
}
|
||||
|
||||
public static function forget(): void
|
||||
{
|
||||
Cache::forget(self::CACHE_KEY);
|
||||
self::$baseline = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, ?string>
|
||||
*/
|
||||
private static function stored(): array
|
||||
{
|
||||
try {
|
||||
return Cache::rememberForever(self::CACHE_KEY, fn (): array => SystemSetting::query()->pluck('value', 'key')->all());
|
||||
} catch (Throwable) {
|
||||
return []; // before the migrations ran
|
||||
}
|
||||
}
|
||||
|
||||
private static function cast(string $key, ?string $value): mixed
|
||||
{
|
||||
if ($value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$kind = self::EDITABLE[$key][1] ?? 'text';
|
||||
|
||||
return match ($kind) {
|
||||
'int' => (int) $value,
|
||||
'secret' => rescue(fn (): string => decrypt($value), null, report: false),
|
||||
default => $value,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tenancy;
|
||||
|
||||
use App\Models\Photo;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use RuntimeException;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
use ZipArchive;
|
||||
|
||||
/**
|
||||
* Hands a landlord their data back and removes them (A25). Everything of one landlord is reachable by
|
||||
* `tenant_id`, so neither is a join across eight levels – it is a list of tables.
|
||||
*/
|
||||
class TenantArchive
|
||||
{
|
||||
/**
|
||||
* Child rows first, so foreign keys allow the delete. The reverse order is the one in which the rows
|
||||
* were assigned when tenancy was introduced.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
private const DELETE_ORDER = [
|
||||
'floor_plans',
|
||||
'channel_sync_logs',
|
||||
'channel_tasks',
|
||||
'portal_emails',
|
||||
'payments',
|
||||
'reviews',
|
||||
'blocked_periods',
|
||||
'bookings',
|
||||
'special_offers',
|
||||
'extras',
|
||||
'seasons',
|
||||
'amenities',
|
||||
'photos',
|
||||
'appearances',
|
||||
'pages',
|
||||
'notices',
|
||||
'faqs',
|
||||
'content_blocks',
|
||||
'guests',
|
||||
'channels',
|
||||
'properties',
|
||||
'site_domains',
|
||||
'sites',
|
||||
'tenant_services',
|
||||
'service_usages',
|
||||
'tenant_access_logs',
|
||||
'tenant_user',
|
||||
];
|
||||
|
||||
/**
|
||||
* Writes every row and every uploaded file of this landlord into one zip file.
|
||||
*
|
||||
* @return string the path of the written archive
|
||||
*/
|
||||
public function export(Tenant $tenant, string $directory): string
|
||||
{
|
||||
File::ensureDirectoryExists($directory);
|
||||
|
||||
$path = rtrim($directory, '/\\').DIRECTORY_SEPARATOR.'mandant-'.$tenant->slug.'-'.now()->format('Ymd-His').'.zip';
|
||||
$zip = new ZipArchive;
|
||||
|
||||
if ($zip->open($path, ZipArchive::CREATE | ZipArchive::OVERWRITE) !== true) {
|
||||
throw new RuntimeException('Archiv konnte nicht angelegt werden: '.$path);
|
||||
}
|
||||
|
||||
$zip->addFromString('mandant.json', (string) json_encode($tenant->toArray(), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||
|
||||
foreach ($this->tables() as $table) {
|
||||
$rows = $this->rowsOf($table, $tenant);
|
||||
|
||||
$zip->addFromString(
|
||||
'daten/'.$table.'.json',
|
||||
(string) json_encode($rows, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||
);
|
||||
}
|
||||
|
||||
$zip->addFromString(
|
||||
'daten/benutzer.json',
|
||||
(string) json_encode($this->usersOf($tenant), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||
);
|
||||
|
||||
$this->addFiles($zip, $tenant);
|
||||
|
||||
$zip->close();
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Who worked for this landlord, with their role. Deliberately without password hashes and without the
|
||||
* two-factor secrets: the export is handed out, and those would be worth stealing.
|
||||
*
|
||||
* @return list<array{id: int, name: string, email: string, role: ?string, weitere_mandanten: int}>
|
||||
*/
|
||||
public function usersOf(Tenant $tenant): array
|
||||
{
|
||||
return User::query()
|
||||
->whereHas('tenants', fn ($query) => $query->where('tenants.id', $tenant->id))
|
||||
->withCount('tenants')
|
||||
->get()
|
||||
->map(fn (User $user): array => [
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'email' => $user->email,
|
||||
'role' => $user->roleOn($tenant->id)?->value,
|
||||
'weitere_mandanten' => max(0, $user->tenants_count - 1),
|
||||
])
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the landlord and everything that belongs to them, files included. The landlord row goes last.
|
||||
*
|
||||
* @return array<string, int> how many rows were removed per table
|
||||
*/
|
||||
public function delete(Tenant $tenant): array
|
||||
{
|
||||
$this->deleteFiles($tenant);
|
||||
|
||||
$orphans = $this->accountsLosingTheirLastLandlord($tenant);
|
||||
$removed = [];
|
||||
|
||||
DB::transaction(function () use ($tenant, $orphans, &$removed): void {
|
||||
foreach (self::DELETE_ORDER as $table) {
|
||||
if (! $this->hasTenantColumn($table)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$count = DB::table($table)->where('tenant_id', $tenant->id)->delete();
|
||||
|
||||
if ($count > 0) {
|
||||
$removed[$table] = $count;
|
||||
}
|
||||
}
|
||||
|
||||
if ($orphans !== []) {
|
||||
$removed['users'] = User::query()->whereKey($orphans)->delete();
|
||||
}
|
||||
|
||||
$tenant->delete();
|
||||
});
|
||||
|
||||
return $removed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accounts that belonged to this landlord only. They are removed with them – an account that can reach
|
||||
* nothing is personal data without a purpose. An operator keeps their account, and so does anybody who
|
||||
* still works for another landlord.
|
||||
*
|
||||
* @return list<int>
|
||||
*/
|
||||
private function accountsLosingTheirLastLandlord(Tenant $tenant): array
|
||||
{
|
||||
return User::query()
|
||||
->where('is_operator', false)
|
||||
->whereHas('tenants', fn ($query) => $query->where('tenants.id', $tenant->id))
|
||||
->withCount('tenants')
|
||||
->get()
|
||||
->filter(fn (User $user): bool => $user->tenants_count === 1)
|
||||
->pluck('id')
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tables carrying a tenant_id, in a stable order.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function tables(): array
|
||||
{
|
||||
return array_values(array_filter(self::DELETE_ORDER, fn (string $table): bool => $this->hasTenantColumn($table)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
private function rowsOf(string $table, Tenant $tenant): array
|
||||
{
|
||||
return array_map(
|
||||
fn (object $row): array => (array) $row,
|
||||
DB::table($table)->where('tenant_id', $tenant->id)->get()->all(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Photos keep their files through Spatie's media library; they hang off the photo, not off the landlord,
|
||||
* so they are collected through the photos of this landlord.
|
||||
*/
|
||||
private function addFiles(ZipArchive $zip, Tenant $tenant): void
|
||||
{
|
||||
foreach ($this->mediaOf($tenant) as $media) {
|
||||
$path = $media->getPath();
|
||||
|
||||
if (is_string($path) && File::exists($path)) {
|
||||
$zip->addFile($path, 'dateien/'.$media->id.'-'.$media->file_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function deleteFiles(Tenant $tenant): void
|
||||
{
|
||||
foreach ($this->mediaOf($tenant) as $media) {
|
||||
$media->delete(); // removes the stored file as well
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Media>
|
||||
*/
|
||||
private function mediaOf(Tenant $tenant): Collection
|
||||
{
|
||||
return app(TenantContext::class)->run(
|
||||
$tenant,
|
||||
fn () => Photo::query()->with('media')->get()->flatMap(fn (Photo $photo) => $photo->media),
|
||||
);
|
||||
}
|
||||
|
||||
private function hasTenantColumn(string $table): bool
|
||||
{
|
||||
static $known = [];
|
||||
|
||||
return $known[$table] ??= Schema::hasTable($table)
|
||||
&& Schema::hasColumn($table, 'tenant_id');
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,23 @@ public static function forLegacyLandlord(array $settings = [], bool $encryptBank
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The mailbox the single-landlord installation used, taken from the .env for a raw database write.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function mailboxFromConfig(): array
|
||||
{
|
||||
return [
|
||||
'mailbox_host' => config('fewo.mailbox.host'),
|
||||
'mailbox_port' => config('fewo.mailbox.port'),
|
||||
'mailbox_encryption' => config('fewo.mailbox.encryption'),
|
||||
'mailbox_username' => config('fewo.mailbox.username'),
|
||||
'mailbox_password' => self::bank(config('fewo.mailbox.password'), true),
|
||||
'mailbox_folder' => config('fewo.mailbox.folder'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The value of the installation, not the one a landlord may already have laid over the configuration.
|
||||
*/
|
||||
@@ -53,7 +70,7 @@ 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
|
||||
public static function bank(mixed $value, bool $encrypt): ?string
|
||||
{
|
||||
if (blank($value)) {
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tenancy;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use Closure;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Runs background work once per landlord, with that landlord current. Everything the scheduler does –
|
||||
* expiring holds, importing portals, writing reminders – acts on one landlord's data and sends mail with
|
||||
* one landlord's sender, so it has to be told which one.
|
||||
*
|
||||
* Without this, a run with several landlords sees no landlord at all: queries fall back to unfiltered and
|
||||
* mail falls back to the .env sender, which would send one landlord's reminders with another one's address.
|
||||
*
|
||||
* A landlord whose run fails does not stop the others – the next one still gets its turn.
|
||||
*/
|
||||
class TenantRunner
|
||||
{
|
||||
/**
|
||||
* @param Closure(Tenant): void $callback
|
||||
* @return int how many landlords ran without an error
|
||||
*/
|
||||
public function each(Closure $callback, bool $onlyActive = true): int
|
||||
{
|
||||
$context = app(TenantContext::class);
|
||||
$succeeded = 0;
|
||||
|
||||
foreach ($this->tenants($onlyActive) as $tenant) {
|
||||
try {
|
||||
$context->run($tenant, fn () => $callback($tenant));
|
||||
$succeeded++;
|
||||
} catch (Throwable $exception) {
|
||||
Log::error('Lauf für Mandant '.$tenant->slug.' fehlgeschlagen: '.$exception->getMessage(), [
|
||||
'tenant_id' => $tenant->id,
|
||||
'exception' => $exception,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $succeeded;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Tenant>
|
||||
*/
|
||||
public function tenants(bool $onlyActive = true): Collection
|
||||
{
|
||||
return Tenant::query()
|
||||
->when($onlyActive, fn ($query) => $query->where('is_active', true))
|
||||
->orderBy('id')
|
||||
->get();
|
||||
}
|
||||
}
|
||||
@@ -3,18 +3,19 @@
|
||||
namespace App\Themes;
|
||||
|
||||
use App\Models\Appearance;
|
||||
use App\Models\Property;
|
||||
use App\Themes\Sections\Section;
|
||||
use Filament\Forms\Components\Builder\Block;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Support\Facades\View as ViewFactory;
|
||||
|
||||
/**
|
||||
* The section catalogue from config/themes.php: builder blocks for the admin and rendering for the website.
|
||||
*
|
||||
* Every placed section carries data.id (a stable UUID, see Page::assignSectionIds) so appearances can
|
||||
* address it, and data.appearances (appearance ids; empty = always shown).
|
||||
* address it, data.appearances (appearance ids; empty = always shown), and an optional data.property_id
|
||||
* (an active property of this website; empty = primary property).
|
||||
*/
|
||||
class SectionRegistry
|
||||
{
|
||||
@@ -38,7 +39,7 @@ public function get(string $key): ?Section
|
||||
/**
|
||||
* @return list<Block>
|
||||
*/
|
||||
public function blocks(): array
|
||||
public function blocks(?int $siteId = null): array
|
||||
{
|
||||
return array_values(array_map(
|
||||
fn (string $class): Block => Block::make($class::key())
|
||||
@@ -47,6 +48,17 @@ public function blocks(): array
|
||||
->schema([
|
||||
Hidden::make('id'),
|
||||
...$class::schema(),
|
||||
Select::make('property_id')
|
||||
->label('Wohnung')
|
||||
->placeholder('Hauptwohnung')
|
||||
->helperText('Leer = Hauptwohnung dieser Website.')
|
||||
->options(fn (): array => Property::query()
|
||||
->where('site_id', $siteId)
|
||||
->whereNotNull('site_id')
|
||||
->where('is_active', true)
|
||||
->orderBy('name')
|
||||
->pluck('name', 'id')
|
||||
->all()),
|
||||
Select::make('appearances')
|
||||
->label('Nur anzeigen im Erscheinungsbild')
|
||||
->helperText('Leer = immer anzeigen. Z. B. ein Weihnachts-Baustein nur im Erscheinungsbild „Weihnachten“.')
|
||||
@@ -70,11 +82,11 @@ public function isVisible(Theme $theme, array $data): bool
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the stored sections of a page; unknown or failing types are skipped (and reported),
|
||||
* so a page never breaks because of one section.
|
||||
* Prepares the stored sections for deferred rendering. Unknown types, missing views, hidden sections
|
||||
* and unavailable property assignments are skipped.
|
||||
*
|
||||
* @param list<array{type: string, data?: array<string, mixed>}>|null $sections
|
||||
* @return list<View>
|
||||
* @return list<SectionView>
|
||||
*/
|
||||
public function render(Theme $theme, ?array $sections): array
|
||||
{
|
||||
@@ -85,11 +97,24 @@ public function render(Theme $theme, ?array $sections): array
|
||||
continue;
|
||||
}
|
||||
|
||||
$views[] = ViewFactory::make($section->view(), [
|
||||
...$section->data($theme, $stored['data'] ?? []),
|
||||
'theme' => $theme,
|
||||
'sectionId' => $section::key().'-'.$index,
|
||||
]);
|
||||
$data = $stored['data'] ?? [];
|
||||
$property = filled($data['property_id'] ?? null)
|
||||
? $theme->site->properties()->where('is_active', true)->whereKey($data['property_id'])->first()
|
||||
: $theme->property();
|
||||
|
||||
if (filled($data['property_id'] ?? null) && $property === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$views[] = $theme->runForProperty($property, fn (): SectionView => new SectionView(
|
||||
$theme,
|
||||
$property,
|
||||
ViewFactory::make($section->view(), [
|
||||
...$section->data($theme, $data),
|
||||
'theme' => $theme,
|
||||
'sectionId' => $section::key().'-'.$index,
|
||||
]),
|
||||
));
|
||||
}
|
||||
|
||||
return $views;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Themes;
|
||||
|
||||
use App\Models\Property;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
/**
|
||||
* Keeps the section's property active when the page eventually renders its Blade view and partials.
|
||||
*/
|
||||
class SectionView implements Renderable
|
||||
{
|
||||
public function __construct(
|
||||
private Theme $theme,
|
||||
private ?Property $property,
|
||||
private View $view,
|
||||
) {}
|
||||
|
||||
public function render(): string
|
||||
{
|
||||
return $this->theme->runForProperty($this->property, fn (): string => $this->view->render());
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Themes;
|
||||
|
||||
use App\ImageWorlds\ImageWorldManifest;
|
||||
use App\ImageWorlds\MotifRenderer;
|
||||
use App\Models\Appearance;
|
||||
use App\Models\Page;
|
||||
use App\Models\Photo;
|
||||
@@ -9,6 +11,7 @@
|
||||
use App\Models\Site;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
/**
|
||||
* The theme context of the current request: site, theme chain and appearance. Activating it registers the
|
||||
@@ -128,6 +131,39 @@ public function appearanceKey(): string
|
||||
return $this->appearance ? str($this->appearance->name)->slug()->toString() : 'standard';
|
||||
}
|
||||
|
||||
/**
|
||||
* A brand graphic of this website (logo, favicon, document logo), or null when none was uploaded.
|
||||
* The brand belongs to the landlord; the picture world belongs to the look. Templates that fall back
|
||||
* to their own graphic should ask for this first (A14/A22).
|
||||
*/
|
||||
public function brand(string $collection): ?string
|
||||
{
|
||||
return $this->site->exists ? $this->site->brandUrl($collection) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The graphic behind a picture-world slot (divider, closing, vignette.beach …). Templates ask for a
|
||||
* slot, never for a file, so the same template works in every picture world (A18/A19).
|
||||
*/
|
||||
public function motif(string $slot, ?string $class = null, ?string $label = null): HtmlString
|
||||
{
|
||||
return app(MotifRenderer::class)->render($slot, $class, $label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the current picture world fills this slot – for templates that want to leave out a whole
|
||||
* decorative block instead of rendering an empty one.
|
||||
*/
|
||||
public function hasMotif(string $slot): bool
|
||||
{
|
||||
return app(MotifRenderer::class)->has($slot);
|
||||
}
|
||||
|
||||
public function imageWorld(): ?ImageWorldManifest
|
||||
{
|
||||
return app(MotifRenderer::class)->world();
|
||||
}
|
||||
|
||||
public function property(): ?Property
|
||||
{
|
||||
if (! $this->propertyResolved) {
|
||||
@@ -138,6 +174,29 @@ public function property(): ?Property
|
||||
return $this->property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a section with its property, restoring the previous cache even when rendering fails.
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @param callable(): T $callback
|
||||
* @return T
|
||||
*/
|
||||
public function runForProperty(?Property $property, callable $callback): mixed
|
||||
{
|
||||
$previousProperty = $this->property;
|
||||
$previousResolved = $this->propertyResolved;
|
||||
$this->property = $property;
|
||||
$this->propertyResolved = true;
|
||||
|
||||
try {
|
||||
return $callback();
|
||||
} finally {
|
||||
$this->property = $previousProperty;
|
||||
$this->propertyResolved = $previousResolved;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Published pages of a menu location ("main" or "footer").
|
||||
*
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Picture worlds ("Bildwelten")
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Every folder below one of these paths that contains a world.json is a
|
||||
| picture world: the bands, vignettes and ornaments a website is dressed
|
||||
| in. Themes ask for a slot, never for a file (MANDANTEN-ANFORDERUNGEN
|
||||
| A18/A19), so the same theme can wear "Ostsee" or later "Berge".
|
||||
|
|
||||
*/
|
||||
|
||||
'paths' => [
|
||||
resource_path('image-worlds'),
|
||||
],
|
||||
|
||||
/*
|
||||
| Applies while a website has chosen none. Empty = no decoration at all.
|
||||
*/
|
||||
'default' => env('FEWO_IMAGE_WORLD', 'ostsee'),
|
||||
|
||||
];
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Two things the operator owns. The notice a suspended landlord's visitors see instead of a dead link,
|
||||
* and the settings of the whole installation – which, unlike the former `settings` table, belong to
|
||||
* nobody's landlord: they are the operator's, and a landlord's admin never reaches them.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
$table->text('suspended_message')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('system_settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('key')->unique();
|
||||
$table->text('value')->nullable();
|
||||
$table->boolean('is_secret')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('system_settings');
|
||||
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
$table->dropColumn('suspended_message');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use App\Tenancy\TenantDefaults;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Each landlord reads the portals' booking notifications from their own mailbox. An empty host means
|
||||
* the fast path is off for that landlord. The password is encrypted with APP_KEY like the bank details.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
$table->string('mailbox_host')->nullable();
|
||||
$table->unsignedSmallInteger('mailbox_port')->nullable();
|
||||
$table->string('mailbox_encryption', 10)->nullable();
|
||||
$table->string('mailbox_username')->nullable();
|
||||
$table->text('mailbox_password')->nullable();
|
||||
$table->string('mailbox_folder')->nullable();
|
||||
});
|
||||
|
||||
// Whatever the single-landlord installation had in its .env belongs to Stommer.
|
||||
$stommer = DB::table('tenants')->where('slug', 'stommer')->first();
|
||||
|
||||
if ($stommer !== null && filled(config('fewo.mailbox.host'))) {
|
||||
DB::table('tenants')->where('id', $stommer->id)->update(TenantDefaults::mailboxFromConfig());
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'mailbox_host', 'mailbox_port', 'mailbox_encryption',
|
||||
'mailbox_username', 'mailbox_password', 'mailbox_folder',
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* A website is dressed in a picture world; an apartment may wear a different one (A18/A20) – that is
|
||||
* the place for a mountain apartment on a coastal website. Empty means: the one above decides.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('sites', function (Blueprint $table) {
|
||||
$table->string('image_world')->nullable()->after('theme');
|
||||
});
|
||||
|
||||
Schema::table('properties', function (Blueprint $table) {
|
||||
$table->string('image_world')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('properties', function (Blueprint $table) {
|
||||
$table->dropColumn('image_world');
|
||||
});
|
||||
|
||||
Schema::table('sites', function (Blueprint $table) {
|
||||
$table->dropColumn('image_world');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -1,11 +1,12 @@
|
||||
# Deployment auf Strato
|
||||
|
||||
Stand: 22.10.2026 · Skript: `scripts/deploy.sh` · CI: `.gitea/workflows/deploy.yml`
|
||||
Stand: 26.10.2026 · Gemeinsamer Manager: [PipelineManager](https://gitea.stommer.de/Lars/PipelineManager) · Pilotkonfiguration: `pipeline.toml` · CI: `.gitea/workflows/deploy.yml`
|
||||
|
||||
## 1. Prinzip
|
||||
|
||||
```
|
||||
Gitea (main/Tag) ──► Build (CI oder lokal): git-Stand · composer --no-dev · npm run build
|
||||
Gitea (develop/main) ──► PipelineManager-Container auf Raspi5-Paperless
|
||||
│ exakter Git-Commit · Abhängigkeiten · Tests · fertige Assets
|
||||
│ tar.gz
|
||||
▼ SSH
|
||||
Strato <DEPLOY_PATH>/
|
||||
@@ -20,6 +21,10 @@ ## 1. Prinzip
|
||||
|
||||
Auf dem Server werden nur **bash, tar und PHP-CLI** gebraucht – kein Composer, kein Node, kein Git, kein rsync.
|
||||
|
||||
Die Werkzeugumgebung wird im eigenen Repository `C:\dev\pipelinemanager` entwickelt und als lokales Image `pipeline-manager:0.1.0` auf dem Pi freigegeben. Das Image bleibt nach dem Entfernen eines Job-Containers erhalten. Der Ablauf folgt Tsumugus Docker-Aufträgen auf dem vorhandenen Host-Runner (`ubuntu-latest`), führt Tests jedoch am exakten Commit vor dem Upload aus. Keine PHP-/Node-Installation auf dem Host und kein Build auf dem Entwicklungsrechner für automatische Deployments.
|
||||
|
||||
FeWo definiert nur seine prepare/test/finalize-Befehle, erforderlichen Dateien, Laravel-Hooks, persistenten Pfade und Ziele in `pipeline.toml`. Gemeinsame Paket-, Sicherungs-, Upload- und Rückfalllogik liegt im PipelineManager. Der bisherige manuelle Weg über `scripts/deploy.sh` bleibt als bestehender Wartungsweg erhalten, bis die neue Anbindung vollständig auf Test bestätigt ist.
|
||||
|
||||
## 2. SSH oder SFTP?
|
||||
|
||||
**Empfehlung: SSH.** Das Skript führt nach dem Hochladen Befehle auf dem Server aus (Archiv entpacken, Datenbank migrieren, Caches erzeugen, Version umschalten, ggf. zurückschalten). Das geht nur mit SSH.
|
||||
@@ -77,9 +82,13 @@ ## 4. Tägliche Nutzung
|
||||
|
||||
## 5. Automatisch über Gitea Actions
|
||||
|
||||
- Workflow `.gitea/workflows/deploy.yml`: **Tests bei jedem Push**; **Deployment** bei Tags `v*` (z. B. `git tag v1.0.0 && git push --tags`) oder per Knopfdruck (Actions › Deploy › Run workflow, Ziel production/staging).
|
||||
- Voraussetzung: Gitea Actions aktiviert und ein **act_runner** registriert – passt gut auf den privaten Server (Docker). Anleitung: Gitea-Doku „Act Runner“.
|
||||
- Repository-Secrets: `DEPLOY_SSH_KEY` (privater Schlüssel, dessen öffentlicher Teil bei Strato hinterlegt ist), `DEPLOY_HOST`, `DEPLOY_USER`, `DEPLOY_PATH`, `DEPLOY_PHP`, `DEPLOY_URL`.
|
||||
- Push auf `develop`: Manager-Image prüfen, FeWo vorbereiten und die Feature-Suite im Container ausführen, danach nach `test.fewo-stommer.de/` unter https://stommer.info deployen. Merge-Commit von `develop` nach `main`: derselbe Ablauf für `prod.fewo-stommer.de/`, sobald dieses Ziel ausdrücklich in `pipeline.toml` aktiviert ist.
|
||||
- Produktion ist derzeit `enabled=false`: Der Workflow überspringt Vorbereitung und Deployment. Eigenständige Produktionsdatenbank, `.env` und Domain-Zuordnung müssen vor Freigabe eingerichtet werden. Das bestehende WordPress-Verzeichnis `www.fewo-stommer.de/` bleibt unangetastet.
|
||||
- Die 18 Manager-Tests liegen im separaten Repository; die Anwendung behält ihre 285 Feature-Tests. Kein `setup-php`, kein `setup-node`, keine Toolinstallation auf dem Pi-Host. Der bisherige Node-24-/PHP-Setup-Fehler entfällt damit.
|
||||
- Build und Deployment laufen in getrennten Containeraufrufen mit UID/GID des Runners und Ressourcenlimits. Nur der Deployment-Container erhält die Strato-Zugänge. Er bekommt weder den Docker-Socket noch Verzeichnisse anderer Anwendungen.
|
||||
- Persistente Verzeichnisse auf dem Pi: `/home/lars/docker/pipeline-manager/cache` (Composer/npm) und `backups/<project>/<environment>` (Datenbank, Medien und Server-Konfiguration). Backups werden vor dem Upload geprüft; ein Fehler verhindert die Auslieferung. Eine Sperre auf Strato verhindert parallele Umschaltungen desselben Ziels.
|
||||
- Repository-Secrets vor dem ersten Deployment einrichten: `DEPLOY_HOST`, `DEPLOY_USER`, `DEPLOY_SSH_KEY` (Schlüsselinhalt), `DEPLOY_KNOWN_HOSTS` (geprüfter Hostschlüssel). Geheimnisse bleiben außerhalb von Image und Repository. Der Manager schreibt sie nur vorübergehend in geschützte Dateien. Im Repository waren bei Prüfung noch keine Secrets vorhanden.
|
||||
- Die auf dem Pi freigegebene Image-Version muss vor dem FeWo-Workflow vorhanden sein. Für weitere Runner mit anderer Architektur ist eine entsprechende Imagebereitstellung erforderlich. Erst nach erfolgreichem Pilotlauf wird der alte manuelle Deploy-Weg ersetzt.
|
||||
|
||||
## 6. Getestet / offen
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Mandantenfähigkeit – Umbauplan
|
||||
|
||||
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
|
||||
Stand: 24.10.2026 · **Phasen 1 bis 5 umgesetzt**, Phase 6 auf der Anwendungsseite ebenfalls. Offen: der Theme-Teil von Phase 6 (§6 der Zusammenarbeit) und Phase 7 · Anforderungen: [MANDANTEN-ANFORDERUNGEN.md](MANDANTEN-ANFORDERUNGEN.md) · Design: [DESIGN-KONZEPT.md](DESIGN-KONZEPT.md) §7 · Übergabe: [STATUS.md](STATUS.md) Abschnitt 7
|
||||
|
||||
Kein Portal, kein Marktplatz. Das Produkt bleibt die eigene Website eines Vermieters mit Vermietung. Wenige Mandanten, eine gemeinsame Datenbank, Laravel und Filament bleiben die Basis. Ein Python-Dienst ist nicht Teil dieses Umbaus.
|
||||
|
||||
@@ -234,33 +234,34 @@ ### Phase 3 – Einstellungen, Texte, Dienste-Grundlage · umgesetzt
|
||||
|
||||
- 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).
|
||||
- `tenant_services` und `service_usages`, Schalter nur im Betreiber-Bereich. Umgesetzt und am 24.10. **wirklich angeschlossen**: `App\Tenancy\TenantFeatures` wird in `RolePolicy::allows()`, beim Portal-Import, im iCal-Feed und im Postfach-Schnellweg abgefragt. Nur verdrahtete Dienste sind schaltbar (`TenantServiceKey::isWired()`); die KI-Dienste erscheinen erst, wenn die Anwendung sie abfragt. Eigene API-Schlüssel gehören dann in den Admin des Mandanten, nicht zum Betreiber (A16). `service_usages` steht bereit, es zählt noch nichts.
|
||||
- Tabelle `settings` entfernen. Umgesetzt.
|
||||
|
||||
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
|
||||
### Phase 4 – Domain, Cron, Mail, Postfach · umgesetzt
|
||||
|
||||
Ziel: Host, Erinnerungen und Portal-Mails gehören dem richtigen Mandanten.
|
||||
|
||||
- `site_domains`, 404 für unbekannte Hosts ab dem zweiten Mandanten. Umgesetzt. Mit genau einem Mandanten bleibt die Standard-Website auf jeder Adresse.
|
||||
- `site_domains`, 404 für unbekannte Hosts ab dem zweiten Mandanten. Umgesetzt. Mit genau einem Mandanten bleibt die Standard-Website auf jeder Adresse. Am 24.10. ergänzt: mehrere Adressen je Website im Admin, weil „www" ein eigener Host ist und das Feld „Domain" nur einen schrieb. Fremde Hosts werden abgelehnt.
|
||||
- Links mit dem Ursprung der Website. Umgesetzt für Angebot, Annahme, Bewertung und Einwilligung.
|
||||
- Scheduler-Schleife, Postfach je Mandant, Absender je Versand. Noch nicht.
|
||||
- Scheduler-Schleife, Postfach je Mandant, Absender je Versand. Umgesetzt am 24.10.: `App\Tenancy\TenantRunner` führt jeden Lauf einmal je aktivem Mandanten aus, mit gesetztem Kontext; ein scheiternder Mandant hält die anderen nicht auf. Die Datenbank-Sicherung bleibt global. Das Postfach liegt als `mailbox_*` am Mandanten (Passwort verschlüsselt, leerer Server = aus), steht im Mandanten-Admin und nur bei freigeschaltetem Dienst. Auch die Cache-Schlüssel der Postfach-Überwachung tragen den Mandanten.
|
||||
|
||||
Tests: Angebotslink trägt den Host der Website. Erinnerungslauf für A schreibt keine Mail an Gäste von B und nicht mit dem Absender von B. Postfach-Passwort von A ist aus dem Kontext von B nicht lesbar. iCal-Token von A liefert keine Belegung von B. Unbekannter Host bei zwei Mandanten: 404. Mit einem Mandanten: Standard-Website wie heute.
|
||||
|
||||
### Phase 5 – Abnahme der Trennung und Kündigung
|
||||
### Phase 5 – Abnahme der Trennung und Kündigung · umgesetzt
|
||||
|
||||
Ziel: Ein Befehl exportiert und löscht genau einen Mandanten (A25). Die Trennung ist als Suite festgehalten, nicht nur in den einzelnen Phasen.
|
||||
|
||||
- Befehl des Betreibers: Export (Daten + Dateien dieses Mandanten) und Löschung in der Reihenfolge, die die Fremdschlüssel erlauben, einschließlich Medien.
|
||||
- Eine Testklasse je Bereich aus A1: Wohnungen, Preise, Kalender, Buchungen, Zahlungen, Gäste, Bewertungen, Portale, Texte, Fotos, Seiten, Einstellungen, Benutzer.
|
||||
- Befehl des Betreibers: `tenants:export <slug>` und `tenants:delete <slug>` (exportiert erst, fragt nach, löscht dann einschließlich Medien). `App\Tenancy\TenantArchive`. Löschen ist bewusst **keine** Schaltfläche im Panel.
|
||||
- Konten, die nur zu diesem Mandanten gehörten, werden mitgelöscht; wer noch für einen anderen arbeitet, und der Betreiber bleiben. Der Export nennt die Konten mit Rolle, aber ohne Passwort-Hashes und ohne 2FA-Geheimnisse – er wird herausgegeben.
|
||||
- `tests/Feature/TenantSeparationTest.php` füllt jeden Bereich aus A1 für zwei Mandanten, exportiert und löscht einen und prüft den anderen Zeile für Zeile, auch die Hosts (die über die Website hängen und keine eigene `tenant_id` haben). Der Test merkt künftig, wenn eine neue Tabelle ihre `tenant_id` vergisst.
|
||||
|
||||
Tests: Nach der Löschung von A ist B vollständig da, inklusive Dateien und Buchungsnummern. Export von A enthält keine Zeile von B.
|
||||
|
||||
### Phase 6 – Marke und Bildwelt (danach, eigene Freigabe)
|
||||
### Phase 6 – Marke und Bildwelt · Anwendungsseite umgesetzt (24.10.), Theme-Teil offen
|
||||
|
||||
A14, A18, A19, A20, A22. Nicht zusammen mit Phase 1–5, und nicht solange der Branch `theme/<key>` die Vorlagen noch nicht nachziehen kann.
|
||||
|
||||
@@ -268,7 +269,11 @@ ### Phase 6 – Marke und Bildwelt (danach, eigene Freigabe)
|
||||
- Bildwelten als Pakete neben den Themes (`resources/image-worlds/<key>/`, Manifest und SVGs), analog zu Themes, nicht als Upload. Die Website wählt eine Bildwelt. Eine Wohnung kann sie überschreiben (A20); das ist die Stelle für die Berg-Wohnung, auch wenn Phase 7 die Auswahl in den Bausteinen erst danach scharf schaltet.
|
||||
- Themes sprechen nur Plätze an (Trenner, Abschlussband, Vignette), keine feste Ostsee-Datei (A19). Das ändert den Vorlagen-Vertrag. Vor der ersten geänderten Theme-Datei steht der Eintrag in ZUSAMMENARBEIT.md §6. Das parallel entstehende Theme wird nicht von dieser Sitzung editiert.
|
||||
|
||||
### Phase 7 – Mehrere Wohnungen je Website (zuletzt)
|
||||
**Umgesetzt am 24.10. (ohne eine Theme-Datei zu ändern):** Bildwelten als Pakete in `resources/image-worlds/<key>/`, Registry, Auswahl an der Website, Überschreibung an der Wohnung; `$theme->motif()`/`hasMotif()`/`imageWorld()` als Platz-API; `image-worlds:check`. Marke als Medien der Website mit `$theme->brand()`, eingebettet im Mietvertrag. Die Ostsee-Grafiken wurden **kopiert**, nicht verschoben.
|
||||
|
||||
**Offen und ein Vertragsfall (ZUSAMMENARBEIT.md §6):** `ostsee-licht` von `partials/brand` auf Plätze umstellen, das Favicon in beiden Themes zuerst bei `$theme->brand('favicon')` erfragen, und Seebads `motifs/`-Ordner gegen die Bildwelt tauschen. `public/brand/` entfällt erst danach.
|
||||
|
||||
### Phase 7 – Mehrere Wohnungen je Website (zuletzt, eigene Sitzung)
|
||||
|
||||
A21. Die Seite bleibt bei einer Wohnung, solange ein Baustein keine nennt.
|
||||
|
||||
@@ -290,6 +295,8 @@ ## 9. Betrieb und Abgrenzung
|
||||
|
||||
## 10. 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.
|
||||
**Phasen 1 bis 5 und die Anwendungsseite von Phase 6 sind umgesetzt und ausgeliefert** (Release `20261026065920`). Der Grundumbau ist damit fertig: Daten, Rollen, Einstellungen, Domains, Hintergrundläufe, Export und Kündigung, dazu Bildwelten und die Marke je Website. **Phase 7 schließt eine eigene Sitzung ab**; die Übergabe dafür steht in [STATUS.md](STATUS.md) Abschnitt 7. Die bisherigen Daten gehören zum Mandanten Stommer, `lars@stommer.com` ist Betreiber. Ausgelieferter Stand und Übergabe: [STATUS.md](STATUS.md) Abschnitt 7.
|
||||
|
||||
Offen und **nicht** Teil dieses Plans: Subscription und Abrechnung (§9 schließt sie aus; `service_usages` liegt als Grundlage bereit) sowie die Frage, ob Strato für die Domain eines Mandanten ein Zertifikat ausstellt – davon hängt ab, ob das Modell „Mandant bringt seine Domain mit" auf diesem Hosting trägt. Phase 6 und 7 warten auf eine eigene Freigabe und einen Eintrag in [ZUSAMMENARBEIT.md](ZUSAMMENARBEIT.md) §6.
|
||||
|
||||
Die Sicherheitsregel in §1 gilt: Passwort und 2FA gehören zum Konto, die Rolle zur Mitgliedschaft. Der Betreiber darf zusätzlich Mandanten-Administrator der eigenen Wohnung sein.
|
||||
@@ -1,6 +1,6 @@
|
||||
# Projektstand
|
||||
|
||||
Stand: 23.10.2026 · ausgelieferter Stand: `deploy/staging/20261023195835` · 235 Feature-Tests grün
|
||||
Stand: 26.10.2026 · ausgelieferter Stand: `deploy/staging/20261026072521` (`abf0e90`) · 285 Feature-Tests grün
|
||||
|
||||
> Dieses Dokument ist der Einstieg für jede neue Arbeitssitzung. Bitte bei größeren Änderungen fortschreiben (Abschnitte „Fertig“, „Offen“, „Nächste Schritte“).
|
||||
|
||||
@@ -70,7 +70,7 @@ ## 3. Offen
|
||||
**Technik**
|
||||
- Cronjob auf Strato einrichten (BETRIEB.md §6).
|
||||
- Design-Theme Seebad 0.3 ist auf `main` und auf stommer.info aktiv (Abschnitt 6).
|
||||
- Mandantenfähigkeit: Phase 1, 2, 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`.
|
||||
- Mandantenfähigkeit: **Phasen 1 bis 5, die Anwendungsseite von Phase 6 und der Kern von Phase 7 sind ausgeliefert**. Bausteine können eine aktive Wohnung ihrer Website wählen; leer = Hauptwohnung. 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:
|
||||
@@ -135,23 +135,64 @@ ## 6. Design-Theme „Seebad“ (Abschnitt der Design-Session)
|
||||
|
||||
## 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)
|
||||
Stand: 26.10.2026 · Phase-7-Kern auf `main` und Strato · 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.
|
||||
> **Ausgeliefert:** `20261026072521`, Commit `abf0e90`, aus aktuellem `main` nach `test.fewo-stommer.de/` (https://stommer.info). Sicherung davor: `C:\Dev\fewo-backups\staging\20261026-082223` (Datenbank und Dateien, 29 MB). Aktiven Pfad und `REVISION` per SSH geprüft; `/up`, `/`, `/wohnung`, `/buchen` und `/admin/login` liefern HTTP 200. Vor jedem weiteren Deploy sichern: `bash scripts/backup-pull.sh staging /c/Dev/fewo-backups/staging`, dann `bash scripts/deploy.sh staging deploy` (nur aus aktuellem `main`).
|
||||
|
||||
**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.
|
||||
**Der Grundumbau (Phasen 1–5) ist fertig.** Von Phase 6 ist die **Anwendungsseite gebaut** (Bildwelten, Marke je Website) – ohne eine einzige Theme-Datei zu ändern; der Rest ist ein Vertragsfall und steht als Aufgabe für die Theme-Sitzung in ZUSAMMENARBEIT.md §6: Favicon und die fest verdrahteten Grafiken in `ostsee-licht` auf `$theme->brand()` bzw. Plätze umstellen. Der Kern von Phase 7 ist ebenfalls umgesetzt und ausgeliefert. Nicht im Plan und offen: Subscription/Abrechnung und die Zertifikatsfrage bei Strato.
|
||||
|
||||
### Phase 7: Kern umgesetzt und ausgeliefert
|
||||
|
||||
Ziel (A21): Ein Baustein kann eine Wohnung **dieser Website** wählen; ohne Wahl gilt wie heute die Hauptwohnung. Voraussetzung für die Bergwohnung unter `fewo-stommer.de`.
|
||||
|
||||
**Ohne Theme-Änderung umgesetzt.** Alle Bausteine haben im Seiten-Baukasten das gemeinsame Feld „Wohnung“ (`data.property_id`). Die Auswahl und ihre Validierung erlauben nur aktive Wohnungen der Website der bearbeiteten Seite. Leer bleibt die Hauptwohnung. Ein Eintrag in [ZUSAMMENARBEIT.md](ZUSAMMENARBEIT.md) §6 wird erst fällig, wenn **neue** Bausteine dazukommen (Übersicht aller Wohnungen, Suche über mehrere) – diese gehören nicht zum Kern und brauchen eine Pflicht-Vorlage im Basis-Theme.
|
||||
|
||||
Die Umsetzung:
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| `app/Themes/Theme.php` | `runForProperty(?Property, callable)` setzt die Wohnung für einen Callback und stellt im `finally` beide bisherigen Cache-Werte wieder her, auch bei Verschachtelung oder Fehlern. |
|
||||
| `app/Themes/SectionRegistry.php`, `PageForm` | Gemeinsames Auswahlfeld für jeden Baustein. Der Renderer prüft Website-Zugehörigkeit und Aktivität erneut; fremde, inaktive oder gelöschte Zuordnungen werden übersprungen, ohne auf eine andere Wohnung umzulenken. |
|
||||
| `app/Themes/SectionView.php` | Die Ausgabe bleibt verzögert (`render()` wie bisher). Auch während Blade, Partials und Livewire laufen, ist die gewählte Wohnung aktiv; das gilt ebenso für die Bildwelt über den Theme-Kontext. Danach gilt wieder der vorherige Zustand. |
|
||||
|
||||
Tests: `tests/Feature/SectionPropertyTest.php` prüft in 13 Fällen gemischte Wohnungen auf einer Seite, Hauptwohnungs-Fallback, das Buchungsformular, verzögerte Ausgabe, verschachtelte Kontexte und Fehler sowie Speichern und Ablehnen im Admin über Website- und Mandantengrenzen. Gesamte Feature-Suite: **285 Tests, 1289 Assertions grün**; Pint ausgeführt. Keine neue Tabelle, Migration oder Abhängigkeit. Deployment erfolgreich, keine Migration offen.
|
||||
|
||||
**Gemeinsamer PipelineManager (26.10., Pilotanbindung auf `feature/pipeline-manager-integration`):** Eigenes Repository [Lars/PipelineManager](https://gitea.stommer.de/Lars/PipelineManager), lokal `C:\dev\pipelinemanager`. Werkzeug-Image mit PHP/Composer/Node/Python/Git/SSH und gemeinsame Tests, Paketprüfung, Sicherung, Upload, Umschaltung und Rückfall. Nach dem Vorbild von Tsumugu baut der vorhandene Runner `Raspi5-Paperless` das Image im Docker; Anwendungen starten daraus ihre Aufträge. Image und Download-Caches werden wiederverwendet. FeWo liefert nur `pipeline.toml` mit Laravel-Befehlen und Zielen. Push `develop` → `test.fewo-stommer.de/`, Merge nach `main` → `prod.fewo-stommer.de/`; Produktion bleibt ausdrücklich gesperrt. Das leere Produktionsverzeichnis ist bereits angelegt, ohne `.env` oder Datenbank-Anbindung. Keine PHP-/Node-Installation mehr auf dem Host vorgesehen.
|
||||
|
||||
Der frühere lokale Paket-/Registry-Ansatz bleibt unveröffentlicht auf `feature/artifact-pipeline` und ist nicht Bestandteil der Pilotanbindung. Anwendung und Theme-Dateien unverändert. Manager-Stand `0e44a42`: **18 Manager-Tests lokal grün, Docker-Build und Werkzeugprüfungen auf Raspi5-Paperless grün** ([Gitea-Lauf 4648](https://gitea.stommer.de/Lars/PipelineManager/actions/runs/4648)). Version `v0.1.0` ist zur Image-Freigabe markiert. Die Verzeichnisse für Cache und Backups liegen unter `/home/lars/docker/pipeline-manager/`; der Manager veröffentlicht keine Ports. Vor dem ersten automatischen FeWo-Deployment fehlen noch die Strato-Zugänge als Gitea-Secrets. Der aktuelle Strato-Release steht oben; Tsumugu wurde ausschließlich gelesen.
|
||||
|
||||
**Nicht vergessen:** Jede neue Tabelle bekommt `tenant_id` von Anfang an und gehört in `TenantArchive::DELETE_ORDER`, sonst überlebt sie die Kündigung ihres Mandanten. `tests/Feature/TenantSeparationTest.php` merkt das – aber nur, wenn der Testaufbau dort die neue Tabelle auch füllt.
|
||||
|
||||
### Ebenfalls offen
|
||||
|
||||
- **Theme-Teil von Phase 6:** Favicon und `partials/brand` in beiden Themes auf `$theme->brand()` bzw. Plätze umstellen, Seebads `motifs/`-Ordner gegen die Bildwelt tauschen. Steht als Aufgabe in ZUSAMMENARBEIT.md §6 und gehört der Theme-Sitzung.
|
||||
- **Subscription und Abrechnung** – nicht Teil des Mandanten-Plans (§9 schließt sie aus). `service_usages` liegt als Grundlage bereit und zählt nichts.
|
||||
- **Zertifikatsfrage bei Strato:** Ob eine Domain eines Mandanten aufgeschaltet werden kann **und** ein Zertifikat bekommt. Eine Subdomain bekommt keines. Davon hängt ab, ob „Mandant bringt seine Domain mit“ auf diesem Hosting trägt – das ist keine Code-Frage.
|
||||
|
||||
**Phase 3 ist ausgeliefert** (23.10.2026 abends). Die Migrationen sind auf der MariaDB von stommer.info durch, `settings` ist weg, die Werte stehen am Mandanten Stommer.
|
||||
|
||||
**Dienste-Steuerung und Host-Verwaltung sind ausgeliefert** (24.10.2026, Release `20261024072737`). Seitdem läuft stommer.info mit **zwei** Mandanten:
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| Mandant 1 | `stommer` – die bestehenden Daten, Website „Ferienwohnung Stommer" |
|
||||
| Mandant 2 | `testmandant` („Testmandant (Probe)") – **ohne Website und damit unter keiner Adresse erreichbar**. Das ist jetzt ein richtiger Zustand, kein Fehler: Einsprungsadressen vergibt der Betreiber, und dieser Mandant hat noch keine. Soll er erreichbar werden, braucht er eine Domain, die bei Strato auf dieses Verzeichnis zeigt. Betriebsart Test, Mails fallen auf `FEWO_NOTIFICATION_EMAIL` zurück. |
|
||||
| Hosts | An der Website von Stommer stehen jetzt `stommer.info` (Hauptadresse) **und** `www.stommer.info`. Das war die Voraussetzung: ab dem zweiten Mandanten bekommt jede nicht eingetragene Adresse 404. |
|
||||
| Geprüft nach dem Anlegen | `/`, `/wohnung`, `/buchen` auf beiden Hosts 200 und weiterhin Inhalte von Stommer; `/admin` und `/betreiber` 302. |
|
||||
|
||||
### Ausgeliefert
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| Server | nur **stommer.info** (Staging). `www.fewo-stommer.de` ist unberührt und bleibt WordPress. |
|
||||
| Release | `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. |
|
||||
| Release | `20261026065920` (**Phasen 1–5 plus Anwendungsseite von Phase 6**). Frühere Tags desselben Tages: `20261024151841` und `20261024152057` zeigen auf denselben Commit – ein Deploy wurde wiederholt, weil die erste Ausgabe durch einen Absturz verloren ging. |
|
||||
| Code danach | Commits auf `main` nach `361acfa` 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. |
|
||||
| Sicherung davor | `C:\Dev\fewo-backups\staging\20261026-075730`; davor `…\20261024-171534`, `…\20261024-102031`, `…\20261024-092543` und `…\20261023-215553` (die letzte mit noch vorhandener `settings`-Tabelle). Erstellt mit `scripts/backup-pull.sh staging`. Ein Rollback der Version nimmt die Migration **nicht** zurück. |
|
||||
| Konto | `php artisan users:promote-operator lars@stommer.com` ist auf dem Server gelaufen. Passwort und 2FA sind gleich geblieben. |
|
||||
| Prüfung | `https://stommer.info/`, `/wohnung` und `/buchen` antworten 200 und zeigen weiter Seebad und Stommer samt Vermieterdaten aus den Mandanten-Spalten. `/admin` und `/betreiber` leiten ohne Anmeldung auf die Login-Seite um (302). Betriebsart Testbetrieb, Umleitung an `lars@stommer.com`. **Noch nicht angemeldet geprüft:** die Seite System › Betrieb mit den neuen Abschnitten. |
|
||||
| Prüfung (24.10., nach Phase 4/5) | `/`, `/wohnung`, `/buchen` auf beiden Hosts 200; `/admin` und `/betreiber` 302. `bookings:expire-holds` läuft nachweislich **je Mandant** („Stommer: 0 …“, „Testmandant (Probe): 0 …“). `tenants:export testmandant` einmal auf dem Server ausgeführt; Exporte landen über den Symlink in `shared/storage/app/private/exports` (überleben jeden Deploy) und sind aus dem Web mit 403 gesperrt. **Nicht geprüft:** `tenants:delete` auf echten Daten – es löscht Dateien. |
|
||||
| Prüfung (26.10., nach Phase 6) | `/`, `/wohnung`, `/buchen` auf beiden Hosts 200 und weiter Inhalte von Stommer; `/admin` und `/betreiber` 302. `image-worlds:check` meldet die Bildwelt `ostsee` mit 11 Plätzen. Spalten `image_world` sind leer, also greift die Vorgabe der Installation: `$theme->imageWorld()` liefert `ostsee`, `$theme->motif(‚divider‘)` ein SVG von 1897 Zeichen mit `aria-hidden`. `$theme->brand(‘logo‘)` ist null – es wurde noch kein Logo hochgeladen, der Vertrag bleibt dadurch wie bisher. |
|
||||
|
||||
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.
|
||||
|
||||
@@ -160,7 +201,7 @@ ### Ausgeliefert
|
||||
### Nicht anfassen, solange es nicht der Auftrag ist
|
||||
|
||||
- `resources/themes/**`. Seebad 0.3 ist auf stommer.info aktiv. Eine neue Theme-Datei erst nach Eintrag in ZUSAMMENARBEIT.md §6.
|
||||
- Keinen zweiten Mandanten anlegen, bevor an der Website von Stommer der Host `stommer.info` steht (Webseite › Website, Feld Domain). Die Domain ist leer. Mit genau einem Mandanten liefert jeder Host die Standard-Website. Ab dem zweiten Mandanten antwortet ein unbekannter Host mit 404, `is_default` rettet ihn nicht. `www` ist ein eigener Host.
|
||||
- Die Hosts stehen jetzt (`stommer.info`, `www.stommer.info`), und es gibt zwei Mandanten. Jede weitere Adresse muss **vor** ihrer Benutzung in Webseite › Website eingetragen werden, sonst 404. `is_default` rettet einen unbekannten Host nicht.
|
||||
- `users.role` nicht löschen. Die Mitgliedschaft in `tenant_user` gilt; die Spalte bleibt der Übergang, wenn es genau einen Mandanten gibt und noch kein Kontext gesetzt ist.
|
||||
- `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.
|
||||
@@ -185,14 +226,28 @@ ### So ist es gebaut
|
||||
| Betrieb (Phase 3) | Die Seite System › Betrieb schreibt jetzt den Mandanten des Kontextes (`Settings::tenant()`), nicht mehr die Tabelle `settings`. Sie enthält zusätzlich Vermieterdaten, Bank, Steuerangabe und die Fristen. Bank, Steuerangabe und Dienst-Schlüssel liegen über das `encrypted`-Cast verschlüsselt (`APP_KEY`). |
|
||||
| Dienste (Phase 3) | `tenant_services` (Mandant, Schlüssel aus `App\Enums\TenantServiceKey`, an/aus, eigener API-Schlüssel) wird nur im Betreiber-Bereich am Mandanten-Formular geschaltet. `service_usages` steht bereit; es zählt noch nichts, weil kein Dienst aufruft. |
|
||||
| `settings` | Entfernt. Modell `App\Models\Setting` gelöscht, `Settings::get/save` gibt es nicht mehr. |
|
||||
| Läufe je Mandant (24.10.) | `App\Tenancy\TenantRunner` führt jeden Hintergrundlauf einmal je aktivem Mandanten aus, mit gesetztem Kontext (`routes/console.php` und die Befehle `bookings:expire-holds`, `channels:sync`, `channels:fetch-mail`). Ohne ihn sah der Scheduler bei zwei Mandanten **keinen** – Abfragen filterten nicht und der Absender fiel auf die `.env` zurück. Ein scheiternder Mandant hält die anderen nicht auf (Log-Eintrag). Die Datenbank-Sicherung bleibt global. |
|
||||
| Postfach (24.10.) | Gehört dem Mandanten (`mailbox_*`, Passwort verschlüsselt, leerer Server = aus). Im Mandanten-Admin, sichtbar nur bei freigeschaltetem Dienst `portal_mail`. Die Cache-Schlüssel der Überwachung tragen den Mandanten. |
|
||||
| Kündigung (24.10.) | `php artisan tenants:export <slug>` schreibt Zeilen und Dateien in ein Zip; `tenants:delete <slug>` exportiert erst, fragt nach und löscht dann einschließlich Medien. **Löschen ist bewusst keine Schaltfläche im Panel.** Konten, die nur zu diesem Mandanten gehörten, gehen mit; wer noch woanders arbeitet, und der Betreiber bleiben. Der Export nennt Konten mit Rolle, ohne Passwort-Hashes und ohne 2FA-Geheimnisse. Exporte liegen in `storage/app/private/exports` (nicht im Web, nicht in Git). |
|
||||
| Dienste (24.10.) | `App\Tenancy\TenantFeatures` ist die einzige Stelle, die beantwortet, ob ein Mandant einen Dienst hat. Abgefragt in `RolePolicy::allows()` (damit in **jeder** Richtlinie des Admins), in `Channel::importsOccupations()`, im öffentlichen iCal-Feed und im Postfach-Schnellweg. Keine Rolle wiegt einen gesperrten Dienst auf. `TenantServiceKey::isWired()` trennt Gebautes von Geplantem: nur verdrahtete Dienste sind schaltbar, die drei KI-Dienste stehen als Hinweis. Eigene API-Schlüssel gehören später in den Admin des Mandanten, nicht zum Betreiber. |
|
||||
| Bildwelten (24.10.) | Pakete in `resources/image-worlds/<key>/` (`world.json` + `svg/`), analog zu Themes. Website wählt, Wohnung darf überschreiben (A20). Vorlagen fragen über `$theme->motif($slot, $class, $label)` nach einem **Platz**, nie nach einer Datei (A19). Ein leerer Platz ist kein Fehler – es gibt dann keine Dekoration; `php artisan image-worlds:check` meldet Plätze ohne Datei. Die Ids im SVG werden je Aufruf eindeutig gemacht, sonst teilen sich zwei Kopien einer Grafik ihren Verlauf. Die Ostsee-Grafiken sind nach `image-worlds/ostsee` **kopiert**; `resources/themes/seebad/motifs/` ist unberührt, bis die Theme-Sitzung umstellt. |
|
||||
| Marke (24.10.) | Logo, Favicon und Logo für E-Mail/Vertrag als Medien der **Website** (A14/A22), gepflegt unter Webseite › Website › Marke. `$theme->brand(...)` für Vorlagen. Der Mietvertrag bettet die Datei ein statt eine URL zu holen. Ohne Logo bleibt alles wie bisher. **Noch nicht umgestellt:** Favicon und `partials/brand` in den Themes – §6. |
|
||||
| Einsprungsadressen (24.10.) | Gehören dem **Betreiber**: Mandanten-Formular › Einsprungsadressen, je Website eine Liste von Adressen. Die erste ist die Hauptadresse und steht in Gästelinks. Beim Anlegen entstehen Website, Host-Einträge und eine leere Startseite – ohne Startseite antwortet die Website 404. Im Mandanten-Admin sind die Adressen nur sichtbar. Eine fremde Adresse wird abgelehnt. Die Domain beim Hoster auf das Verzeichnis zu legen bleibt ein Schritt von Hand, auch bei Domains, die dem Mandanten gehören. |
|
||||
| Links (24.10.) | `URL::forceRootUrl(APP_URL)` zwang **alle** Links auf einen festen Host – mit einem Mandanten unsichtbar, mit zwei Domains hätte jeder interne Link der zweiten Website auf die erste gezeigt. `ResolveTheme` setzt den Ursprung jetzt auf die **Hauptadresse der aufgelösten Website**. Wer über eine Nebenadresse kommt (`www`), bekommt trotzdem Links auf die Hauptadresse – ein kanonischer Host. |
|
||||
| Gesperrter Mandant (24.10.) | Statt 404 eine schlichte Hinweisseite mit Status **503**, Text je Mandant einstellbar (sonst Standardtext). 503 hält die Seiten im Suchindex, weil eine Sperre vorübergehend ist. Gilt auch für `/admin` des Mandanten; der Betreiber kommt weiter hinein. |
|
||||
| Systemweite Einstellungen (24.10.) | Betreiber › Einstellungen, gespeichert in `system_settings`: Löschfristen, Bot-Schutz, Flutgrenze, Sicherungen, Portal-Fristen, Versandweg, SMTP, harte Mail-Umleitung, Tokens. **Leer = der Wert der `.env` gilt wieder**, und zwar sofort. Geheimnisse liegen verschlüsselt. Datenbank-Zugang und `APP_KEY` sind nicht dabei und können es nicht sein: sie werden gebraucht, um die Datenbank zu öffnen und das Gespeicherte zu entschlüsseln. Betreiber › System bleibt die Übersicht (Mandanten, geltende Werte, Zugriffsprotokoll). |
|
||||
| Noch global | Postfach, Absender des Scheduler-Laufs und der Scheduler selbst kennen keinen Mandanten (Rest von Phase 4). Der Cronjob auf Strato ist weiterhin nicht eingerichtet, der Versandweg ist `log`. Das ist mit einem Mandanten der bisherige Betrieb. Ein Mandant ohne eigene Adressen fällt für die Testumleitung auf `FEWO_NOTIFICATION_EMAIL` zurück, damit nichts versehentlich an echte Gäste geht. |
|
||||
|
||||
Tests dazu: `tests/Feature/TenantIsolationTest.php`, `TenantAccessTest.php`, `WebsiteTenancyTest.php`, `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`.
|
||||
Tests dazu: `TenantIsolationTest`, `TenantAccessTest`, `WebsiteTenancyTest`, `TenantSettingsTest`, `OperationsModeTest`, `TenantServiceGateTest`, `TenantProvisioningTest`, `SystemSettingsTest`, `TenantScheduleTest` und `TenantSeparationTest` (alle in `tests/Feature`). Zuletzt 262 Feature-Tests grün. PHP auf diesem Rechner: `%LOCALAPPDATA%\Microsoft\WinGet\Packages\PHP.PHP.NTS.8.4_*\php.exe`, nicht im PATH der Git-Bash. Für `scripts/deploy.sh` von hier `COMPOSER_BIN` auf `php …/composer/composer.phar` setzen, sonst findet die Bash kein `composer`.
|
||||
|
||||
### Offen, aber nicht in derselben Sitzung nötig gewesen
|
||||
|
||||
- Rest von Phase 4 und Phase 5. Jede davon bringt eigene Migrationen. Auslieferung und Migration wieder in einem Schritt, nach Sicherung.
|
||||
- **Bankverbindung eintragen:** Die `.env` von stommer.info hat keine `FEWO_BANK_*`-Werte, deshalb sind Kontoinhaber, IBAN, BIC und Bank am Mandanten leer (wie vorher auch). Sie gehören jetzt in System › Betrieb › Bankverbindung und Steuer; `mail/partials/bank.blade.php` und der Vertrag zeigen den Block erst, wenn eine IBAN da ist.
|
||||
- **Testmandant wieder loswerden,** wenn er nicht mehr gebraucht wird. Löschen ist erst Phase 5; bis dahin im Betreiber-Bereich den Zugang ausschalten.
|
||||
- **Noch nicht am lebenden Server geprüft:** die Hinweisseite eines gesperrten Mandanten und das Anlegen einer Website über den Betreiber-Admin. Beides deckt die Testsuite ab, aber es fehlt eine Domain, unter der sich ein zweiter Mandant wirklich zeigen ließe.
|
||||
- **Subscription** (was ein Mandant bucht, Abrechnung) ist noch nirgends abgebildet. `service_usages` steht als Grundlage bereit, es zählt nichts.
|
||||
- **Vor jeder weiteren Adresse:** Jede Schreibweise ist ein eigener Host. Kommt `fewo-stommer.de` dazu, gehören `fewo-stommer.de` **und** `www.fewo-stommer.de` in das Feld „Weitere Adressen", sonst antwortet eine davon mit 404.
|
||||
- Betreiber-Bereich https://stommer.info/betreiber einmal öffnen. Der Admin ist geprüft.
|
||||
- Host `stommer.info` an der Website eintragen, bevor ein zweiter Mandant entsteht. Später ebenso `www` und `fewo-stommer.de`, wenn die Produktion umzieht.
|
||||
- Brigitte, Cronjob, SMTP, Rechtstexte: Abschnitt 4, unverändert und unabhängig vom Mandanten-Code.
|
||||
|
||||
@@ -34,7 +34,7 @@ # … arbeiten (docs/THEME-ERSTELLUNG.md) …
|
||||
|
||||
## 3. Ausliefern (Deployment)
|
||||
|
||||
- **Nur aus `main`, nur nach `git pull`, nur mit grünen Tests.** Das Skript baut den letzten Commit des **lokalen** Stands. Wer aus einem Feature- oder Theme-Branch ausliefert, nimmt alle Änderungen der anderen Session vom Server.
|
||||
- **Zielablauf mit PipelineManager:** Feature- und Theme-Branches gehen nach `develop`; dessen Push startet Tests und Deployment auf das Testsystem. Produktion entsteht durch Merge-Commit `develop` → `main` und ist bis zur Einrichtung gesperrt. Gemeinsame Deployment-Werkzeuge werden im separaten Repository PipelineManager gepflegt. Details und Freigabestand: `docs/DEPLOYMENT.md`, `docs/STATUS.md`. Bis der Pilot bestätigt ist, bleibt der bestehende manuelle Weg aus aktuellem `main` verfügbar.
|
||||
- Theme-Vorschau auf stommer.info: erst nach dem Zusammenführen in `main`, dann `bash scripts/deploy.sh staging deploy` und `bash scripts/deploy.sh staging artisan themes:preview <key>` (gibt die Vorschau-Links aus).
|
||||
- Das neue Theme aktivieren (Admin › System › Websites › Theme) entscheidet Lars, nach Sichtung der Vorschau.
|
||||
- `shared/.env` auf dem Server ändert nur Lars (Passwörter); Sessions ändern dort höchstens nicht geheime Werte und dokumentieren das in BETRIEB.md.
|
||||
@@ -74,7 +74,7 @@ ## 5. Wünsche der Design-Session an die Anwendung
|
||||
| 23.10.2026 | **Darstellungsvarianten je Baustein** (`theme.json › variants`), Feld „Darstellung“ im Seiten-Baukasten (DESIGN-KONZEPT §7 Nr. 2) | offen |
|
||||
| 23.10.2026 | **Baustein „Tipps der Gastgeberin“**: Orte mit Kategorie (Strand, Seebrücke, Bahn, Rad, Wald …), Weg/Gehzeit, Text, Foto, Karten-Link; saisonal filterbar. Seebad zeigt je Kategorie eine Vignette der Bildwelt (DESIGN-KONZEPT §7 Nr. 4) | offen |
|
||||
| 23.10.2026 | **Baustein „Gut zu wissen“**: strukturierte Angaben (Zugang/Stufen, Dusche, Rollstuhl, Haustiere, An-/Abreisezeiten, Parken) an der Wohnung; Seebad stellt ihn in der Kartusche dar (DESIGN-KONZEPT §7 Nr. 5) | offen |
|
||||
| 23.10.2026 | **Bildwelt-System** (MANDANTEN-ANFORDERUNGEN A18–A20): Seebad nutzt schon Plätze über `partials/motif` (`mark`, `divider`, `closing`, `crest`, `gulls`, `vignette.*`) | offen |
|
||||
| 23.10.2026 | **Bildwelt-System** (MANDANTEN-ANFORDERUNGEN A18–A20): Seebad nutzt schon Plätze über `partials/motif` (`mark`, `divider`, `closing`, `crest`, `gulls`, `vignette.*`) | **erledigt in `4e66add`** – Anwendungsseite steht, siehe §6 |
|
||||
| 23.10.2026 | Hilfetext „*Wort* wird hervorgehoben“ im Titelbereich ist theme-abhängig (Seebad hebt nicht hervor) – Hinweis neutral formulieren | offen |
|
||||
| 23.10.2026 | **Menübild je Seite** (Feld an der Seite, Auswahl aus den Fotos, `PhotoSelect`) und optional ein kurzer **Menütext** – Seebad zeigt beides in den Menü-Tafeln; heute nur SEO-Beschreibung und Sprunglinks | offen |
|
||||
|
||||
@@ -89,4 +89,6 @@ ## 6. Änderungsprotokoll Vorlagen-Vertrag
|
||||
| 22.10.2026 | `hero`: `$featuredOffer` (wichtigstes hervorgehobenes Angebot oder null) | sections/hero |
|
||||
| 22.10.2026 | `offers`: `$display` (grid/list/rotating), `$offers` = `AdvertisedOffer` (Termin, Preis, `bookingUrl()`); rollierend über `data-rotator*` | sections/offers |
|
||||
| 23.10.2026 | **Neuer Baustein `floor_plan`** (Grundriss interaktiv): Vertrag in THEMES.md §5; Basis-Vorlage `ostsee-licht/views/sections/floor_plan.blade.php` (ohne JS: Flächen springen zur Raumliste), Seebad interaktiv (`theme.js` `initFloorPlans`). Neue Themes brauchen keine eigene Vorlage (Vererbung) | sections/floor_plan |
|
||||
| 24.10.2026 | **Bildwelt-System steht (Anwendungsseite).** `$theme->motif($slot, $class, $label)` liefert das Inline-SVG des Platzes, `$theme->hasMotif($slot)` sagt, ob der Platz gefüllt ist, `$theme->imageWorld()` nennt die aktive Bildwelt. Bildwelten liegen in `resources/image-worlds/<key>/` (`world.json` + `svg/`), Auswahl an der Website, Überschreibung an der Wohnung. Die Ostsee-Grafiken sind als Bildwelt `ostsee` **kopiert** – `resources/themes/seebad/motifs/` ist unverändert. **Seebad kann jetzt** sein `partials/motif.blade.php` auf `{!! $theme->motif($slot, $class ?? null, $label ?? null) !!}` verkürzen und seinen `motifs/`-Ordner löschen. `php artisan image-worlds:check` zeigt, welcher Platz von welcher Bildwelt gefüllt wird. | sections/*, partials/motif |
|
||||
| 24.10.2026 | **Marke je Website** (A14/A22): `$theme->brand('logo'|'favicon'|'document_logo')` liefert die URL oder null. Gepflegt unter Webseite › Website › Marke. **Noch offen und ein Fall für euch:** `ostsee-licht/views/layouts/app.blade.php` holt das Favicon aus `public/brand/`, Seebad aus seinen eigenen Assets – beide sollten zuerst `$theme->brand('favicon')` fragen und nur sonst auf ihre eigene Datei zurückfallen. Dasselbe gilt für `ostsee-licht/views/partials/brand.blade.php`, das noch fest verdrahtete Ostsee-Grafiken zeigt (A19). | layouts/app, partials/brand |
|
||||
| 22.10.2026 | Seiten außerhalb der Bausteine, die das Theme-Layout nutzen: Angebotsseite `resources/views/offer.blade.php`, Bewertung `resources/views/review.blade.php` – beim Theme-Test mitprüfen | layouts/app |
|
||||
@@ -0,0 +1,63 @@
|
||||
schema = 1
|
||||
project = "fewo-stommer"
|
||||
manager = "0.1.0"
|
||||
|
||||
[build]
|
||||
prepare = [
|
||||
["composer", "install", "--prefer-dist", "--no-interaction", "--no-progress"],
|
||||
["npm", "ci", "--no-audit", "--no-fund"],
|
||||
["npm", "run", "build"],
|
||||
["php", "-r", "copy('.env.example', '.env');"],
|
||||
["php", "artisan", "key:generate", "--no-interaction"],
|
||||
]
|
||||
test = [["php", "artisan", "test", "--compact", "--testsuite=Feature"]]
|
||||
finalize = [
|
||||
["composer", "install", "--no-dev", "--prefer-dist", "--optimize-autoloader", "--no-interaction", "--no-progress"],
|
||||
["php", "artisan", "optimize:clear", "--no-interaction"],
|
||||
]
|
||||
exclude = [
|
||||
"node_modules", "tests", "docs", "styles", "scripts", "storage", ".gitea", ".github",
|
||||
".claude", ".codex", ".ai", ".cursor", "AGENTS.md", "CLAUDE.md", "phpunit.xml",
|
||||
"pipeline.toml", "boost.json", "vendor/laravel/boost", "vendor/laravel/pao",
|
||||
]
|
||||
required = ["artisan", "vendor/autoload.php", "public/index.php", "public/build/manifest.json"]
|
||||
|
||||
[build.environment]
|
||||
APP_ENV = "testing"
|
||||
DB_CONNECTION = "sqlite"
|
||||
DB_DATABASE = ":memory:"
|
||||
DB_URL = ""
|
||||
MAIL_MAILER = "array"
|
||||
CACHE_STORE = "array"
|
||||
SESSION_DRIVER = "array"
|
||||
QUEUE_CONNECTION = "sync"
|
||||
|
||||
[remote]
|
||||
public = "public"
|
||||
backup = [["@php", "artisan", "backup:database", "--no-interaction"]]
|
||||
activate = [
|
||||
["@php", "artisan", "migrate", "--force", "--no-interaction"],
|
||||
["@php", "artisan", "optimize", "--no-interaction"],
|
||||
["@php", "artisan", "filament:optimize", "--no-interaction"],
|
||||
]
|
||||
|
||||
[remote.shared]
|
||||
".env" = ".env"
|
||||
storage = "storage"
|
||||
"public/storage" = "storage/app/public"
|
||||
|
||||
[targets.staging]
|
||||
branch = "develop"
|
||||
path = "test.fewo-stommer.de"
|
||||
url = "https://stommer.info"
|
||||
php = "/opt/RZphp84/bin/php-cli"
|
||||
enabled = true
|
||||
|
||||
[targets.production]
|
||||
branch = "main"
|
||||
require_merge = true
|
||||
source_branch = "develop"
|
||||
path = "prod.fewo-stommer.de"
|
||||
url = "https://www.fewo-stommer.de"
|
||||
php = "/opt/RZphp84/bin/php-cli"
|
||||
enabled = false
|
||||
@@ -0,0 +1,20 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1600 150" preserveAspectRatio="xMidYMid meet" role="presentation" aria-hidden="true">
|
||||
<defs><clipPath id="band-pier-horizon"><rect x="1160" y="20" width="140" height="78"/></clipPath></defs>
|
||||
<circle cx="1230" cy="98" r="50" fill="var(--brand-sun, #F2C27A)" clip-path="url(#band-pier-horizon)"/>
|
||||
<g fill="var(--brand-navy, #0B2E55)">
|
||||
<rect x="1100" y="92" width="380" height="6" rx="1"/>
|
||||
<rect x="1100" y="80" width="300" height="2.5"/>
|
||||
<path d="M1108 80 V92 M1126 80 V92 M1144 80 V92 M1162 80 V92 M1180 80 V92 M1198 80 V92 M1216 80 V92 M1234 80 V92 M1252 80 V92 M1270 80 V92 M1288 80 V92 M1306 80 V92 M1324 80 V92 M1342 80 V92 M1360 80 V92 M1378 80 V92" stroke="var(--brand-navy, #0B2E55)" stroke-width="2"/>
|
||||
<path d="M1112 98 H1117 V112 H1112 Z M1150 98 H1155 V112 H1150 Z M1188 98 H1193 V112 H1188 Z M1226 98 H1231 V112 H1226 Z M1264 98 H1269 V112 H1264 Z M1302 98 H1307 V112 H1302 Z M1340 98 H1345 V112 H1340 Z M1378 98 H1383 V112 H1378 Z M1416 98 H1421 V112 H1416 Z M1454 98 H1459 V112 H1454 Z"/>
|
||||
<rect x="1410" y="72" width="44" height="20"/>
|
||||
<path d="M1404 74 L1432 50 L1460 74 Z"/>
|
||||
<path d="M1430 50 L1432 34 L1434 50 Z"/>
|
||||
<rect x="1160" y="56" width="2" height="24"/>
|
||||
<path d="M1162 56 L1174 60 L1162 64 Z"/>
|
||||
<rect x="1380" y="60" width="2" height="20"/>
|
||||
<path d="M1382 60 L1392 64 L1382 68 Z"/>
|
||||
</g>
|
||||
<path fill="none" stroke="var(--brand-navy, #0B2E55)" stroke-width="3" stroke-linecap="round" d="M1060 44 Q1068 36 1076 44 Q1084 34 1094 40 M1020 64 Q1025 59 1030 64 Q1035 58 1041 61"/>
|
||||
<path fill="var(--brand-teal, #0286A2)" d="M10 104 C200 70 400 68 600 90 C800 112 1000 112 1200 106 C1350 102 1480 96 1590 80 C1440 130 1260 126 1100 120 C900 114 760 120 600 108 C400 88 200 92 10 104 Z"/>
|
||||
<path fill="var(--brand-wave, #6DBFC2)" d="M60 122 C240 102 420 104 600 120 C800 136 1000 130 1200 124 C1340 120 1460 116 1540 110 C1400 142 1220 142 1060 136 C900 132 760 136 600 130 C420 118 240 116 60 122 Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.0 KiB |
@@ -0,0 +1,21 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1600 150" preserveAspectRatio="xMidYMid meet" role="presentation" aria-hidden="true">
|
||||
<defs><clipPath id="band-sonne-horizon"><rect x="740" y="20" width="120" height="78"/></clipPath></defs>
|
||||
<circle cx="800" cy="98" r="44" fill="var(--brand-sun, #F2C27A)" clip-path="url(#band-sonne-horizon)"/>
|
||||
<path fill="var(--brand-sun, #F2C27A)" d="M760 104 H840 A3 3 0 0 1 840 110 H760 A3 3 0 0 1 760 104 Z M776 118 H824 A3 3 0 0 1 824 124 H776 A3 3 0 0 1 776 118 Z"/>
|
||||
<g fill="var(--brand-reed, #C9A15E)" transform="translate(744 100) scale(-1 1)">
|
||||
<path d="M0 0 C-4 -20 -14 -38 -30 -50 C-18 -34 -10 -18 -4 0 Z"/>
|
||||
<path d="M2 0 C2 -22 -2 -42 -12 -62 C-4 -40 -2 -20 -2 0 Z"/>
|
||||
<path d="M4 0 C8 -18 16 -34 28 -46 C18 -30 10 -16 8 0 Z"/>
|
||||
<path d="M6 0 C14 -12 24 -22 36 -26 C26 -18 16 -8 10 0 Z"/>
|
||||
<path d="M-2 0 C-10 -10 -22 -18 -36 -20 C-22 -14 -12 -6 -6 0 Z"/>
|
||||
</g>
|
||||
<g fill="var(--brand-reed, #C9A15E)" transform="translate(856 100)">
|
||||
<path d="M0 0 C-4 -20 -14 -38 -30 -50 C-18 -34 -10 -18 -4 0 Z"/>
|
||||
<path d="M2 0 C2 -22 -2 -42 -12 -62 C-4 -40 -2 -20 -2 0 Z"/>
|
||||
<path d="M4 0 C8 -18 16 -34 28 -46 C18 -30 10 -16 8 0 Z"/>
|
||||
<path d="M6 0 C14 -12 24 -22 36 -26 C26 -18 16 -8 10 0 Z"/>
|
||||
<path d="M-2 0 C-10 -10 -22 -18 -36 -20 C-22 -14 -12 -6 -6 0 Z"/>
|
||||
</g>
|
||||
<path fill="var(--brand-teal, #0286A2)" d="M10 104 C200 66 400 64 600 88 C690 98 750 104 800 100 C850 96 910 88 1000 88 C1200 88 1400 112 1590 74 C1420 128 1220 120 1000 108 C910 104 850 112 800 114 C750 116 690 114 600 106 C400 84 200 88 10 104 Z"/>
|
||||
<path fill="var(--brand-wave, #6DBFC2)" d="M60 122 C240 100 420 102 600 118 C690 126 750 128 800 126 C850 124 910 116 1000 116 C1180 116 1360 134 1540 110 C1380 142 1200 140 1000 130 C910 126 850 134 800 136 C750 138 690 136 600 130 C420 116 240 114 60 122 Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
@@ -0,0 +1,9 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 66" role="img" aria-label="Rundbogengaube">
|
||||
<title>Rundbogengaube</title>
|
||||
<path fill="var(--brand-navy, #13294B)" d="M6 64 V54 A54 54 0 0 1 114 54 V64 Z"/>
|
||||
<path fill="var(--brand-paper, #F6F1E4)" d="M13 62 V54 A47 47 0 0 1 107 54 V62 Z"/>
|
||||
<path fill="var(--brand-glass, #9FD3E6)" d="M20 60 V54 A40 40 0 0 1 100 54 V60 Z"/>
|
||||
<path fill="none" stroke="var(--brand-paper, #F6F1E4)" stroke-width="3.2" stroke-linecap="square" d="M60 14 V60 M20 52 H100 M60 52 L32 25 M60 52 L88 25"/>
|
||||
<path fill="var(--brand-navy, #13294B)" d="M54 2 H66 L64 12 H56 Z"/>
|
||||
<path fill="none" stroke="var(--brand-navy, #13294B)" stroke-width="2.5" stroke-linecap="round" d="M0 64 H120"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 739 B |
@@ -0,0 +1,16 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="34" role="presentation" aria-hidden="true">
|
||||
<defs>
|
||||
<pattern id="gelaender-feld" patternUnits="userSpaceOnUse" width="132" height="34">
|
||||
<g fill="var(--brand-paper, #F6F1E4)" stroke="var(--brand-navy, #13294B)" stroke-width="1.2">
|
||||
<rect x="14" y="9" width="4" height="17"/><rect x="26" y="9" width="4" height="17"/><rect x="38" y="9" width="4" height="17"/>
|
||||
<rect x="50" y="9" width="4" height="17"/><rect x="62" y="9" width="4" height="17"/><rect x="74" y="9" width="4" height="17"/>
|
||||
<rect x="86" y="9" width="4" height="17"/><rect x="98" y="9" width="4" height="17"/><rect x="110" y="9" width="4" height="17"/>
|
||||
<rect x="0.6" y="3" width="8" height="30" rx="1"/>
|
||||
<rect x="0.6" y="5" width="132" height="4"/>
|
||||
<rect x="0.6" y="26" width="132" height="3.5"/>
|
||||
<rect x="-1" y="1" width="12" height="3" rx="1"/>
|
||||
</g>
|
||||
</pattern>
|
||||
</defs>
|
||||
<rect width="100%" height="34" fill="url(#gelaender-feld)"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="presentation" aria-hidden="true">
|
||||
<g fill="var(--brand-paper, #F6F1E4)" stroke="var(--brand-navy, #13294B)" stroke-width="1.6" stroke-linejoin="round">
|
||||
<path d="M1 1 H47 V7 H7 V47 H1 Z"/>
|
||||
<path d="M7 30 L30 7 H38 L7 38 Z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 314 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 50" role="presentation" aria-hidden="true">
|
||||
<path fill="none" stroke="var(--brand-navy, #0B2E55)" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" d="M8 26 Q20 12 32 24 Q46 6 62 16 M70 40 Q78 32 86 40 Q94 30 104 36 M88 14 Q93 9 98 14 Q103 8 110 11"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 332 B |
@@ -0,0 +1,27 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 180" role="img" aria-label="Bäderbahn Molli">
|
||||
<title>Bäderbahn Molli</title>
|
||||
<g fill="var(--brand-wave, #6DBFC2)">
|
||||
<circle cx="66" cy="54" r="14"/><circle cx="84" cy="44" r="16"/><circle cx="104" cy="40" r="13"/><circle cx="120" cy="34" r="11"/><circle cx="80" cy="60" r="10"/>
|
||||
</g>
|
||||
<g fill="var(--brand-navy, #0B2E55)">
|
||||
<path d="M58 62 H74 L72 70 V92 H60 V70 Z"/>
|
||||
<rect x="44" y="90" width="66" height="30" rx="8"/>
|
||||
<rect x="104" y="76" width="34" height="44" rx="2"/>
|
||||
<rect x="100" y="72" width="42" height="6" rx="2"/>
|
||||
<rect x="80" y="82" width="10" height="10" rx="5"/>
|
||||
</g>
|
||||
<rect x="112" y="84" width="18" height="14" fill="var(--brand-paper, #F6F1E4)"/>
|
||||
<rect x="40" y="118" width="102" height="8" fill="var(--brand-brick, #A63A2B)"/>
|
||||
<g fill="var(--brand-paper, #F6F1E4)" stroke="var(--brand-navy, #0B2E55)" stroke-width="2.5">
|
||||
<rect x="146" y="86" width="74" height="34" rx="3"/>
|
||||
</g>
|
||||
<rect x="146" y="108" width="74" height="12" fill="var(--brand-brick, #A63A2B)"/>
|
||||
<path fill="var(--brand-navy, #0B2E55)" d="M142 82 H224 V88 H142 Z M154 92 H166 V102 H154 Z M172 92 H184 V102 H172 Z M190 92 H202 V102 H190 Z M206 92 H216 V102 H206 Z"/>
|
||||
<g fill="var(--brand-brick, #A63A2B)" stroke="var(--brand-navy, #0B2E55)" stroke-width="3">
|
||||
<circle cx="60" cy="132" r="9"/><circle cx="84" cy="132" r="9"/><circle cx="108" cy="132" r="9"/>
|
||||
<circle cx="160" cy="128" r="6"/><circle cx="206" cy="128" r="6"/>
|
||||
</g>
|
||||
<path fill="none" stroke="var(--brand-navy, #0B2E55)" stroke-width="3" stroke-linecap="round" d="M60 132 H108 M24 142 H228"/>
|
||||
<path fill="var(--brand-teal, #0286A2)" d="M6 156 C50 136 98 132 142 142 C178 150 208 150 234 140 C216 160 182 168 142 164 C102 160 62 150 6 156 Z"/>
|
||||
<path fill="var(--brand-wave, #6DBFC2)" d="M22 170 C62 158 106 160 142 168 C174 176 202 174 228 166 C208 178 174 180 138 176 C102 172 66 166 22 170 Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.9 KiB |
@@ -0,0 +1,21 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 180" role="img" aria-label="Mit dem Rad an der Küste">
|
||||
<title>Mit dem Rad an der Küste</title>
|
||||
<defs><clipPath id="rad-horizon"><rect x="120" y="20" width="110" height="88"/></clipPath></defs>
|
||||
<circle cx="172" cy="104" r="40" fill="var(--brand-sun, #F2C27A)" clip-path="url(#rad-horizon)"/>
|
||||
<path fill="var(--brand-wave, #6DBFC2)" d="M118 108 H234 V118 H118 Z"/>
|
||||
<path fill="var(--brand-navy, #0B2E55)" d="M200 92 H205 V122 H200 Z M212 96 H217 V122 H212 Z"/>
|
||||
<path fill="var(--brand-sun, #F2C27A)" opacity="0.55" d="M8 150 C60 128 110 120 160 124 C190 126 214 132 234 140 V150 Z"/>
|
||||
<g fill="var(--brand-reed, #C9A15E)" transform="translate(26 138)">
|
||||
<path d="M0 0 C-4 -16 -10 -30 -22 -40 C-12 -28 -6 -14 -4 0 Z"/>
|
||||
<path d="M2 0 C2 -18 0 -34 -6 -50 C0 -32 0 -16 -2 0 Z"/>
|
||||
<path d="M4 0 C8 -14 14 -26 24 -36 C16 -24 10 -12 8 0 Z"/>
|
||||
</g>
|
||||
<g fill="none" stroke="var(--brand-navy, #0B2E55)" stroke-width="5" stroke-linecap="round" stroke-linejoin="round">
|
||||
<circle cx="76" cy="116" r="22"/>
|
||||
<circle cx="146" cy="116" r="22"/>
|
||||
<path d="M76 116 L100 88 L134 88 L146 116 M100 88 L112 116 L76 116 M112 116 L134 88 M94 78 L108 78 M134 88 L130 74 L142 72"/>
|
||||
</g>
|
||||
<path fill="none" stroke="var(--brand-navy, #0B2E55)" stroke-width="3" stroke-linecap="round" d="M150 48 Q158 40 166 48 Q174 38 184 44"/>
|
||||
<path fill="var(--brand-teal, #0286A2)" d="M6 158 C50 140 98 136 142 146 C178 154 208 154 234 144 C216 164 182 170 142 166 C102 162 62 152 6 158 Z"/>
|
||||
<path fill="var(--brand-wave, #6DBFC2)" d="M22 172 C62 160 106 162 142 170 C174 178 202 176 228 168 C208 178 174 180 138 178 C102 174 66 168 22 172 Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
@@ -0,0 +1,22 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 180" role="img" aria-label="Seebrücke">
|
||||
<title>Seebrücke</title>
|
||||
<defs><clipPath id="pier-horizon"><rect x="60" y="20" width="140" height="106"/></clipPath></defs>
|
||||
<circle cx="128" cy="122" r="52" fill="var(--brand-sun, #F2C27A)" clip-path="url(#pier-horizon)"/>
|
||||
<g fill="var(--brand-navy, #0B2E55)">
|
||||
<rect x="22" y="114" width="196" height="7" rx="1"/>
|
||||
<rect x="22" y="100" width="150" height="3"/>
|
||||
<path d="M30 100 V114 M48 100 V114 M66 100 V114 M84 100 V114 M102 100 V114 M120 100 V114 M138 100 V114 M156 100 V114" stroke="var(--brand-navy, #0B2E55)" stroke-width="2.5"/>
|
||||
<path d="M34 121 H40 V146 H34 Z M64 121 H70 V146 H64 Z M94 121 H100 V146 H94 Z M124 121 H130 V146 H124 Z M154 121 H160 V146 H154 Z M184 121 H190 V146 H184 Z M206 121 H212 V146 H206 Z"/>
|
||||
<rect x="176" y="92" width="38" height="22"/>
|
||||
<path d="M170 94 L195 72 L220 94 Z"/>
|
||||
<path d="M193 72 L195 56 L197 72 Z"/>
|
||||
<rect x="58" y="74" width="2.5" height="26"/>
|
||||
<path d="M60.5 74 L74 78 L60.5 82 Z"/>
|
||||
<rect x="148" y="78" width="2.5" height="22"/>
|
||||
<path d="M150.5 78 L162 82 L150.5 86 Z"/>
|
||||
</g>
|
||||
<path fill="var(--brand-paper, #F6F1E4)" d="M182 98 H190 V108 H182 Z M200 98 H208 V108 H200 Z"/>
|
||||
<path fill="none" stroke="var(--brand-navy, #0B2E55)" stroke-width="3" stroke-linecap="round" d="M34 50 Q42 42 50 50 Q58 40 68 46"/>
|
||||
<path fill="var(--brand-teal, #0286A2)" d="M6 152 C50 124 98 118 142 132 C178 144 208 142 234 128 C216 154 182 166 142 160 C102 154 62 140 6 152 Z"/>
|
||||
<path fill="var(--brand-wave, #6DBFC2)" d="M22 168 C62 150 106 152 142 164 C174 174 202 172 228 160 C208 176 174 180 138 174 C102 168 66 160 22 168 Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
@@ -0,0 +1,15 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 180" role="img" aria-label="Strand mit Sonne">
|
||||
<title>Strand mit Sonne</title>
|
||||
<defs><clipPath id="strand-horizon"><rect x="90" y="30" width="140" height="102"/></clipPath></defs>
|
||||
<circle cx="150" cy="128" r="50" fill="var(--brand-sun, #F2C27A)" clip-path="url(#strand-horizon)"/>
|
||||
<path fill="var(--brand-sun, #F2C27A)" d="M112 138 H188 A3 3 0 0 1 188 144 H112 A3 3 0 0 1 112 138 Z M128 150 H172 A3 3 0 0 1 172 156 H128 A3 3 0 0 1 128 150 Z"/>
|
||||
<path fill="none" stroke="var(--brand-navy, #0B2E55)" stroke-width="3" stroke-linecap="round" d="M156 54 Q164 46 172 54 Q180 44 190 50 M180 76 Q185 71 190 76 Q195 70 201 73"/>
|
||||
<g fill="var(--brand-reed, #C9A15E)" transform="translate(46 150) scale(1.5)">
|
||||
<path d="M0 0 C-4 -20 -14 -38 -30 -50 C-18 -34 -10 -18 -4 0 Z"/>
|
||||
<path d="M2 0 C2 -22 -2 -42 -12 -62 C-4 -40 -2 -20 -2 0 Z"/>
|
||||
<path d="M4 0 C8 -18 16 -34 28 -46 C18 -30 10 -16 8 0 Z"/>
|
||||
<path d="M6 0 C14 -12 24 -22 36 -26 C26 -18 16 -8 10 0 Z"/>
|
||||
</g>
|
||||
<path fill="var(--brand-teal, #0286A2)" d="M6 152 C50 120 98 114 142 130 C178 143 208 142 234 126 C216 154 182 166 142 160 C102 154 62 140 6 152 Z"/>
|
||||
<path fill="var(--brand-wave, #6DBFC2)" d="M22 168 C62 150 106 152 142 164 C174 174 202 172 228 160 C208 176 174 180 138 174 C102 168 66 160 22 168 Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
@@ -0,0 +1,24 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 180" role="img" aria-label="Küstenwald">
|
||||
<title>Küstenwald</title>
|
||||
<defs><clipPath id="wald-horizon"><rect x="140" y="40" width="96" height="84"/></clipPath></defs>
|
||||
<circle cx="190" cy="120" r="38" fill="var(--brand-sun, #F2C27A)" clip-path="url(#wald-horizon)"/>
|
||||
<g fill="var(--brand-navy, #0B2E55)">
|
||||
<path d="M58 140 L62 70 L66 140 Z"/>
|
||||
<path d="M92 140 L95 56 L99 140 Z"/>
|
||||
<path d="M124 140 L127 76 L131 140 Z"/>
|
||||
<path d="M150 140 L152 92 L155 140 Z"/>
|
||||
<path d="M95 92 L78 80 M95 80 L112 70 M62 96 L48 88 M127 100 L142 90" stroke="var(--brand-navy, #0B2E55)" stroke-width="3" stroke-linecap="round"/>
|
||||
</g>
|
||||
<g fill="var(--brand-teal, #0286A2)">
|
||||
<ellipse cx="62" cy="70" rx="26" ry="16"/><ellipse cx="44" cy="84" rx="18" ry="11"/>
|
||||
<ellipse cx="96" cy="52" rx="30" ry="18"/><ellipse cx="120" cy="66" rx="20" ry="12"/>
|
||||
<ellipse cx="128" cy="78" rx="24" ry="14"/><ellipse cx="152" cy="92" rx="16" ry="10"/>
|
||||
</g>
|
||||
<g fill="var(--brand-navy, #0B2E55)" opacity="0.85">
|
||||
<ellipse cx="74" cy="62" rx="16" ry="10"/><ellipse cx="104" cy="44" rx="16" ry="9"/><ellipse cx="136" cy="72" rx="12" ry="8"/>
|
||||
</g>
|
||||
<path fill="var(--brand-reed, #C9A15E)" d="M30 140 C60 132 140 130 200 136 C214 138 226 140 234 142 V146 H30 Z"/>
|
||||
<path fill="none" stroke="var(--brand-navy, #0B2E55)" stroke-width="3" stroke-linecap="round" d="M196 70 Q202 64 208 70 Q214 62 222 66"/>
|
||||
<path fill="var(--brand-teal, #0286A2)" d="M6 158 C50 140 98 136 142 146 C178 154 208 154 234 144 C216 164 182 170 142 166 C102 162 62 152 6 158 Z"/>
|
||||
<path fill="var(--brand-wave, #6DBFC2)" d="M22 172 C62 160 106 162 142 170 C174 178 202 176 228 168 C208 178 174 180 138 178 C102 174 66 168 22 172 Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "Ostsee",
|
||||
"description": "Bänder, Vignetten und Ornamente der Ostseeküste: Sonne, Seebrücke, Möwen, Molli.",
|
||||
"slots": {
|
||||
"divider": "band-sonne",
|
||||
"closing": "band-seebruecke",
|
||||
"crest": "gaube",
|
||||
"railing": "gelaender",
|
||||
"bracket": "kopfband",
|
||||
"gulls": "moewen",
|
||||
"vignette.beach": "vignette-strand",
|
||||
"vignette.pier": "vignette-seebruecke",
|
||||
"vignette.train": "vignette-molli",
|
||||
"vignette.bike": "vignette-rad",
|
||||
"vignette.forest": "vignette-wald"
|
||||
}
|
||||
}
|
||||
@@ -34,9 +34,8 @@
|
||||
<x-filament::section>
|
||||
<x-slot name="heading">Grenzen für alle Mandanten</x-slot>
|
||||
<x-slot name="description">
|
||||
Aus der <code>.env</code> dieses Servers. Ein Mandant kann sie in seinem Admin verschärfen, aber nicht
|
||||
überschreiten. Änderungen hier wären Änderungen an der Infrastruktur und gehören deshalb auf den Server,
|
||||
nicht in eine Oberfläche, die ein Mandant erreichen könnte.
|
||||
Ein Mandant kann sie in seinem Admin verschärfen, aber nicht überschreiten. Geändert werden sie unter
|
||||
<strong>Einstellungen</strong>; dort gilt ein leeres Feld als „Wert aus der <code>.env</code> des Servers“.
|
||||
</x-slot>
|
||||
|
||||
<dl class="divide-y divide-gray-200 dark:divide-white/10">
|
||||
|
||||
@@ -25,6 +25,10 @@
|
||||
<body>
|
||||
<div class="footer">{{ config('fewo.owner.name') }} · {{ config('fewo.owner.street') }} · {{ config('fewo.owner.city') }} · {{ config('fewo.owner.phone') }} · {{ config('fewo.owner.email') }}</div>
|
||||
|
||||
@if ($logo ?? null)
|
||||
<img src="{{ $logo }}" alt="" style="max-height: 18mm; max-width: 60mm; margin-bottom: 4mm;">
|
||||
@endif
|
||||
|
||||
@if ($draft ?? false)
|
||||
<h1>Angebot und Mietvertrag (Entwurf)</h1>
|
||||
<p class="muted">Angebot {{ $booking->reference }} · Version {{ $booking->offer_version }} · erstellt am {{ ($booking->offer_sent_at ?? now())->format('d.m.Y') }} · gültig bis {{ $booking->hold_expires_at?->format('d.m.Y, H:i') }} Uhr</p>
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="robots" content="noindex">
|
||||
<title>Webseite nicht erreichbar</title>
|
||||
<style>
|
||||
body { margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center;
|
||||
background: #f6f5f3; color: #2f2f2d; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
|
||||
main { max-width: 32rem; padding: 2rem; text-align: center; }
|
||||
h1 { font-size: 1.25rem; font-weight: 600; margin: 0 0 0.75rem; }
|
||||
p { margin: 0; line-height: 1.6; color: #5b5b57; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>Webseite nicht erreichbar</h1>
|
||||
<p>{{ $message }}</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -5,39 +5,45 @@
|
||||
use App\Actions\RemindChannelTasks;
|
||||
use App\Actions\RequestReviews;
|
||||
use App\Actions\SendBookingReminders;
|
||||
use App\Tenancy\TenantRunner;
|
||||
use Illuminate\Support\Facades\Schedule;
|
||||
|
||||
/**
|
||||
* Everything that acts on a landlord's data runs once per landlord (TenantRunner), so queries see the right
|
||||
* rows and mail goes out with the right sender. Only the database backup stays global: one database, one dump.
|
||||
*/
|
||||
Schedule::command('bookings:expire-holds')->everyFiveMinutes()->withoutOverlapping();
|
||||
|
||||
Schedule::command('channels:sync')->everyFiveMinutes()->withoutOverlapping(10);
|
||||
|
||||
Schedule::command('channels:fetch-mail')->everyMinute()->withoutOverlapping(5);
|
||||
|
||||
Schedule::call(fn (MonitorChannels $monitorChannels) => $monitorChannels->handle())
|
||||
Schedule::call(fn (TenantRunner $runner, MonitorChannels $monitorChannels) => $runner->each(fn () => $monitorChannels->handle()))
|
||||
->name('channels:monitor')
|
||||
->everyFifteenMinutes()
|
||||
->withoutOverlapping();
|
||||
|
||||
Schedule::call(fn (RemindChannelTasks $remindChannelTasks) => $remindChannelTasks->handle())
|
||||
Schedule::call(fn (TenantRunner $runner, RemindChannelTasks $remindChannelTasks) => $runner->each(fn () => $remindChannelTasks->handle()))
|
||||
->name('channels:remind-tasks')
|
||||
->everyFifteenMinutes()
|
||||
->withoutOverlapping();
|
||||
|
||||
Schedule::call(fn (SendBookingReminders $sendBookingReminders) => $sendBookingReminders->handle())
|
||||
Schedule::call(fn (TenantRunner $runner, SendBookingReminders $sendBookingReminders) => $runner->each(fn () => $sendBookingReminders->handle()))
|
||||
->name('bookings:reminders')
|
||||
->dailyAt('09:00')
|
||||
->withoutOverlapping();
|
||||
|
||||
Schedule::call(fn (RequestReviews $requestReviews) => $requestReviews->handle())
|
||||
Schedule::call(fn (TenantRunner $runner, RequestReviews $requestReviews) => $runner->each(fn () => $requestReviews->handle()))
|
||||
->name('reviews:request')
|
||||
->dailyAt('10:00')
|
||||
->withoutOverlapping();
|
||||
|
||||
Schedule::call(fn (AnonymizeGuests $anonymizeGuests) => $anonymizeGuests->handle())
|
||||
Schedule::call(fn (TenantRunner $runner, AnonymizeGuests $anonymizeGuests) => $runner->each(fn () => $anonymizeGuests->handle()))
|
||||
->name('guests:anonymize')
|
||||
->dailyAt('03:00')
|
||||
->withoutOverlapping();
|
||||
|
||||
// One database, one dump – across all landlords (see MANDANTEN-PLAN §5).
|
||||
Schedule::command('backup:database')
|
||||
->name('backup:database')
|
||||
->dailyAt('02:30')
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\ImageWorlds\ImageWorldRegistry;
|
||||
use App\ImageWorlds\MotifRenderer;
|
||||
use App\Models\Property;
|
||||
use App\Models\Site;
|
||||
use App\Models\Tenant;
|
||||
use App\Tenancy\TenantContext;
|
||||
use App\Themes\Theme;
|
||||
use App\Themes\ThemeFactory;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Picture worlds (A18–A20): a website is dressed in a set of graphics, an apartment may wear a different
|
||||
* one. Templates ask for a slot, never for a file, so the same template works in every world.
|
||||
*/
|
||||
class ImageWorldTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private string $extra;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// A second world, so "the apartment overrules the website" is testable against something.
|
||||
$this->extra = resource_path('image-worlds/berge');
|
||||
File::ensureDirectoryExists($this->extra.'/svg');
|
||||
File::put($this->extra.'/world.json', json_encode([
|
||||
'name' => 'Berge',
|
||||
'description' => 'Gipfel statt Wellen.',
|
||||
'slots' => ['divider' => 'grat', 'crest' => 'gipfel'],
|
||||
]));
|
||||
File::put($this->extra.'/svg/grat.svg', '<svg viewBox="0 0 10 10"><title>Grat</title><path id="line" fill="url(#verlauf)"/></svg>');
|
||||
|
||||
app()->forgetInstance(ImageWorldRegistry::class);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
File::deleteDirectory($this->extra);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function test_the_registry_finds_every_world_and_reports_slots_without_a_file(): void
|
||||
{
|
||||
$registry = app(ImageWorldRegistry::class);
|
||||
|
||||
$this->assertArrayHasKey('ostsee', $registry->all());
|
||||
$this->assertArrayHasKey('berge', $registry->all());
|
||||
$this->assertSame('Berge', $registry->options()['berge']);
|
||||
|
||||
$this->assertSame([], $registry->get('ostsee')->missingFiles());
|
||||
$this->assertSame(['crest'], $registry->get('berge')->missingFiles(), 'gipfel.svg fehlt und muss auffallen.');
|
||||
$this->assertNull($registry->get('gibtsnicht'));
|
||||
}
|
||||
|
||||
public function test_a_slot_without_a_file_renders_nothing_instead_of_breaking(): void
|
||||
{
|
||||
$this->useWorld('berge');
|
||||
|
||||
$this->assertSame('', (string) app(MotifRenderer::class)->render('crest'));
|
||||
$this->assertFalse(app(MotifRenderer::class)->has('crest'));
|
||||
$this->assertTrue(app(MotifRenderer::class)->has('divider'));
|
||||
}
|
||||
|
||||
public function test_the_apartment_overrules_the_website(): void
|
||||
{
|
||||
$this->useWorld('ostsee');
|
||||
$this->assertSame('ostsee', app(MotifRenderer::class)->world()?->key);
|
||||
|
||||
$this->useWorld('ostsee', apartmentWorld: 'berge');
|
||||
$this->assertSame('berge', app(MotifRenderer::class)->world()?->key, 'Die Bergwohnung trägt ihre eigene Bildwelt.');
|
||||
}
|
||||
|
||||
public function test_without_any_choice_the_installation_decides(): void
|
||||
{
|
||||
config(['image-worlds.default' => 'berge']);
|
||||
$this->useWorld(null);
|
||||
|
||||
$this->assertSame('berge', app(MotifRenderer::class)->world()?->key);
|
||||
}
|
||||
|
||||
public function test_the_rendered_graphic_is_decorative_unless_it_is_given_a_label(): void
|
||||
{
|
||||
$this->useWorld('berge');
|
||||
|
||||
$plain = (string) app(MotifRenderer::class)->render('divider', 'h-8 text-accent');
|
||||
|
||||
$this->assertStringContainsString('aria-hidden="true"', $plain);
|
||||
$this->assertStringContainsString('class="h-8 text-accent"', $plain);
|
||||
$this->assertStringNotContainsString('<title>', $plain, 'Der Titel würde sonst doppelt vorgelesen.');
|
||||
|
||||
$labelled = (string) app(MotifRenderer::class)->render('divider', null, 'Bergkamm');
|
||||
|
||||
$this->assertStringContainsString('role="img"', $labelled);
|
||||
$this->assertStringContainsString('aria-label="Bergkamm"', $labelled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Two copies of one graphic on a page must not share their internal ids – the second would otherwise
|
||||
* point at the first one's gradient and lose its colours.
|
||||
*/
|
||||
public function test_the_internal_ids_are_unique_per_rendering(): void
|
||||
{
|
||||
$this->useWorld('berge');
|
||||
|
||||
$first = (string) app(MotifRenderer::class)->render('divider');
|
||||
$second = (string) app(MotifRenderer::class)->render('divider');
|
||||
|
||||
$this->assertNotSame($first, $second);
|
||||
$this->assertMatchesRegularExpression('/id="line-m\w{6}"/', $first);
|
||||
$this->assertStringContainsString('url(#verlauf-m', $first);
|
||||
}
|
||||
|
||||
private function useWorld(?string $key, ?string $apartmentWorld = null): Theme
|
||||
{
|
||||
$tenant = Tenant::factory()->create();
|
||||
|
||||
return app(TenantContext::class)->run($tenant, function () use ($key, $apartmentWorld): Theme {
|
||||
$site = Site::factory()->create(['image_world' => $key, 'is_default' => true]);
|
||||
Property::factory()->create(['site_id' => $site->id, 'image_world' => $apartmentWorld]);
|
||||
|
||||
$theme = app(ThemeFactory::class)->forSite($site);
|
||||
app()->instance(Theme::class, $theme);
|
||||
|
||||
return $theme;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@
|
||||
use App\Models\PortalEmail;
|
||||
use App\Models\Property;
|
||||
use App\Models\User;
|
||||
use App\Support\Settings;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Database\Seeders\PropertySeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
@@ -188,7 +189,8 @@ public function test_n8n_can_push_mails_with_a_signed_request(): void
|
||||
|
||||
public function test_mailbox_outage_is_alerted_once(): void
|
||||
{
|
||||
config(['fewo.mailbox.host' => 'imap.strato.de', 'fewo.mailbox.username' => 'fewo@stommer.de']);
|
||||
// The mailbox belongs to the landlord now, not to the server's .env.
|
||||
Settings::tenant()?->update(['mailbox_host' => 'imap.strato.de', 'mailbox_username' => 'fewo@stommer.de']);
|
||||
|
||||
$this->fewo->update(['settings' => ['email_senders' => 'fewo-direkt.de']]);
|
||||
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Filament\Resources\Pages\Pages\EditPage;
|
||||
use App\Models\Page;
|
||||
use App\Models\Property;
|
||||
use App\Models\Site;
|
||||
use App\Models\User;
|
||||
use App\Tenancy\TenantContext;
|
||||
use App\Themes\SectionRegistry;
|
||||
use App\Themes\Theme;
|
||||
use App\Themes\ThemeFactory;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Livewire\Livewire;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use RuntimeException;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SectionPropertyTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_sections_use_the_selected_property_and_return_to_the_primary_property(): void
|
||||
{
|
||||
$this->withoutVite();
|
||||
$site = Site::factory()->create(['domain' => 'wohnungen.test', 'is_default' => true]);
|
||||
Property::factory()->for($site)->create(['name' => 'Hauptwohnung', 'size_sqm' => 53]);
|
||||
$second = Property::factory()->for($site)->create(['name' => 'Bergwohnung', 'size_sqm' => 87]);
|
||||
Page::factory()->for($site)->create([
|
||||
'slug' => Page::HOME,
|
||||
'sections' => [
|
||||
['type' => 'facts', 'data' => ['heading' => 'Erste Wohnung']],
|
||||
['type' => 'facts', 'data' => ['heading' => 'Zweite Wohnung', 'property_id' => (string) $second->id]],
|
||||
['type' => 'facts', 'data' => ['heading' => 'Wieder Hauptwohnung', 'property_id' => null]],
|
||||
['type' => 'booking', 'data' => ['property_id' => $second->id]],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->get('http://wohnungen.test/')
|
||||
->assertOk()
|
||||
->assertSeeInOrder(['Erste Wohnung', '53 m²', 'Zweite Wohnung', '87 m²', 'Wieder Hauptwohnung', '53 m²'])
|
||||
->assertSee('"propertyId":'.$second->id, false);
|
||||
|
||||
$this->assertSame('Hauptwohnung', app(Theme::class)->property()->name);
|
||||
}
|
||||
|
||||
public function test_deferred_views_and_partials_see_the_selected_theme_property(): void
|
||||
{
|
||||
$site = Site::factory()->create();
|
||||
$primary = Property::factory()->for($site)->create(['name' => 'Hauptwohnung']);
|
||||
$second = Property::factory()->for($site)->create(['name' => 'Bergwohnung']);
|
||||
$theme = app(ThemeFactory::class)->forSite($site)->activate();
|
||||
app()->instance(Theme::class, $theme);
|
||||
View::composer('theme::sections.facts', function ($view): void {
|
||||
$view->with('heading', $view->getData()['theme']->property()->name.' / '.app(Theme::class)->property()->name);
|
||||
});
|
||||
|
||||
$sections = app(SectionRegistry::class)->render($theme, [
|
||||
['type' => 'facts', 'data' => ['property_id' => $second->id]],
|
||||
['type' => 'facts', 'data' => []],
|
||||
]);
|
||||
|
||||
$this->assertSame($primary->id, $theme->property()->id);
|
||||
$this->assertStringContainsString('Bergwohnung / Bergwohnung', $sections[0]->render());
|
||||
$this->assertStringContainsString('Hauptwohnung / Hauptwohnung', $sections[1]->render());
|
||||
$this->assertSame($primary->id, $theme->property()->id);
|
||||
}
|
||||
|
||||
public function test_nested_property_contexts_restore_the_unresolved_primary_cache_after_an_exception(): void
|
||||
{
|
||||
$site = Site::factory()->create();
|
||||
$primary = Property::factory()->for($site)->create();
|
||||
$second = Property::factory()->for($site)->create();
|
||||
$theme = app(ThemeFactory::class)->forSite($site);
|
||||
|
||||
try {
|
||||
$theme->runForProperty($second, function () use ($theme, $primary, $second): void {
|
||||
$this->assertSame($second->id, $theme->property()->id);
|
||||
$theme->runForProperty($primary, function () use ($theme, $primary): void {
|
||||
$this->assertSame($primary->id, $theme->property()->id);
|
||||
});
|
||||
$this->assertSame($second->id, $theme->property()->id);
|
||||
|
||||
throw new RuntimeException('Abbruch');
|
||||
});
|
||||
$this->fail('The callback must throw.');
|
||||
} catch (RuntimeException $exception) {
|
||||
$this->assertSame('Abbruch', $exception->getMessage());
|
||||
}
|
||||
|
||||
$primary->update(['is_active' => false]);
|
||||
$this->assertSame($second->id, $theme->property()->id);
|
||||
}
|
||||
|
||||
public function test_a_failing_deferred_view_restores_the_primary_property(): void
|
||||
{
|
||||
$site = Site::factory()->create();
|
||||
$primary = Property::factory()->for($site)->create();
|
||||
$second = Property::factory()->for($site)->create();
|
||||
$theme = app(ThemeFactory::class)->forSite($site)->activate();
|
||||
$sections = app(SectionRegistry::class)->render($theme, [
|
||||
['type' => 'facts', 'data' => ['property_id' => $second->id]],
|
||||
]);
|
||||
View::composer('theme::sections.facts', function () use ($theme, $second): void {
|
||||
$this->assertSame($second->id, $theme->property()->id);
|
||||
|
||||
throw new RuntimeException('Vorlage abgebrochen');
|
||||
});
|
||||
|
||||
try {
|
||||
$sections[0]->render();
|
||||
$this->fail('The view must throw.');
|
||||
} catch (RuntimeException $exception) {
|
||||
$this->assertSame('Vorlage abgebrochen', $exception->getMessage());
|
||||
}
|
||||
|
||||
$this->assertSame($primary->id, $theme->property()->id);
|
||||
}
|
||||
|
||||
/** @return array<string, array{string}> */
|
||||
public static function invalidPropertyProvider(): array
|
||||
{
|
||||
return [
|
||||
'other website of same tenant' => ['other_site'],
|
||||
'other tenant' => ['other_tenant'],
|
||||
'inactive property' => ['inactive'],
|
||||
'deleted property' => ['deleted'],
|
||||
];
|
||||
}
|
||||
|
||||
#[DataProvider('invalidPropertyProvider')]
|
||||
public function test_invalid_property_assignments_are_skipped(string $kind): void
|
||||
{
|
||||
$site = Site::factory()->create();
|
||||
Property::factory()->for($site)->create();
|
||||
$otherSite = Site::factory()->create(['tenant_id' => $site->tenant_id]);
|
||||
$property = match ($kind) {
|
||||
'other_site' => Property::factory()->for($otherSite)->create(),
|
||||
'other_tenant' => Property::factory()->for(Site::factory())->create(),
|
||||
default => Property::factory()->for($site)->create(['is_active' => false]),
|
||||
};
|
||||
if ($kind === 'deleted') {
|
||||
$property->delete();
|
||||
}
|
||||
app(TenantContext::class)->set($site->tenant);
|
||||
$theme = app(ThemeFactory::class)->forSite($site)->activate();
|
||||
|
||||
$sections = app(SectionRegistry::class)->render($theme, [
|
||||
['type' => 'facts', 'data' => ['property_id' => $property->id]],
|
||||
['type' => 'facts', 'data' => ['heading' => 'Hauptwohnung bleibt sichtbar']],
|
||||
]);
|
||||
|
||||
$this->assertCount(1, $sections);
|
||||
$this->assertStringContainsString('Hauptwohnung bleibt sichtbar', $sections[0]->render());
|
||||
}
|
||||
|
||||
public function test_editor_saves_a_property_of_the_pages_website(): void
|
||||
{
|
||||
$site = Site::factory()->create();
|
||||
$property = Property::factory()->for($site)->create();
|
||||
$page = Page::factory()->for($site)->create();
|
||||
$user = User::factory()->role(UserRole::Content)->create();
|
||||
$user->tenants()->syncWithoutDetaching([$site->tenant_id => ['role' => UserRole::Content->value]]);
|
||||
app(TenantContext::class)->set($site->tenant);
|
||||
$this->actingAs($user);
|
||||
|
||||
Livewire::test(EditPage::class, ['record' => $page->getRouteKey()])
|
||||
->fillForm(['sections' => [['type' => 'facts', 'data' => ['property_id' => $property->id]]]])
|
||||
->call('save')
|
||||
->assertHasNoFormErrors();
|
||||
|
||||
$this->assertSame($property->id, (int) $page->fresh()->sections[0]['data']['property_id']);
|
||||
}
|
||||
|
||||
#[DataProvider('invalidPropertyProvider')]
|
||||
public function test_editor_rejects_properties_outside_the_available_selection(string $kind): void
|
||||
{
|
||||
$site = Site::factory()->create();
|
||||
$page = Page::factory()->for($site)->create(['sections' => []]);
|
||||
$otherSite = Site::factory()->create(['tenant_id' => $site->tenant_id]);
|
||||
$property = match ($kind) {
|
||||
'other_site' => Property::factory()->for($otherSite)->create(),
|
||||
'other_tenant' => Property::factory()->for(Site::factory())->create(),
|
||||
default => Property::factory()->for($site)->create(['is_active' => false]),
|
||||
};
|
||||
if ($kind === 'deleted') {
|
||||
$property->delete();
|
||||
}
|
||||
$user = User::factory()->role(UserRole::Content)->create();
|
||||
$user->tenants()->syncWithoutDetaching([$site->tenant_id => ['role' => UserRole::Content->value]]);
|
||||
app(TenantContext::class)->set($site->tenant);
|
||||
$this->actingAs($user);
|
||||
|
||||
Livewire::test(EditPage::class, ['record' => $page->getRouteKey()])
|
||||
->fillForm(['sections' => [['type' => 'facts', 'data' => ['property_id' => $property->id]]]])
|
||||
->call('save')
|
||||
->assertHasFormErrors();
|
||||
|
||||
$this->assertSame([], $page->fresh()->sections);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Documents\RentalContract;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Property;
|
||||
use App\Models\Site;
|
||||
use App\Models\Tenant;
|
||||
use App\Tenancy\TenantContext;
|
||||
use App\Themes\Theme;
|
||||
use App\Themes\ThemeFactory;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* The brand (A14/A22): logo, favicon and the logo for mail and contract belong to the website, not to the
|
||||
* installation. Without this, a second landlord would carry the first one's logo in their rental contract.
|
||||
*/
|
||||
class SiteBrandTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_each_website_carries_its_own_brand(): void
|
||||
{
|
||||
Storage::fake('public');
|
||||
|
||||
$first = $this->website('Nordhaus');
|
||||
$second = $this->website('Südheim');
|
||||
|
||||
$first->addMedia(UploadedFile::fake()->image('nord.png'))->toMediaCollection(Site::BRAND_LOGO);
|
||||
|
||||
$this->assertNotNull($first->fresh()->brandUrl(Site::BRAND_LOGO));
|
||||
$this->assertNull($second->fresh()->brandUrl(Site::BRAND_LOGO), 'Ohne eigenes Logo erbt niemand ein fremdes.');
|
||||
$this->assertNull($first->fresh()->brandUrl(Site::BRAND_FAVICON));
|
||||
}
|
||||
|
||||
public function test_the_contract_shows_the_logo_of_its_own_website(): void
|
||||
{
|
||||
Storage::fake('public');
|
||||
Storage::fake('local');
|
||||
|
||||
$site = $this->website('Nordhaus');
|
||||
$site->addMedia(UploadedFile::fake()->image('vertrag.png', 300, 100))->toMediaCollection(Site::BRAND_DOCUMENT_LOGO);
|
||||
|
||||
$booking = app(TenantContext::class)->run($site->tenant, fn (): Booking => Booking::factory()
|
||||
->for(Property::factory()->create(['site_id' => $site->id]))
|
||||
->create());
|
||||
|
||||
$path = app(TenantContext::class)->run($site->tenant, fn (): string => app(RentalContract::class)->generate($booking, draft: true));
|
||||
|
||||
Storage::disk('local')->assertExists($path);
|
||||
$this->assertGreaterThan(1000, strlen(Storage::disk('local')->get($path)));
|
||||
}
|
||||
|
||||
public function test_a_website_without_a_document_logo_still_renders_its_contract(): void
|
||||
{
|
||||
Storage::fake('public');
|
||||
Storage::fake('local');
|
||||
|
||||
$site = $this->website('Ohne Marke');
|
||||
|
||||
$booking = app(TenantContext::class)->run($site->tenant, fn (): Booking => Booking::factory()
|
||||
->for(Property::factory()->create(['site_id' => $site->id]))
|
||||
->create());
|
||||
|
||||
$path = app(TenantContext::class)->run($site->tenant, fn (): string => app(RentalContract::class)->generate($booking, draft: false));
|
||||
|
||||
Storage::disk('local')->assertExists($path);
|
||||
}
|
||||
|
||||
public function test_the_theme_hands_the_brand_to_the_templates(): void
|
||||
{
|
||||
Storage::fake('public');
|
||||
|
||||
$site = $this->website('Nordhaus');
|
||||
$site->addMedia(UploadedFile::fake()->image('logo.png'))->toMediaCollection(Site::BRAND_LOGO);
|
||||
|
||||
$theme = app(TenantContext::class)->run(
|
||||
$site->tenant,
|
||||
fn (): Theme => app(ThemeFactory::class)->forSite($site->fresh()),
|
||||
);
|
||||
|
||||
$this->assertStringContainsString('logo', (string) $theme->brand(Site::BRAND_LOGO));
|
||||
$this->assertNull($theme->brand(Site::BRAND_FAVICON));
|
||||
}
|
||||
|
||||
private function website(string $name): Site
|
||||
{
|
||||
$tenant = Tenant::factory()->create(['name' => $name]);
|
||||
|
||||
return app(TenantContext::class)->run($tenant, fn (): Site => Site::factory()->create([
|
||||
'name' => $name,
|
||||
'is_default' => false,
|
||||
]));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Filament\Operator\Pages\SystemSettingsPage;
|
||||
use App\Models\SystemSetting;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
use App\Support\Settings;
|
||||
use App\Support\SystemSettings;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Settings of the whole installation, owned by the operator. They are the baseline a landlord may tighten
|
||||
* but not exceed, so they have to win over the .env and lose to nobody's landlord.
|
||||
*/
|
||||
class SystemSettingsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
SystemSettings::forget();
|
||||
}
|
||||
|
||||
public function test_a_stored_value_wins_over_the_env_and_an_empty_one_gives_it_back(): void
|
||||
{
|
||||
config(['fewo.spam.total_per_hour' => 30]);
|
||||
|
||||
SystemSettings::save(['fewo.spam.total_per_hour' => '120']);
|
||||
$this->assertSame(120, config('fewo.spam.total_per_hour'));
|
||||
$this->assertSame(120, SystemSettings::get('fewo.spam.total_per_hour'));
|
||||
|
||||
SystemSettings::save(['fewo.spam.total_per_hour' => '']);
|
||||
config(['fewo.spam.total_per_hour' => 30]);
|
||||
SystemSettings::apply();
|
||||
|
||||
$this->assertSame(30, config('fewo.spam.total_per_hour'), 'Leer = der Wert der .env gilt wieder.');
|
||||
$this->assertSame(0, SystemSetting::query()->count());
|
||||
}
|
||||
|
||||
public function test_a_secret_is_stored_encrypted(): void
|
||||
{
|
||||
SystemSettings::save(['mail.mailers.smtp.password' => 'geheim']);
|
||||
|
||||
$stored = DB::table('system_settings')->where('key', 'mail.mailers.smtp.password')->first();
|
||||
|
||||
$this->assertNotSame('geheim', $stored?->value);
|
||||
$this->assertTrue((bool) $stored?->is_secret);
|
||||
$this->assertSame('geheim', SystemSettings::get('mail.mailers.smtp.password'));
|
||||
}
|
||||
|
||||
/**
|
||||
* The whole point of the ceiling: what the operator sets here binds every landlord.
|
||||
*/
|
||||
public function test_the_stored_limit_becomes_the_ceiling_for_a_landlord(): void
|
||||
{
|
||||
config(['fewo.guest_retention_years' => 10]);
|
||||
SystemSettings::save(['fewo.guest_retention_years' => '4']);
|
||||
|
||||
$tenant = Tenant::factory()->create(['guest_retention_years' => 9]);
|
||||
app(TenantContext::class)->set($tenant);
|
||||
app(TenantConfig::class)->refresh();
|
||||
|
||||
$this->assertSame(4, config('fewo.guest_retention_years'), 'Der Mandant darf die Obergrenze nicht überschreiten.');
|
||||
}
|
||||
|
||||
public function test_the_operator_edits_the_settings_and_a_landlords_administrator_cannot_reach_the_page(): void
|
||||
{
|
||||
$tenant = Tenant::factory()->create();
|
||||
app(TenantContext::class)->set($tenant);
|
||||
|
||||
$admin = User::factory()->create();
|
||||
$this->actingAs($admin)->get('/betreiber/einstellungen')->assertForbidden();
|
||||
|
||||
$admin->forceFill(['is_operator' => true])->saveQuietly();
|
||||
$this->actingAs($admin);
|
||||
Filament::setCurrentPanel('operator');
|
||||
|
||||
$this->get('/betreiber/einstellungen')->assertOk()->assertSee('Systemweite Einstellungen');
|
||||
|
||||
Livewire::test(SystemSettingsPage::class)
|
||||
->set('data.fewo__spam__total_per_hour', '77')
|
||||
->set('data.fewo__mail_redirect_to', 'auffang@example.com')
|
||||
->call('save')
|
||||
->assertHasNoErrors();
|
||||
|
||||
$this->assertSame(77, SystemSettings::get('fewo.spam.total_per_hour'));
|
||||
$this->assertSame('auffang@example.com', config('fewo.mail_redirect_to'));
|
||||
}
|
||||
|
||||
/**
|
||||
* The hard redirect is the net that keeps a test server from writing to real guests. It is editable on
|
||||
* purpose, so it must be obvious that emptying it hands the decision back to each landlord.
|
||||
*/
|
||||
public function test_emptying_the_hard_redirect_leaves_only_the_landlords_own_test_mode(): void
|
||||
{
|
||||
SystemSettings::save(['fewo.mail_redirect_to' => 'auffang@example.com']);
|
||||
|
||||
$live = Tenant::factory()->create(['operating_mode' => 'live', 'notification_emails' => 'wirt@example.com']);
|
||||
app(TenantContext::class)->set($live);
|
||||
|
||||
$this->assertSame('auffang@example.com', Settings::mailRedirect());
|
||||
|
||||
SystemSettings::save(['fewo.mail_redirect_to' => '']);
|
||||
|
||||
$this->assertNull(Settings::mailRedirect(), 'Ohne harte Umleitung entscheidet der Mandant allein.');
|
||||
}
|
||||
}
|
||||
@@ -133,8 +133,10 @@ public function test_a_suspended_landlord_is_closed_except_for_the_operator(): v
|
||||
app(TenantContext::class)->set($tenant);
|
||||
$admin = User::factory()->create();
|
||||
|
||||
$this->get('/')->assertNotFound();
|
||||
$this->actingAs($admin)->get('/admin')->assertNotFound();
|
||||
// Visitors and the landlord's own people see a notice, not a dead link; 503 keeps the pages in the
|
||||
// search index, because a suspended landlord is a temporary state.
|
||||
$this->get('/')->assertStatus(503)->assertSee('nicht erreichbar');
|
||||
$this->actingAs($admin)->get('/admin')->assertStatus(503);
|
||||
|
||||
$admin->forceFill(['is_operator' => true])->saveQuietly();
|
||||
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Filament\Operator\Tenants\Pages\CreateTenant;
|
||||
use App\Filament\Operator\Tenants\Pages\EditTenant;
|
||||
use App\Models\Page;
|
||||
use App\Models\Site;
|
||||
use App\Models\SiteDomain;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
use App\Tenancy\TenantContext;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Setting a landlord up is the operator's job: the hosting and the addresses are theirs. A landlord the
|
||||
* operator created must be reachable straight away – otherwise nobody can get in to finish the job.
|
||||
*/
|
||||
class TenantProvisioningTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->withoutVite();
|
||||
}
|
||||
|
||||
public function test_a_landlord_created_by_the_operator_is_reachable_at_once(): void
|
||||
{
|
||||
$this->asOperator();
|
||||
|
||||
Livewire::test(CreateTenant::class)
|
||||
->fillForm([
|
||||
'name' => 'Ferienhaus Düne',
|
||||
'slug' => 'duene',
|
||||
'is_active' => true,
|
||||
'websites' => [['name' => 'Ferienhaus Düne', 'hosts' => ['duene.test', 'www.duene.test']]],
|
||||
])
|
||||
->call('create')
|
||||
->assertHasNoErrors();
|
||||
|
||||
$tenant = Tenant::query()->where('slug', 'duene')->sole();
|
||||
$site = Site::withoutGlobalScope('tenant')->where('tenant_id', $tenant->id)->sole();
|
||||
|
||||
$this->assertSame(['duene.test', 'www.duene.test'], $site->domains()->orderBy('host')->pluck('host')->all());
|
||||
$this->assertSame('duene.test', $site->domain, 'Die erste Adresse ist die Hauptadresse.');
|
||||
|
||||
// Without a home page the website would answer 404 and the landlord could never get in.
|
||||
$this->assertTrue(
|
||||
app(TenantContext::class)->run($tenant, fn (): bool => $site->pages()->where('slug', Page::HOME)->exists()),
|
||||
);
|
||||
|
||||
$this->get('http://duene.test/')->assertOk()->assertSee('Ferienhaus Düne');
|
||||
$this->get('http://www.duene.test/')->assertOk();
|
||||
}
|
||||
|
||||
public function test_a_suspended_landlord_shows_a_notice_instead_of_a_dead_link(): void
|
||||
{
|
||||
$tenant = Tenant::factory()->create(['is_active' => true]);
|
||||
$site = $this->websiteFor($tenant, 'duene.test');
|
||||
$this->assertNotNull($site);
|
||||
|
||||
Tenant::factory()->create(); // a second landlord, so hosts really decide
|
||||
|
||||
$this->get('http://duene.test/')->assertOk();
|
||||
|
||||
$tenant->update(['is_active' => false, 'suspended_message' => 'Die Vermietung pausiert bis Frühjahr.']);
|
||||
|
||||
$response = $this->get('http://duene.test/');
|
||||
$response->assertStatus(503);
|
||||
$response->assertSee('Die Vermietung pausiert bis Frühjahr.');
|
||||
$response->assertSee('nicht erreichbar');
|
||||
}
|
||||
|
||||
public function test_the_default_notice_applies_when_none_was_written(): void
|
||||
{
|
||||
$tenant = Tenant::factory()->create(['is_active' => false]);
|
||||
$this->websiteFor($tenant, 'duene.test');
|
||||
Tenant::factory()->create();
|
||||
|
||||
$this->get('http://duene.test/')->assertStatus(503)->assertSee('Bitte versuchen Sie es später noch einmal.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Links carry the main address of the website they belong to – not APP_URL, which is a single value and
|
||||
* would have sent every visitor of a second landlord to the first landlord's host. Visiting through a
|
||||
* further address of the same website still yields the main address, which keeps one canonical host.
|
||||
*/
|
||||
public function test_links_carry_the_main_address_of_their_own_website(): void
|
||||
{
|
||||
config(['app.url' => 'https://erster.test']);
|
||||
$first = Tenant::factory()->create();
|
||||
$this->websiteFor($first, 'erster.test');
|
||||
|
||||
$second = Tenant::factory()->create();
|
||||
$this->websiteFor($second, 'zweiter.test');
|
||||
|
||||
$html = (string) $this->get('http://zweiter.test/')->assertOk()->getContent();
|
||||
|
||||
$this->assertStringNotContainsString('erster.test', $html);
|
||||
$this->assertStringContainsString('zweiter.test', $html);
|
||||
|
||||
// A further address of the same website keeps pointing at its main address.
|
||||
SiteDomain::query()->create(['site_id' => Site::withoutGlobalScope('tenant')->where('tenant_id', $second->id)->value('id'), 'host' => 'www.zweiter.test']);
|
||||
|
||||
$viaWww = (string) $this->get('http://www.zweiter.test/')->assertOk()->getContent();
|
||||
|
||||
$this->assertStringContainsString('https://zweiter.test', $viaWww);
|
||||
}
|
||||
|
||||
public function test_the_operator_adds_an_address_to_an_existing_landlord(): void
|
||||
{
|
||||
$tenant = Tenant::factory()->create();
|
||||
$site = $this->websiteFor($tenant, 'duene.test');
|
||||
Tenant::factory()->create();
|
||||
|
||||
$this->get('http://neu.duene.test/')->assertNotFound();
|
||||
|
||||
$this->asOperator();
|
||||
|
||||
Livewire::test(EditTenant::class, ['record' => $tenant->getRouteKey()])
|
||||
->fillForm(['websites' => [[
|
||||
'id' => $site->id,
|
||||
'name' => $site->name,
|
||||
'hosts' => ['duene.test', 'neu.duene.test'],
|
||||
]]])
|
||||
->call('save')
|
||||
->assertHasNoErrors();
|
||||
|
||||
$this->get('http://neu.duene.test/')->assertOk();
|
||||
$this->get('http://duene.test/')->assertOk();
|
||||
}
|
||||
|
||||
private function asOperator(): void
|
||||
{
|
||||
$operator = User::factory()->create();
|
||||
$operator->forceFill(['is_operator' => true])->saveQuietly();
|
||||
$this->actingAs($operator);
|
||||
Filament::setCurrentPanel('operator');
|
||||
}
|
||||
|
||||
private function websiteFor(Tenant $tenant, string $host): Site
|
||||
{
|
||||
return app(TenantContext::class)->run($tenant, function () use ($tenant, $host): Site {
|
||||
$site = Site::query()->create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'name' => 'Website von '.$tenant->name,
|
||||
'domain' => $host,
|
||||
'is_default' => true,
|
||||
'theme' => config('themes.base'),
|
||||
]);
|
||||
|
||||
Page::query()->create([
|
||||
'site_id' => $site->id,
|
||||
'slug' => Page::HOME,
|
||||
'title' => $site->name,
|
||||
'sections' => [],
|
||||
'is_published' => true,
|
||||
]);
|
||||
|
||||
return $site;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Actions\ExpireReservations;
|
||||
use App\Channels\Mail\MailboxReader;
|
||||
use App\Mail\ReservationExpired;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Property;
|
||||
use App\Models\Site;
|
||||
use App\Models\Tenant;
|
||||
use App\Tenancy\TenantContext;
|
||||
use App\Tenancy\TenantRunner;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Phase 4: everything running in the background belongs to one landlord. Without a landlord the scheduler
|
||||
* sees no landlord at all – queries stop filtering and mail falls back to the server's sender, which would
|
||||
* send one landlord's reminders under another one's address.
|
||||
*/
|
||||
class TenantScheduleTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->travelTo(CarbonImmutable::parse('2026-11-01 09:00'));
|
||||
Mail::fake();
|
||||
}
|
||||
|
||||
public function test_the_runner_visits_every_active_landlord_with_that_landlord_current(): void
|
||||
{
|
||||
$first = Tenant::factory()->create(['name' => 'Erster']);
|
||||
$second = Tenant::factory()->create(['name' => 'Zweiter']);
|
||||
Tenant::factory()->create(['name' => 'Gesperrt', 'is_active' => false]);
|
||||
|
||||
$seen = [];
|
||||
$succeeded = app(TenantRunner::class)->each(function (Tenant $tenant) use (&$seen): void {
|
||||
$seen[] = [$tenant->id, app(TenantContext::class)->id()];
|
||||
});
|
||||
|
||||
$this->assertSame(2, $succeeded);
|
||||
$this->assertSame([[$first->id, $first->id], [$second->id, $second->id]], $seen);
|
||||
$this->assertNull(app(TenantContext::class)->id(), 'Nach dem Lauf ist kein Mandant mehr gesetzt.');
|
||||
}
|
||||
|
||||
public function test_a_failing_landlord_does_not_stop_the_others(): void
|
||||
{
|
||||
Tenant::factory()->create();
|
||||
Tenant::factory()->create();
|
||||
|
||||
$visited = 0;
|
||||
$succeeded = app(TenantRunner::class)->each(function () use (&$visited): void {
|
||||
$visited++;
|
||||
|
||||
if ($visited === 1) {
|
||||
throw new \RuntimeException('Postfach nicht erreichbar');
|
||||
}
|
||||
});
|
||||
|
||||
$this->assertSame(2, $visited);
|
||||
$this->assertSame(1, $succeeded);
|
||||
}
|
||||
|
||||
/**
|
||||
* The test the plan asks for: a run for A must not write to B's guests, nor under B's sender.
|
||||
*/
|
||||
public function test_a_run_touches_only_its_own_landlord_and_uses_their_sender(): void
|
||||
{
|
||||
[$a, $bookingA] = $this->landlordWithExpiredHold('Nordhaus', 'nord@example.com', 'Absender Nord <nord@example.com>');
|
||||
[$b, $bookingB] = $this->landlordWithExpiredHold('Südheim', 'sued@example.com', 'Absender Süd <sued@example.com>');
|
||||
|
||||
$senders = [];
|
||||
|
||||
app(TenantRunner::class)->each(function (Tenant $tenant) use (&$senders): void {
|
||||
$senders[$tenant->name] = [config('mail.from.address'), config('fewo.owner.name')];
|
||||
|
||||
app(ExpireReservations::class)->handle();
|
||||
});
|
||||
|
||||
$this->assertSame(['nord@example.com', 'Nordhaus'], $senders['Nordhaus']);
|
||||
$this->assertSame(['sued@example.com', 'Südheim'], $senders['Südheim']);
|
||||
|
||||
// Each landlord is told about their own expired hold only.
|
||||
Mail::assertSent(ReservationExpired::class, 2);
|
||||
Mail::assertSent(ReservationExpired::class, fn (ReservationExpired $mail): bool => $mail->hasTo('nord@example.com'));
|
||||
Mail::assertSent(ReservationExpired::class, fn (ReservationExpired $mail): bool => $mail->hasTo('sued@example.com'));
|
||||
|
||||
$this->assertSame('expired', $bookingA->fresh()->status->value);
|
||||
$this->assertSame('expired', $bookingB->fresh()->status->value);
|
||||
$this->assertNotSame($a->id, $b->id);
|
||||
}
|
||||
|
||||
public function test_the_mailbox_belongs_to_the_landlord_and_is_unreadable_from_another_one(): void
|
||||
{
|
||||
$withBox = Tenant::factory()->create([
|
||||
'mailbox_host' => 'imap.nord.example',
|
||||
'mailbox_username' => 'post@nord.example',
|
||||
'mailbox_password' => 'geheim',
|
||||
]);
|
||||
$without = Tenant::factory()->create();
|
||||
|
||||
app(TenantContext::class)->set($withBox);
|
||||
$this->assertTrue(MailboxReader::isConfigured());
|
||||
$this->assertSame('imap.nord.example', MailboxReader::configuration()['host']);
|
||||
$this->assertSame('geheim', MailboxReader::configuration()['password']);
|
||||
|
||||
app(TenantContext::class)->set($without);
|
||||
$this->assertFalse(MailboxReader::isConfigured(), 'Ein Mandant ohne Postfach sieht keines – auch nicht das fremde.');
|
||||
$this->assertNull(MailboxReader::configuration());
|
||||
|
||||
// Stored encrypted, like the bank details.
|
||||
$this->assertNotSame('geheim', DB::table('tenants')->where('id', $withBox->id)->value('mailbox_password'));
|
||||
}
|
||||
|
||||
public function test_the_ical_token_of_one_landlord_does_not_serve_another_ones_occupancy(): void
|
||||
{
|
||||
$nord = $this->websiteFor(Tenant::factory()->create(['name' => 'Nordhaus']), 'nord.test');
|
||||
$sued = $this->websiteFor(Tenant::factory()->create(['name' => 'Südheim']), 'sued.test');
|
||||
|
||||
$channel = app(TenantContext::class)->run($nord->tenant, fn (): Channel => Channel::factory()->create([
|
||||
'property_id' => Property::factory()->create(['site_id' => $nord->id])->id,
|
||||
]));
|
||||
|
||||
// On its own address the feed answers …
|
||||
$this->get('http://nord.test'.route('channels.feed', ['token' => $channel->export_token], absolute: false))->assertOk();
|
||||
|
||||
// … on the other landlord's address it does not exist.
|
||||
$this->get('http://sued.test'.route('channels.feed', ['token' => $channel->export_token], absolute: false))->assertNotFound();
|
||||
$this->assertNotNull($sued);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{Tenant, Booking}
|
||||
*/
|
||||
private function landlordWithExpiredHold(string $name, string $email, string $sender): array
|
||||
{
|
||||
$tenant = Tenant::factory()->create([
|
||||
'name' => $name,
|
||||
'owner_name' => $name,
|
||||
'notification_emails' => $email,
|
||||
'sender_email' => $email,
|
||||
'sender_name' => 'Absender '.$name,
|
||||
'operating_mode' => 'live',
|
||||
]);
|
||||
|
||||
$booking = app(TenantContext::class)->run($tenant, fn (): Booking => Booking::factory()
|
||||
->for(Property::factory()->create())
|
||||
->reserved(now()->subHour())
|
||||
->create());
|
||||
|
||||
return [$tenant, $booking];
|
||||
}
|
||||
|
||||
private function websiteFor(Tenant $tenant, string $host): Site
|
||||
{
|
||||
return app(TenantContext::class)->run($tenant, fn (): Site => Site::factory()->create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'name' => $tenant->name,
|
||||
'domain' => $host,
|
||||
'is_default' => false,
|
||||
]));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Models\Amenity;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Models\ContentBlock;
|
||||
use App\Models\Extra;
|
||||
use App\Models\Faq;
|
||||
use App\Models\Guest;
|
||||
use App\Models\Notice;
|
||||
use App\Models\Page;
|
||||
use App\Models\Payment;
|
||||
use App\Models\Photo;
|
||||
use App\Models\Property;
|
||||
use App\Models\Review;
|
||||
use App\Models\Season;
|
||||
use App\Models\Site;
|
||||
use App\Models\SpecialOffer;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
use App\Tenancy\TenantArchive;
|
||||
use App\Tenancy\TenantContext;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Tests\TestCase;
|
||||
use ZipArchive;
|
||||
|
||||
/**
|
||||
* Phase 5: the acceptance of the separation. Every area from A1 is filled for two landlords; then one is
|
||||
* exported and deleted, and the other has to be complete – rows, files and booking numbers.
|
||||
*
|
||||
* This is the test that would notice if a new table ever forgot its tenant_id: such a table would neither
|
||||
* be exported nor deleted, and its rows would outlive the landlord they belong to.
|
||||
*/
|
||||
class TenantSeparationTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_every_area_of_a_landlord_is_exported_and_deleted_while_the_other_stays_whole(): void
|
||||
{
|
||||
$gone = $this->landlordWithEverything('Geht');
|
||||
$stays = $this->landlordWithEverything('Bleibt');
|
||||
|
||||
$before = $this->census($stays);
|
||||
$this->assertNotEmpty(array_filter($before), 'Der Aufbau muss jeden Bereich füllen.');
|
||||
|
||||
$archive = app(TenantArchive::class);
|
||||
$directory = storage_path('framework/testing/tenant-export');
|
||||
$path = $archive->export($gone, $directory);
|
||||
|
||||
$this->assertFileExists($path);
|
||||
$this->assertExportHasOnly($path, $gone, $stays);
|
||||
|
||||
$archive->delete($gone);
|
||||
|
||||
$this->assertDatabaseMissing('tenants', ['id' => $gone->id]);
|
||||
|
||||
foreach ($archive->tables() as $table) {
|
||||
$this->assertSame(
|
||||
0,
|
||||
DB::table($table)->where('tenant_id', $gone->id)->count(),
|
||||
"In {$table} sind Zeilen des gelöschten Mandanten übrig.",
|
||||
);
|
||||
}
|
||||
|
||||
$this->assertSame($before, $this->census($stays), 'Der verbliebene Mandant hat sich verändert.');
|
||||
|
||||
// site_domains trägt keine tenant_id; die Hosts hängen über die Website am Mandanten. Bleibt hier
|
||||
// eine Zeile übrig, zeigt ein Host auf eine gelöschte Website – schlimmstenfalls auf einen fremden.
|
||||
$this->assertSame(0, DB::table('site_domains')->where('host', 'geht.test')->count(), 'Verwaister Host nach der Löschung.');
|
||||
$this->assertSame(1, DB::table('site_domains')->where('host', 'bleibt.test')->count());
|
||||
|
||||
File::deleteDirectory($directory);
|
||||
}
|
||||
|
||||
public function test_a_deleted_landlord_frees_their_booking_numbers_without_touching_the_others(): void
|
||||
{
|
||||
$gone = $this->landlordWithEverything('Geht');
|
||||
$stays = $this->landlordWithEverything('Bleibt');
|
||||
|
||||
$reference = app(TenantContext::class)->run($stays, fn (): string => Booking::query()->value('reference'));
|
||||
|
||||
app(TenantArchive::class)->delete($gone);
|
||||
|
||||
app(TenantContext::class)->run($stays, function () use ($reference): void {
|
||||
$this->assertSame($reference, Booking::query()->value('reference'));
|
||||
$this->assertSame(1, Booking::query()->count());
|
||||
});
|
||||
}
|
||||
|
||||
public function test_accounts_of_the_deleted_landlord_go_with_them_unless_they_serve_somebody_else(): void
|
||||
{
|
||||
$gone = $this->landlordWithEverything('Geht');
|
||||
$stays = $this->landlordWithEverything('Bleibt');
|
||||
|
||||
$onlyTheirs = User::factory()->create(['email' => 'nur-dort@example.com']);
|
||||
$onlyTheirs->tenants()->sync([$gone->id => ['role' => UserRole::Admin->value]]);
|
||||
|
||||
$shared = User::factory()->create(['email' => 'beide@example.com']);
|
||||
$shared->tenants()->sync([
|
||||
$gone->id => ['role' => UserRole::Rentals->value],
|
||||
$stays->id => ['role' => UserRole::Rentals->value],
|
||||
]);
|
||||
|
||||
$operator = User::factory()->create(['email' => 'betrieb@example.com']);
|
||||
$operator->tenants()->sync([$gone->id => ['role' => UserRole::Admin->value]]);
|
||||
$operator->forceFill(['is_operator' => true])->saveQuietly();
|
||||
|
||||
app(TenantArchive::class)->delete($gone);
|
||||
|
||||
$this->assertDatabaseMissing('users', ['email' => 'nur-dort@example.com']);
|
||||
$this->assertDatabaseHas('users', ['email' => 'beide@example.com']);
|
||||
$this->assertDatabaseHas('users', ['email' => 'betrieb@example.com']);
|
||||
$this->assertSame([$stays->id], $shared->fresh()->tenants()->pluck('tenants.id')->all());
|
||||
}
|
||||
|
||||
public function test_the_export_names_the_accounts_but_not_their_passwords(): void
|
||||
{
|
||||
$tenant = $this->landlordWithEverything('Geht');
|
||||
$user = User::factory()->create(['email' => 'wirt@example.com', 'name' => 'Wirt']);
|
||||
$user->tenants()->sync([$tenant->id => ['role' => UserRole::Admin->value]]);
|
||||
|
||||
$exported = app(TenantArchive::class)->usersOf($tenant);
|
||||
|
||||
$this->assertSame(['wirt@example.com'], array_column($exported, 'email'));
|
||||
$this->assertSame('admin', $exported[0]['role']);
|
||||
$this->assertArrayNotHasKey('password', $exported[0]);
|
||||
$this->assertStringNotContainsString($user->password, (string) json_encode($exported));
|
||||
}
|
||||
|
||||
/**
|
||||
* The archive of one landlord must not carry a single row of the other.
|
||||
*/
|
||||
private function assertExportHasOnly(string $path, Tenant $exported, Tenant $other): void
|
||||
{
|
||||
$zip = new ZipArchive;
|
||||
$this->assertTrue($zip->open($path) === true);
|
||||
|
||||
$seen = 0;
|
||||
|
||||
for ($i = 0; $i < $zip->numFiles; $i++) {
|
||||
$name = (string) $zip->getNameIndex($i);
|
||||
|
||||
if (! str_starts_with($name, 'daten/')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rows = json_decode((string) $zip->getFromIndex($i), true);
|
||||
$this->assertIsArray($rows);
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$seen++;
|
||||
$this->assertSame($exported->id, $row['tenant_id'], "Fremde Zeile in {$name}.");
|
||||
$this->assertNotSame($other->id, $row['tenant_id']);
|
||||
}
|
||||
}
|
||||
|
||||
$zip->close();
|
||||
|
||||
$this->assertGreaterThan(0, $seen, 'Das Archiv enthält keine Daten.');
|
||||
}
|
||||
|
||||
/**
|
||||
* How many rows this landlord has per table – the yardstick for "unchanged".
|
||||
*
|
||||
* @return array<string, int>
|
||||
*/
|
||||
private function census(Tenant $tenant): array
|
||||
{
|
||||
$counts = [];
|
||||
|
||||
foreach (app(TenantArchive::class)->tables() as $table) {
|
||||
$counts[$table] = DB::table($table)->where('tenant_id', $tenant->id)->count();
|
||||
}
|
||||
|
||||
return $counts;
|
||||
}
|
||||
|
||||
/**
|
||||
* One landlord with at least one row in every area of A1.
|
||||
*/
|
||||
private function landlordWithEverything(string $name): Tenant
|
||||
{
|
||||
$tenant = Tenant::factory()->create(['name' => $name]);
|
||||
|
||||
app(TenantContext::class)->run($tenant, function () use ($name): void {
|
||||
$site = Site::factory()->create([
|
||||
'name' => $name,
|
||||
'domain' => mb_strtolower($name).'.test',
|
||||
'is_default' => false,
|
||||
]);
|
||||
$property = Property::factory()->create(['site_id' => $site->id]);
|
||||
|
||||
Page::factory()->create(['site_id' => $site->id, 'slug' => Page::HOME, 'sections' => []]);
|
||||
Season::factory()->create(['property_id' => $property->id]);
|
||||
Extra::factory()->create(['property_id' => $property->id]);
|
||||
Amenity::factory()->create(['property_id' => $property->id]);
|
||||
SpecialOffer::factory()->create(['property_id' => $property->id]);
|
||||
Photo::factory()->create(['property_id' => $property->id]);
|
||||
Faq::factory()->create();
|
||||
Notice::factory()->create();
|
||||
ContentBlock::query()->create(['key' => 'legal.imprint', 'value' => 'Impressum '.$name]);
|
||||
|
||||
$guest = Guest::factory()->create();
|
||||
$booking = Booking::factory()->for($property)->create(['guest_id' => $guest->id]);
|
||||
Payment::factory()->create(['booking_id' => $booking->id]);
|
||||
Review::factory()->create(['booking_id' => $booking->id, 'property_id' => $property->id]);
|
||||
|
||||
$channel = Channel::factory()->create(['property_id' => $property->id]);
|
||||
BlockedPeriod::factory()->create(['property_id' => $property->id, 'channel_id' => $channel->id]);
|
||||
});
|
||||
|
||||
return $tenant;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Enums\TenantServiceKey;
|
||||
use App\Filament\Operator\Tenants\Pages\CreateTenant;
|
||||
use App\Filament\Operator\Tenants\Pages\EditTenant;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
@@ -99,6 +100,41 @@ public function test_a_landlord_without_a_decision_keeps_the_portal_services():
|
||||
$this->assertFalse(app(TenantFeatures::class)->enabled(TenantServiceKey::AiOffers, $tenant));
|
||||
}
|
||||
|
||||
public function test_the_operator_creates_a_landlord_in_the_operator_panel(): void
|
||||
{
|
||||
$existing = Tenant::factory()->create();
|
||||
app(TenantContext::class)->set($existing);
|
||||
$operator = User::factory()->create();
|
||||
$operator->forceFill(['is_operator' => true])->saveQuietly();
|
||||
$this->actingAs($operator);
|
||||
Filament::setCurrentPanel('operator');
|
||||
|
||||
$this->get('/betreiber/tenants')->assertOk()->assertSee('Neuen Mandanten anlegen');
|
||||
$this->get('/betreiber/tenants/create')->assertOk();
|
||||
|
||||
Livewire::test(CreateTenant::class)
|
||||
->fillForm([
|
||||
'name' => 'Ferienhaus Düne',
|
||||
'slug' => 'duene',
|
||||
'is_active' => true,
|
||||
'websites' => [['name' => 'Ferienhaus Düne', 'hosts' => ['duene.example']]],
|
||||
'services.'.TenantServiceKey::PortalSync->value.'.is_enabled' => true,
|
||||
'services.'.TenantServiceKey::PortalMail->value.'.is_enabled' => false,
|
||||
])
|
||||
->call('create')
|
||||
->assertHasNoErrors();
|
||||
|
||||
$created = Tenant::query()->where('slug', 'duene')->sole();
|
||||
|
||||
$this->assertSame('Ferienhaus Düne', $created->name);
|
||||
$this->assertTrue(app(TenantFeatures::class)->enabled(TenantServiceKey::PortalSync, $created));
|
||||
$this->assertFalse(app(TenantFeatures::class)->enabled(TenantServiceKey::PortalMail, $created));
|
||||
|
||||
// A new landlord must not inherit anything from the one the operator happened to be looking at.
|
||||
$this->assertNull($created->contact_email);
|
||||
$this->assertSame(Settings::MODE_TEST, $created->operating_mode);
|
||||
}
|
||||
|
||||
public function test_the_operator_switches_a_service_on_the_tenant_form(): void
|
||||
{
|
||||
$tenant = Tenant::factory()->create();
|
||||
|
||||
@@ -3,15 +3,14 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Actions\SendOffer;
|
||||
use App\Enums\UserRole;
|
||||
use App\Filament\Resources\Sites\Pages\EditSite;
|
||||
use App\Filament\Operator\Tenants\Pages\EditTenant;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Page;
|
||||
use App\Models\Property;
|
||||
use App\Models\Site;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
use App\Tenancy\TenantContext;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Features\SupportTesting\Testable;
|
||||
use Livewire\Livewire;
|
||||
@@ -98,17 +97,24 @@ public function test_the_offer_link_uses_the_website_address(): void
|
||||
}
|
||||
|
||||
/**
|
||||
* Enters the further addresses through the real admin form, so the form's own defences are under test.
|
||||
* Enters the addresses the way they are really entered: by the operator, on the landlord. The form's
|
||||
* own defences are under test with them.
|
||||
*
|
||||
* @param list<string> $hosts
|
||||
*/
|
||||
private function editHosts(Site $site, array $hosts): Testable
|
||||
{
|
||||
app(TenantContext::class)->set($site->tenant);
|
||||
$this->actingAs(User::factory()->role(UserRole::Admin)->create());
|
||||
$operator = User::factory()->create();
|
||||
$operator->forceFill(['is_operator' => true])->saveQuietly();
|
||||
$this->actingAs($operator);
|
||||
Filament::setCurrentPanel('operator');
|
||||
|
||||
return Livewire::test(EditSite::class, ['record' => $site->getRouteKey()])
|
||||
->fillForm(['extra_hosts' => $hosts])
|
||||
return Livewire::test(EditTenant::class, ['record' => $site->tenant->getRouteKey()])
|
||||
->fillForm(['websites' => [[
|
||||
'id' => $site->id,
|
||||
'name' => $site->name,
|
||||
'hosts' => [$site->domain, ...$hosts],
|
||||
]]])
|
||||
->call('save');
|
||||
}
|
||||
|
||||
|
||||