FleetCart/Modules/Newsletter/Http/Controllers/SubscriberController.php
2023-12-03 14:07:47 +00:00

27 lines
641 B
PHP

<?php
namespace Modules\Newsletter\Http\Controllers;
use Newsletter;
use Illuminate\Http\Response;
use Modules\Newsletter\Http\Requests\StoreSubscriberRequest;
class SubscriberController
{
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(StoreSubscriberRequest $request)
{
Newsletter::subscribeOrUpdate($request->email);
if (!Newsletter::lastActionSucceeded()) {
return response()->json([
'message' => str_after(Newsletter::getLastError(), '400: '),
], 403);
}
}
}