<?php

namespace App\Http\Controllers;

use App\Models\NewsSubscriber;
use Illuminate\Http\Request;

class NewsSubscriberController extends Controller
{
    public function store(Request $request){
        // dd($request);
        try {
            //code...
        
        $data = $request->validate([
           'email'=>"email|required|unique:news_subscribers,email"
        ]);
        NewsSubscriber::create($data);
        return back(303)->with(['success' => 'success']);
    } catch (\Throwable $th) {
        return back(303)->with(['error' => $th->getMessage()]);
    }
    }
}
