- 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>
73 lines
2.3 KiB
PHP
73 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire;
|
|
|
|
use App\Actions\SubmitReview;
|
|
use App\Models\Booking;
|
|
use App\Models\Review;
|
|
use Illuminate\Contracts\View\View;
|
|
use Livewire\Component;
|
|
|
|
/**
|
|
* Review form for a finished stay, reached through the signed link in the review invitation.
|
|
*/
|
|
class ReviewForm extends Component
|
|
{
|
|
public Booking $booking;
|
|
|
|
public int $rating = 0;
|
|
|
|
/** @var array<string, int> */
|
|
public array $categories = ['rating_cleanliness' => 0, 'rating_equipment' => 0, 'rating_location' => 0, 'rating_host' => 0];
|
|
|
|
public string $title = '';
|
|
|
|
public string $body = '';
|
|
|
|
public string $privateFeedback = '';
|
|
|
|
public string $displayName = '';
|
|
|
|
public bool $publishConsent = true;
|
|
|
|
public bool $submitted = false;
|
|
|
|
public function mount(Booking $booking): void
|
|
{
|
|
$this->booking = $booking;
|
|
$this->displayName = $booking->guest->first_name.' '.mb_substr($booking->guest->last_name, 0, 1).'.'.($booking->guest->city ? ' aus '.$booking->guest->city : '');
|
|
}
|
|
|
|
public function submit(SubmitReview $submitReview): void
|
|
{
|
|
$this->validate([
|
|
'rating' => ['required', 'integer', 'between:1,5'],
|
|
'categories.*' => ['integer', 'between:0,5'],
|
|
'title' => ['nullable', 'string', 'max:120'],
|
|
'body' => ['nullable', 'string', 'max:3000'],
|
|
'privateFeedback' => ['nullable', 'string', 'max:3000'],
|
|
'displayName' => ['required', 'string', 'max:80'],
|
|
], [], ['rating' => 'Gesamtbewertung', 'displayName' => 'Angezeigter Name']);
|
|
|
|
$submitReview->handle($this->booking, [
|
|
'rating' => $this->rating,
|
|
...array_map(fn (int $value): ?int => $value > 0 ? $value : null, $this->categories),
|
|
'title' => $this->title ?: null,
|
|
'body' => $this->body ?: null,
|
|
'private_feedback' => $this->privateFeedback ?: null,
|
|
'display_name' => $this->displayName,
|
|
'publish_consent' => $this->publishConsent,
|
|
]);
|
|
|
|
$this->submitted = true;
|
|
}
|
|
|
|
public function render(): View
|
|
{
|
|
return view('livewire.review-form', [
|
|
'canReview' => $this->submitted || SubmitReview::canReview($this->booking),
|
|
'categoryLabels' => Review::CATEGORIES,
|
|
]);
|
|
}
|
|
}
|