*/ public array $content = []; public function mount(): void { $this->content = cms_theme_section('contact_form'); $this->formLoadedAt = time(); } /** @return array */ public function getSubjectsProperty(): array { return $this->content['form']['subjects'] ?? []; } /** @return array> */ public function getContactInfoProperty(): array { return $this->content['contact_info'] ?? []; } /** @return array> */ public function getSocialMediaProperty(): array { return $this->content['social_media']['platforms'] ?? []; } public function submit(ContactFormService $service): void { $this->validate([ 'firstName' => ['required', 'string', 'max:255'], 'lastName' => ['required', 'string', 'max:255'], 'email' => ['required', 'email:rfc', 'max:255'], 'subject' => ['required', 'string'], 'message' => ['required', 'string', 'max:2000'], 'company' => ['nullable', 'string', 'max:255'], 'phone' => ['nullable', 'string', 'max:255'], 'privacy' => ['accepted'], 'website' => ['nullable', 'string', 'max:0'], ]); $spamDetector = SpamDetector::fromConfig(); $payload = [ 'first_name' => $this->firstName, 'last_name' => $this->lastName, 'email' => $this->email, 'subject' => $this->subject, 'message' => $this->message, 'company' => $this->company, 'phone' => $this->phone, 'website' => $this->website, 'ip' => request()->ip(), 'user_agent' => request()->userAgent(), 'is_spam' => false, ]; $payload['is_spam'] = $spamDetector->detect($payload, $this->formLoadedAt); $subjectLabel = $this->getSubjectsProperty()[$this->subject] ?? $this->subject; $subjectLine = $subjectLabel ? 'Kontaktanfrage B2in: ' . $subjectLabel : __('contact-form::contact-form.default_subject'); $service->handle($payload, $subjectLine, 'contact-form'); $this->success = true; $this->firstName = ''; $this->lastName = ''; $this->company = ''; $this->email = ''; $this->phone = ''; $this->subject = ''; $this->message = ''; $this->privacy = false; $this->website = ''; $this->formLoadedAt = time(); } public function render(): \Illuminate\View\View { return view('livewire.web.components.ui.contact-form'); } }