Gästeverzeichnis und Customer Voice
- Gäste: Markierungen, Aufenthalte & Umsatz, Stammgast-/Einwilligungsfilter, CSV-Export, Anonymisierung (manuell + automatisch nach Aufbewahrungsfrist) - Werbe-Einwilligung per Double-Opt-in aus dem Anfrageformular, signierte Bestätigungs-/Abmeldelinks - Bewertungen: automatische Einladung nach Abreise, Bewertungsformular mit Kategorien und internem Feedback, Freigabe und öffentliche Antwort im Admin - Konzept: Rollen, Inhalte, Customer Voice, Architektur Portal-Sync/Buchungshoheit Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bb7eb62782
commit
2892e6aeab
44 files changed
+1505
-23
No files matched your search
@@ -11,6 +11,7 @@
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
/**
|
||||
* A reservation or booking. arrival is the first night, departure the day the guest leaves,
|
||||
@@ -35,6 +36,7 @@
|
||||
'internal_notes',
|
||||
'confirmed_at',
|
||||
'cancelled_at',
|
||||
'review_requested_at',
|
||||
])]
|
||||
class Booking extends Model
|
||||
{
|
||||
@@ -65,6 +67,7 @@ protected function casts(): array
|
||||
'hold_expires_at' => 'immutable_datetime',
|
||||
'confirmed_at' => 'immutable_datetime',
|
||||
'cancelled_at' => 'immutable_datetime',
|
||||
'review_requested_at' => 'immutable_datetime',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -112,6 +115,14 @@ protected function overlapping(Builder $query, CarbonInterface $from, CarbonInte
|
||||
->whereDate('departure', '>', $from);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasOne<Review, $this>
|
||||
*/
|
||||
public function review(): HasOne
|
||||
{
|
||||
return $this->hasOne(Review::class);
|
||||
}
|
||||
|
||||
public function nights(): int
|
||||
{
|
||||
return (int) $this->arrival->diffInDays($this->departure);
|
||||
|
||||
+54
-1
@@ -4,18 +4,35 @@
|
||||
|
||||
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'])]
|
||||
#[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>
|
||||
*/
|
||||
@@ -31,4 +48,40 @@ 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]);
|
||||
|
||||
$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();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ReviewStatus;
|
||||
use Database\Factories\ReviewFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Scope;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* A guest review. Reviews from the website always belong to a booking (verified stay);
|
||||
* reviews taken over from portals carry their source instead.
|
||||
*/
|
||||
#[Fillable([
|
||||
'property_id',
|
||||
'booking_id',
|
||||
'status',
|
||||
'source',
|
||||
'rating',
|
||||
'rating_cleanliness',
|
||||
'rating_equipment',
|
||||
'rating_location',
|
||||
'rating_host',
|
||||
'title',
|
||||
'body',
|
||||
'private_feedback',
|
||||
'display_name',
|
||||
'publish_consent',
|
||||
'stayed_on',
|
||||
'response',
|
||||
'responded_at',
|
||||
'approved_at',
|
||||
])]
|
||||
class Review extends Model
|
||||
{
|
||||
/** @use HasFactory<ReviewFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/** Rating categories besides the overall rating, with their German labels. */
|
||||
public const CATEGORIES = [
|
||||
'rating_cleanliness' => 'Sauberkeit',
|
||||
'rating_equipment' => 'Ausstattung',
|
||||
'rating_location' => 'Lage',
|
||||
'rating_host' => 'Gastgeber',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::saving(function (Review $review): void {
|
||||
if ($review->status === ReviewStatus::Approved && $review->approved_at === null) {
|
||||
$review->approved_at = now();
|
||||
}
|
||||
|
||||
if ($review->isDirty('response')) {
|
||||
$review->responded_at = filled($review->response) ? now() : null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'status' => ReviewStatus::class,
|
||||
'publish_consent' => 'boolean',
|
||||
'stayed_on' => 'immutable_date',
|
||||
'responded_at' => 'immutable_datetime',
|
||||
'approved_at' => 'immutable_datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Property, $this>
|
||||
*/
|
||||
public function property(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Property::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Booking, $this>
|
||||
*/
|
||||
public function booking(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Booking::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reviews that may be shown on the website.
|
||||
*
|
||||
* @param Builder<Review> $query
|
||||
* @return Builder<Review>
|
||||
*/
|
||||
#[Scope]
|
||||
protected function published(Builder $query): Builder
|
||||
{
|
||||
return $query
|
||||
->where('status', ReviewStatus::Approved)
|
||||
->where('publish_consent', true)
|
||||
->latest('stayed_on');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user