Mandanten Phase 3: Einstellungen, Texte und Dienste gehören dem Mandanten
Vermieterdaten, Bank, Steuerangabe, Adressen, Betriebsart und Fristen sind
Spalten von `tenants`. `App\Tenancy\TenantConfig` legt sie über
`config('fewo.*')` und `mail.from`, sobald der Mandantenkontext wechselt –
so lesen Vorlagen, Mails und der Mietvertrag weiter dieselben Schlüssel und
`resources/themes/**` bleibt unangetastet.
Die `.env` ist die Grundlinie: Rückfall, solange kein Mandant feststeht, und
Grenze für Löschfristen und Bot-Schutz (nur verschärfen, nicht lockern). Die
Flutgrenze bleibt global. Bank, Steuerangabe und eigene Dienst-Schlüssel
liegen verschlüsselt.
Die Seite System › Betrieb schreibt jetzt den Mandanten und enthält
zusätzlich Vermieterdaten, Bank und die Fristen. Tabelle `settings` und
Modell `Setting` entfallen; die Migration übernimmt die bisherigen Werte
aus `settings` und der Konfiguration in den Mandanten Stommer.
Neu: `tenant_services` (Freischaltung je Dienst mit optionalem eigenem
API-Schlüssel, nur im Betreiber-Bereich schaltbar) und `service_usages`.
Es zählt noch nichts, weil kein Dienst aufruft.
235 Feature-Tests grün. Der Umbauweg wurde zusätzlich auf einer Kopie der
lokalen Datenbank durchgespielt.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
12e4079126
commit
e6d4d89141
24 files changed
+1123
-135
No files matched your search
@@ -3,6 +3,7 @@
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Tenancy\TenantDefaults;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@@ -22,6 +23,7 @@ public function definition(): array
|
||||
'name' => $name,
|
||||
'slug' => Str::slug($name).'-'.Str::lower(Str::random(4)),
|
||||
'is_active' => true,
|
||||
...TenantDefaults::forLegacyLandlord(encryptBank: false),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
use App\Tenancy\TenantDefaults;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Landlord data, bank, addresses, operating mode and periods become columns of the landlord. The values
|
||||
* of the existing (single) landlord come from the `settings` table and from config/.env. The `settings`
|
||||
* table stays until the shipped code no longer reads it (own step, see docs/MANDANTEN-PLAN.md §4).
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
$table->string('owner_name')->nullable();
|
||||
$table->string('owner_street')->nullable();
|
||||
$table->string('owner_city')->nullable();
|
||||
$table->string('owner_phone')->nullable();
|
||||
$table->string('contact_email')->nullable();
|
||||
$table->text('notification_emails')->nullable();
|
||||
$table->string('sender_name')->nullable();
|
||||
$table->string('sender_email')->nullable();
|
||||
$table->text('bank_account_holder')->nullable();
|
||||
$table->text('bank_iban')->nullable();
|
||||
$table->text('bank_bic')->nullable();
|
||||
$table->text('bank_name')->nullable();
|
||||
$table->text('tax_note')->nullable();
|
||||
$table->string('operating_mode', 10)->default('test');
|
||||
$table->string('test_recipient')->nullable();
|
||||
$table->unsignedSmallInteger('deposit_due_days')->nullable();
|
||||
$table->unsignedSmallInteger('review_request_after_days')->nullable();
|
||||
$table->unsignedSmallInteger('guest_retention_years')->nullable();
|
||||
$table->unsignedSmallInteger('retention_inquiry_months')->nullable();
|
||||
$table->unsignedSmallInteger('retention_portal_email_excerpt_days')->nullable();
|
||||
$table->unsignedSmallInteger('retention_attribution_months')->nullable();
|
||||
$table->unsignedSmallInteger('spam_min_seconds')->nullable();
|
||||
$table->unsignedSmallInteger('spam_per_ip_per_hour')->nullable();
|
||||
$table->unsignedSmallInteger('spam_per_email_per_day')->nullable();
|
||||
$table->unsignedSmallInteger('spam_open_requests_per_email')->nullable();
|
||||
$table->unsignedSmallInteger('spam_max_links')->nullable();
|
||||
$table->unsignedSmallInteger('channel_stale_after_minutes')->nullable();
|
||||
$table->unsignedSmallInteger('channel_task_reminder_after_minutes')->nullable();
|
||||
});
|
||||
|
||||
$stommer = DB::table('tenants')->where('slug', 'stommer')->first();
|
||||
|
||||
if ($stommer !== null) {
|
||||
DB::table('tenants')->where('id', $stommer->id)->update(TenantDefaults::forLegacyLandlord(
|
||||
DB::table('settings')->pluck('value', 'key')->all(),
|
||||
));
|
||||
}
|
||||
|
||||
Schema::create('tenant_services', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('service', 40);
|
||||
$table->boolean('is_enabled')->default(false);
|
||||
$table->text('api_key')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['tenant_id', 'service']);
|
||||
});
|
||||
|
||||
Schema::create('service_usages', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('service', 40);
|
||||
$table->unsignedInteger('quantity')->default(1);
|
||||
$table->timestamp('used_at')->useCurrent();
|
||||
|
||||
$table->index(['tenant_id', 'service', 'used_at']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('service_usages');
|
||||
Schema::dropIfExists('tenant_services');
|
||||
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'owner_name', 'owner_street', 'owner_city', 'owner_phone', 'contact_email', 'notification_emails',
|
||||
'sender_name', 'sender_email', 'bank_account_holder', 'bank_iban', 'bank_bic', 'bank_name', 'tax_note',
|
||||
'operating_mode', 'test_recipient', 'deposit_due_days', 'review_request_after_days',
|
||||
'guest_retention_years', 'retention_inquiry_months', 'retention_portal_email_excerpt_days',
|
||||
'retention_attribution_months', 'spam_min_seconds', 'spam_per_ip_per_hour', 'spam_per_email_per_day',
|
||||
'spam_open_requests_per_email', 'spam_max_links', 'channel_stale_after_minutes',
|
||||
'channel_task_reminder_after_minutes',
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* The operating settings are columns of the landlord now (see the previous migration); nothing reads
|
||||
* this table any more. One store for operating data, not two.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::dropIfExists('settings');
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::create('settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('key')->unique();
|
||||
$table->text('value')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user