*/ 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, ]); } }