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:
Lars StommerandClaude Opus 5.5 committed 2026-10-22 10:26:11 +02:00
1 parent bb7eb62782
commit 2892e6aeab
44 files changed
+1505 -23

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
<?php
namespace App\Actions;
use App\Models\Guest;
/**
* Anonymises guests whose last stay ended longer ago than the retention period (GDPR storage limitation).
*/
class AnonymizeGuests
{
public function handle(): int
{
$cutoff = today()->subYears(config('fewo.guest_retention_years'));
$guests = Guest::query()
->whereNull('anonymized_at')
->whereDate('created_at', '<', $cutoff)
->whereDoesntHave('bookings', fn ($query) => $query->whereDate('departure', '>=', $cutoff))
->get();
$guests->each->anonymize();
return $guests->count();
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace App\Actions;
use App\Mail\MarketingConsentRequest;
use App\Models\Guest;
use Illuminate\Support\Facades\Mail;
/**
* First step of the double opt-in: the guest receives a confirmation link.
*/
class RequestMarketingConsent
{
public function handle(Guest $guest): void
{
if ($guest->marketing_consent_at !== null || $guest->anonymized_at !== null) {
return;
}
Mail::to($guest->email, $guest->full_name)->send(new MarketingConsentRequest($guest));
}
}
+37
View File
@@ -0,0 +1,37 @@
<?php
namespace App\Actions;
use App\Enums\BookingStatus;
use App\Mail\ReviewRequest;
use App\Models\Booking;
use Illuminate\Support\Facades\Mail;
/**
* Sends the review invitation once, a few days after departure. Old stays (more than 30 days ago)
* are skipped so that switching the feature on does not mail former guests.
*/
class RequestReviews
{
public function handle(): int
{
$latestDeparture = today()->subDays(config('fewo.review_request_after_days'));
$bookings = Booking::query()
->whereIn('status', BookingStatus::occupying())
->whereNull('review_requested_at')
->whereDate('departure', '<=', $latestDeparture)
->whereDate('departure', '>', $latestDeparture->copy()->subDays(30))
->whereDoesntHave('review')
->whereHas('guest', fn ($query) => $query->whereNull('anonymized_at'))
->with('guest')
->get();
foreach ($bookings as $booking) {
Mail::to($booking->guest->email, $booking->guest->full_name)->send(new ReviewRequest($booking));
$booking->update(['review_requested_at' => now()]);
}
return $bookings->count();
}
}
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace App\Actions;
use App\Enums\BookingStatus;
use App\Enums\ReviewStatus;
use App\Mail\NewReview;
use App\Models\Booking;
use App\Models\Review;
use Illuminate\Support\Facades\Mail;
use RuntimeException;
/**
* Stores a review written by a guest of a real, finished stay. It is published only after approval.
*/
class SubmitReview
{
/**
* @param array{rating: int, rating_cleanliness?: ?int, rating_equipment?: ?int, rating_location?: ?int, rating_host?: ?int, title?: ?string, body?: ?string, private_feedback?: ?string, display_name: string, publish_consent: bool} $data
*/
public function handle(Booking $booking, array $data): Review
{
if (! self::canReview($booking)) {
throw new RuntimeException('Für diese Buchung kann keine Bewertung abgegeben werden.');
}
$review = $booking->review()->create([
...$data,
'property_id' => $booking->property_id,
'status' => ReviewStatus::Pending,
'source' => 'website',
'stayed_on' => $booking->arrival,
]);
Mail::to(config('fewo.notification_email'))->send(new NewReview($review));
return $review;
}
public static function canReview(Booking $booking): bool
{
return in_array($booking->status, BookingStatus::occupying(), true)
&& $booking->departure->lessThanOrEqualTo(today())
&& ! $booking->review()->exists();
}
}