feature flags and a bit on the design
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Mail\WaitlistWelcome;
|
||||
use App\Models\WaitlistEntry;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class WaitlistController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('waitlist.index');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'email' => 'required|email|unique:waitlist_entries,email',
|
||||
]);
|
||||
|
||||
try {
|
||||
$entry = WaitlistEntry::create([
|
||||
'email' => $request->email,
|
||||
]);
|
||||
|
||||
// Send welcome email
|
||||
Mail::to($entry->email)->send(new WaitlistWelcome($entry));
|
||||
|
||||
return redirect()->back()->with('success', 'Thank you for joining our waitlist! Check your email for confirmation.');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('error', 'Something went wrong. Please try again.');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user