Skip to content

Commit

Permalink
Created the newsletter livewire component
Browse files Browse the repository at this point in the history
  • Loading branch information
Raccoon254 committed Jun 16, 2024
1 parent 8fe114b commit f98fe82
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 10 deletions.
11 changes: 11 additions & 0 deletions app/Http/Controllers/PagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
14 changes: 14 additions & 0 deletions app/Livewire/Newsletter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace App\Livewire;

use Illuminate\View\View;
use Livewire\Component;

class Newsletter extends Component
{
public function render(): View
{
return view('livewire.newsletter');
}
}
13 changes: 13 additions & 0 deletions resources/views/livewire/newsletter.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class="center bg-blue-500 p-4 md:p-14">
<form class="w-full max-w-md flex flex-col gap-4 center bg-blue-500 items-center" wire:submit.prevent="subscribe">
@csrf
<x-text-input type="email" name="email" autocomplete="email" placeholder="Your email address" required />
@error('email')
<p class="text-xs text-red-500">{{ $message }}</p>
@enderror
<button class="py-2 text-blue-500 font-semibold w-full bg-white px-4 rounded-md ring" type="submit">
Subscribe
<i class="fas fa-paper-plane"></i>
</button>
</form>
</div>
11 changes: 1 addition & 10 deletions resources/views/static/coming-soon.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,5 @@
<p class="mb-4">If you want to be the first to know when these features are live, sign up for our newsletter:</p>

</div>
<div class="center bg-blue-500 p-4 md:p-14">
<form class="w-full max-w-md flex flex-col gap-4 center bg-blue-500 items-center" action="" method="POST">
@csrf
<x-text-input type="email" name="email" placeholder="Your email address" required />
<button class="py-2 text-blue-500 font-semibold w-full bg-white px-4 rounded-md ring" type="submit">
Subscribe
<i class="fas fa-paper-plane"></i>
</button>
</form>
</div>
<livewire:newsletter/>
</x-logged-out>
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

0 comments on commit f98fe82

Please sign in to comment.