From f98fe8278476af6193a5046cc1d9f21965017a0e Mon Sep 17 00:00:00 2001 From: raccoon254 Date: Sun, 16 Jun 2024 08:30:51 +0300 Subject: [PATCH] Created the newsletter livewire component --- app/Http/Controllers/PagesController.php | 11 +++++++++++ app/Livewire/Newsletter.php | 14 ++++++++++++++ resources/views/livewire/newsletter.blade.php | 13 +++++++++++++ resources/views/static/coming-soon.blade.php | 11 +---------- routes/web.php | 1 + 5 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 app/Livewire/Newsletter.php create mode 100644 resources/views/livewire/newsletter.blade.php diff --git a/app/Http/Controllers/PagesController.php b/app/Http/Controllers/PagesController.php index 679572f..aa46be0 100644 --- a/app/Http/Controllers/PagesController.php +++ b/app/Http/Controllers/PagesController.php @@ -159,4 +159,15 @@ public function submit(Request $request) // Redirect or return a response return redirect()->back()->with('success', 'Thank you for your message!'); } + + public function subscribe(Request $request) + { + // Validate the form data + $request->validate([ + 'email' => 'required|email|unique:subscribers', + ]); + + // Subscribe the user to the newsletter + dd('Subscribed'); + } } diff --git a/app/Livewire/Newsletter.php b/app/Livewire/Newsletter.php new file mode 100644 index 0000000..e2c9fda --- /dev/null +++ b/app/Livewire/Newsletter.php @@ -0,0 +1,14 @@ + +
+ @csrf + + @error('email') +

{{ $message }}

+ @enderror + + + diff --git a/resources/views/static/coming-soon.blade.php b/resources/views/static/coming-soon.blade.php index c495838..db490f3 100644 --- a/resources/views/static/coming-soon.blade.php +++ b/resources/views/static/coming-soon.blade.php @@ -15,14 +15,5 @@

If you want to be the first to know when these features are live, sign up for our newsletter:

-
-
- @csrf - - - -
+ diff --git a/routes/web.php b/routes/web.php index 3dbfa3f..61f5d87 100644 --- a/routes/web.php +++ b/routes/web.php @@ -58,4 +58,5 @@ Route::get('/info/price-calculator', [PagesController::class, 'info_price_calculator'])->name('info.price-calculator'); Route::view('/info/order/create', 'info.order.create')->name('info.order.create'); Route::view('/info/order/payment', 'info.order.payment')->name('info.order.payment'); +Route::post('/newsletter/subscribe', [PagesController::class, 'subscribe'])->name('newsletter.subscribe'); require __DIR__.'/auth.php';