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
+50
-2
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Support\Settings;
|
||||
use App\Tenancy\TenantDefaults;
|
||||
use Database\Factories\TenantFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
@@ -13,7 +15,17 @@
|
||||
* A landlord. Owns websites, apartments, guests, bookings and settings. One account can belong
|
||||
* to several landlords; the operator is not a landlord.
|
||||
*/
|
||||
#[Fillable(['name', 'slug', 'is_active'])]
|
||||
#[Fillable([
|
||||
'name', 'slug', 'is_active',
|
||||
'owner_name', 'owner_street', 'owner_city', 'owner_phone', 'contact_email', 'notification_emails',
|
||||
'sender_name', 'sender_email',
|
||||
'bank_account_holder', 'bank_iban', 'bank_bic', 'bank_name', 'tax_note',
|
||||
'operating_mode', 'test_recipient',
|
||||
'deposit_due_days', 'review_request_after_days', 'guest_retention_years', 'retention_inquiry_months',
|
||||
'retention_portal_email_excerpt_days', 'retention_attribution_months',
|
||||
'spam_min_seconds', 'spam_per_ip_per_hour', 'spam_per_email_per_day', 'spam_open_requests_per_email', 'spam_max_links',
|
||||
'channel_stale_after_minutes', 'channel_task_reminder_after_minutes',
|
||||
])]
|
||||
class Tenant extends Model
|
||||
{
|
||||
/** @use HasFactory<TenantFactory> */
|
||||
@@ -26,7 +38,7 @@ public static function stommer(): self
|
||||
{
|
||||
return static::query()->firstOrCreate(
|
||||
['slug' => 'stommer'],
|
||||
['name' => 'Stommer'],
|
||||
['name' => 'Stommer'] + TenantDefaults::forLegacyLandlord(encryptBank: false),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -37,6 +49,11 @@ protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'is_active' => 'boolean',
|
||||
'bank_account_holder' => 'encrypted',
|
||||
'bank_iban' => 'encrypted',
|
||||
'bank_bic' => 'encrypted',
|
||||
'bank_name' => 'encrypted',
|
||||
'tax_note' => 'encrypted',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -56,6 +73,37 @@ public function properties(): HasMany
|
||||
return $this->hasMany(Property::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<TenantService, $this>
|
||||
*/
|
||||
public function services(): HasMany
|
||||
{
|
||||
return $this->hasMany(TenantService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<ServiceUsage, $this>
|
||||
*/
|
||||
public function serviceUsages(): HasMany
|
||||
{
|
||||
return $this->hasMany(ServiceUsage::class);
|
||||
}
|
||||
|
||||
public function isLive(): bool
|
||||
{
|
||||
return $this->operating_mode === 'live';
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification addresses of this landlord.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function notificationRecipients(): array
|
||||
{
|
||||
return Settings::addressList($this->notification_emails);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsToMany<User, $this>
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user