- Offer workflow: "Angebot senden" in the admin (dates, guests, promo code, manual price adjustment, validity from the property's hold time, message, guest data for the contract) with live price; contract draft PDF; signed, versioned offer page for the guest to accept (acceptance record without IP) or decline; expiry job, landlord notifications, editable offer texts, wording on the website. - 2FA is mandatory for every admin account. - Privacy: complete anonymisation (notes, attribution, review names, offer messages), shorter periods for unbinding requests, portal mail excerpts and attribution (configurable proposals), iCal summary not stored, known e-mail no longer overwrites guest data, security headers, bearer tokens for automations, metadata stripped from photo originals, review link throttled. - Daily database backup (backup:database) and scripts/backup-pull.sh for the NAS. - Theme: brand mark in header/footer, favicon/touch icon, wave divider, icons, illustration as image placeholder; navy follows the text colour for dark appearances. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
100 lines
3.0 KiB
PHP
100 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Database\Factories\GuestFactory;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Attributes\Scope;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
#[Fillable(['first_name', 'last_name', 'email', 'phone', 'street', 'postal_code', 'city', 'country', 'locale', 'notes', 'tags'])]
|
|
class Guest extends Model
|
|
{
|
|
/** @use HasFactory<GuestFactory> */
|
|
use HasFactory, Notifiable;
|
|
|
|
/**
|
|
* Get the attributes that should be cast.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'tags' => 'array',
|
|
'marketing_consent_at' => 'immutable_datetime',
|
|
'anonymized_at' => 'immutable_datetime',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<Booking, $this>
|
|
*/
|
|
public function bookings(): HasMany
|
|
{
|
|
return $this->hasMany(Booking::class)->latest('arrival');
|
|
}
|
|
|
|
/**
|
|
* @return Attribute<string, never>
|
|
*/
|
|
protected function fullName(): Attribute
|
|
{
|
|
return Attribute::get(fn (): string => "{$this->first_name} {$this->last_name}");
|
|
}
|
|
|
|
/**
|
|
* Guests who confirmed (double opt-in) that they want to receive offers by e-mail.
|
|
*
|
|
* @param Builder<Guest> $query
|
|
* @return Builder<Guest>
|
|
*/
|
|
#[Scope]
|
|
protected function withMarketingConsent(Builder $query): Builder
|
|
{
|
|
return $query->whereNotNull('marketing_consent_at')->whereNull('anonymized_at');
|
|
}
|
|
|
|
/**
|
|
* Removes all personal data (GDPR). Bookings stay for accounting, without personal messages.
|
|
*/
|
|
public function anonymize(): void
|
|
{
|
|
DB::transaction(function (): void {
|
|
$this->bookings()->update([
|
|
'message' => null,
|
|
'internal_notes' => null,
|
|
'offer_message' => null,
|
|
'referral_source' => null,
|
|
'utm_source' => null,
|
|
'utm_medium' => null,
|
|
'utm_campaign' => null,
|
|
]);
|
|
Review::query()->whereIn('booking_id', $this->bookings()->select('id'))->update([
|
|
'display_name' => 'Gast',
|
|
'private_feedback' => null,
|
|
]);
|
|
|
|
$this->forceFill([
|
|
'first_name' => 'Anonymisiert',
|
|
'last_name' => "#{$this->id}",
|
|
'email' => "anonymisiert-{$this->id}@invalid.local",
|
|
'phone' => null,
|
|
'street' => null,
|
|
'postal_code' => null,
|
|
'city' => null,
|
|
'notes' => null,
|
|
'tags' => null,
|
|
'marketing_consent_at' => null,
|
|
'anonymized_at' => now(),
|
|
])->save();
|
|
});
|
|
}
|
|
}
|