Ein neu angelegter Mandant war eine Sackgasse. Er bekam keine Website, also keinen Host, also keine Adresse – und der Host wird im Mandanten-Admin eingetragen, den er ohne Adresse nicht erreicht. „Im Admin öffnen" half nicht: ohne Domain landete es beim Mandanten des aktuellen Hosts. Einsprungsadressen gehören jetzt dem Betreiber, weil Webspace und Hosting ihm gehören und ein Mandant nicht die Adresse eines anderen auf sich zeigen lassen darf. Im Mandanten-Formular: Websites mit ihren Adressen. Beim Anlegen entstehen Website, Host-Einträge und eine leere Startseite – ohne Startseite antwortet die Website mit 404. Im Mandanten-Admin sind die Adressen nur noch sichtbar, nicht änderbar. Die Domain beim Hoster auf das Verzeichnis zu legen bleibt ein Schritt von Hand. Gesperrter Mandant: statt 404 ein Hinweis mit Status 503, Text je Mandant einstellbar. 503 hält die Seiten im Suchindex, weil die Sperre vorübergehend ist. Behoben: `URL::forceRootUrl(APP_URL)` zwang **alle** Links auf einen festen Host. Mit einem Mandanten unsichtbar; mit zwei Domains hätte jeder interne Link der zweiten Website auf die erste gezeigt. Der Ursprung ist jetzt der Host der aufgelösten Website. Neu: systemweite Einstellungen sind im Betreiber-Bereich änderbar (Löschfristen, Bot-Schutz, Flutgrenze, Sicherungen, Portal-Fristen, Versandweg, SMTP, harte Mail-Umleitung, Tokens). Leer heißt: der Wert der .env gilt wieder – und zwar sofort, nicht erst beim nächsten Start. Geheimnisse liegen verschlüsselt. Datenbank-Zugang und APP_KEY bleiben in der .env, weil sie gebraucht werden, um die Datenbank zu öffnen und das Gespeicherte zu entschlüsseln. 253 Feature-Tests grün. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
115 lines
3.1 KiB
PHP
115 lines
3.1 KiB
PHP
<?php
|
|
|
|
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;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
/**
|
|
* 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',
|
|
'owner_name', 'owner_street', 'owner_city', 'owner_phone', 'contact_email', 'notification_emails',
|
|
'sender_name', 'sender_email',
|
|
'bank_account_holder', 'bank_iban', 'bank_bic', 'bank_name', 'tax_note',
|
|
'operating_mode', 'test_recipient', 'suspended_message',
|
|
'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> */
|
|
use HasFactory;
|
|
|
|
/**
|
|
* The landlord the existing single-website data belongs to.
|
|
*/
|
|
public static function stommer(): self
|
|
{
|
|
return static::query()->firstOrCreate(
|
|
['slug' => 'stommer'],
|
|
['name' => 'Stommer'] + TenantDefaults::forLegacyLandlord(encryptBank: false),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'is_active' => 'boolean',
|
|
'bank_account_holder' => 'encrypted',
|
|
'bank_iban' => 'encrypted',
|
|
'bank_bic' => 'encrypted',
|
|
'bank_name' => 'encrypted',
|
|
'tax_note' => 'encrypted',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<Site, $this>
|
|
*/
|
|
public function sites(): HasMany
|
|
{
|
|
return $this->hasMany(Site::class);
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<Property, $this>
|
|
*/
|
|
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>
|
|
*/
|
|
public function users(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(User::class)->withPivot('role')->withTimestamps();
|
|
}
|
|
}
|