<?php

namespace App\Http\Controllers\Web;

use App\Services\Response\ResponseService;
use Illuminate\Http\JsonResponse;
use App\Http\Controllers\Controller;
use Modules\Newsletter\Requests\Web\NewsletterRequest;
use Modules\Newsletter\Services\NewsletterService;


class NewsletterController extends Controller
{
    private NewsletterService $newsletterService ;
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct(
        NewsletterService $newsletterService,
    )
    {
        $this->newsletterService = $newsletterService;
    }

    public function store(NewsletterRequest $request) :JsonResponse
    {
        $this->newsletterService->save($request,null);
        $response = [
            'status'=>200,
            'message'=>__('web.success'),
            'data'=> url()->previous(),
        ];
        return ResponseService::response($response);
    }

}
