*/ public array $interestOptions = []; public string $interest = ''; public string $firstName = ''; public string $lastName = ''; public string $email = ''; public string $phone = ''; public string $message = ''; public bool $privacy = false; public bool $success = false; /** @var string Hidden honeypot field */ public string $website = ''; public ?int $formLoadedAt = null; /** * @param array $interestOptions */ public function mount(string $projectSlug = '', string $projectTitle = '', array $interestOptions = []): void { $this->projectSlug = $projectSlug; $this->projectTitle = $projectTitle; $this->interestOptions = $interestOptions; $this->formLoadedAt = time(); } public function submit(ContactFormService $service): void { $this->validate([ 'firstName' => ['required', 'string', 'max:255'], 'lastName' => ['required', 'string', 'max:255'], 'email' => ['required', 'email:rfc', 'max:255'], 'phone' => ['nullable', 'string', 'max:80'], 'interest' => ['nullable', 'string', 'max:255'], 'message' => ['nullable', 'string', 'max:2000'], 'privacy' => ['accepted'], 'website' => ['nullable', 'string', 'max:0'], ]); $spamDetector = SpamDetector::fromConfig(); $payload = [ 'project' => $this->projectSlug, 'project_title' => $this->projectTitle, 'interest' => $this->interest, 'first_name' => $this->firstName, 'last_name' => $this->lastName, 'email' => $this->email, 'phone' => $this->phone, 'message' => $this->message, 'website' => $this->website, 'ip' => request()->ip(), 'user_agent' => request()->userAgent(), 'is_spam' => false, ]; $payload['is_spam'] = $spamDetector->detect($payload, $this->formLoadedAt); $subject = 'Immobilien-Anfrage: '.($this->projectTitle ?: $this->projectSlug); $service->handle($payload, $subject, 'immobilien-contact-form'); $this->success = true; $this->interest = ''; $this->firstName = ''; $this->lastName = ''; $this->email = ''; $this->phone = ''; $this->message = ''; $this->privacy = false; $this->website = ''; $this->formLoadedAt = time(); } public function render(): \Illuminate\View\View { return view('livewire.web.components.sections.immobilien-contact-form'); } }