diff --git a/app/Livewire/Home/ContactUs.php b/app/Livewire/Home/ContactUs.php new file mode 100644 index 0000000..d6b28ea --- /dev/null +++ b/app/Livewire/Home/ContactUs.php @@ -0,0 +1,78 @@ + ['required', 'max:100'], + 'email' => ['required', 'email', 'max:254'], + 'subject' => 'nullable', + 'message' => 'required', + ]; + } + + public function validationAttributes() + { + return [ + 'name' => 'name', + 'email' => 'alamat surel', + 'subject' => 'subyek', + 'message' => 'pesan', + ]; + } + + public function save() + { + $this->validate(); + + // Anti-spam: check if this email has submitted in the last 24 hours + $exists = Contact::where('email', $this->email) + ->where('created_at', '>=', now()->subDay()) + ->exists(); + + if ($exists) { + $this->addError('email', 'Maaf, Anda hanya dapat mengirim pesan sekali dalam 24 jam.'); + + return; + } + + Contact::create([ + 'name' => $this->name, + 'email' => $this->email, + 'subject' => $this->subject, + 'message' => $this->message, + ]); + + $this->reset(['name', 'email', 'subject', 'message']); + + session()->flash('success', 'Pesan Anda telah terkirim!'); + } + + public function render(GeneralSettings $settings) + { + return view('livewire.home.contact-us', [ + 'settings' => $settings, + ]); + } +} diff --git a/public/css/home/style.css b/public/css/home/style.css index 66a0657..bc92a4c 100644 --- a/public/css/home/style.css +++ b/public/css/home/style.css @@ -2607,10 +2607,10 @@ .magic-round-cursor #ball-cursor:after { display: none; } /* Anime animation */ -[data-anime] { +/* [data-anime] { opacity: 0; transition: none; -} +} */ [data-anime].appear { opacity: 1; } diff --git a/resources/views/components/layouts/app.blade.php b/resources/views/components/layouts/app.blade.php index bff10d8..b8a030c 100644 --- a/resources/views/components/layouts/app.blade.php +++ b/resources/views/components/layouts/app.blade.php @@ -2,7 +2,7 @@
-{{ $general->address }}
@endif +Kami di sini untuk membantu dan menjawab pertanyaan apa pun yang Anda + miliki.
+Hubungi langsung?
+ {{ $settings->site_phone }} +Butuh bantuan?
+ {{ $settings->site_email }} +Kunjungi kami?
+ @if ($settings->address) + {{ $settings->address }} + @endif +