b2in/app/Livewire/Web/Components/UI/ContactForm.php
2025-10-20 17:50:35 +02:00

65 lines
1.8 KiB
PHP

<?php
namespace App\Livewire\Web\Components\Ui;
use Livewire\Component;
class ContactForm extends Component
{
public $firstName = '';
public $lastName = '';
public $company = '';
public $email = '';
public $phone = '';
public $subject = '';
public $message = '';
public $content = [];
public function mount()
{
$theme = config('app.theme', 'b2in');
$this->content = config("content.themes.{$theme}.contact_form", []);
}
public function getSubjectsProperty()
{
return $this->content['form']['subjects'] ?? [];
}
public function getContactInfoProperty()
{
return $this->content['contact_info'] ?? [];
}
public function getSocialMediaProperty()
{
return $this->content['social_media']['platforms'] ?? [];
}
public function submit()
{
$this->validate([
'firstName' => 'required|string|max:255',
'lastName' => 'required|string|max:255',
'email' => 'required|email|max:255',
'subject' => 'required|string',
'message' => 'required|string|max:2000',
'company' => 'nullable|string|max:255',
'phone' => 'nullable|string|max:255',
]);
// Here you would typically save to database or send email
// For now, we'll just show a success message
$successMessage = $this->content['form']['success_message'] ?? 'Vielen Dank für Ihre Nachricht! Wir werden uns schnellstmöglich bei Ihnen melden.';
session()->flash('message', $successMessage);
$this->reset(['firstName', 'lastName', 'company', 'email', 'phone', 'subject', 'message']);
}
public function render()
{
return view('livewire.web.components.ui.contact-form');
}
}