/**
  * @param \App\Http\Requests\Front\NewsletterSubscriptionRequest $request
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function subscribe(NewsletterSubscriptionRequest $request)
 {
     $email = strtolower($request->get('email'));
     if (Newsletter::hasMember($email)) {
         return $this->respond(['message' => fragment('newsletter.subscription.result.alreadySubscribed'), 'type' => 'info']);
     }
     $result = Newsletter::subscribe($email);
     if (!$result) {
         return $this->respondWithBadRequest(['message' => fragment('newsletter.subscription.result.error'), 'type' => 'error']);
     }
     activity()->log("{$email} schreef zich in op de nieuwsbrief");
     return $this->respond(['message' => fragment('newsletter.subscription.result.ok'), 'type' => 'success']);
 }
 /**
  * @param \App\Http\Requests\Front\NewsletterSubscriptionRequest $request
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function subscribe(NewsletterSubscriptionRequest $request)
 {
     try {
         $this->newsletter->subscribe($request->get('email'));
         Activity::log($request->get('email') . ' schreef zich in op de nieuwsbrief.');
     } catch (AlreadySubscribed $exception) {
         return $this->respond(['message' => fragment('newsletter.subscription.result.alreadySubscribed'), 'type' => 'info']);
     } catch (ServiceRefusedSubscription $exception) {
         return $this->respondWithBadRequest(['message' => fragment('newsletter.subscription.result.error'), 'type' => 'error']);
     } catch (Exception $e) {
         Log::error('newsletter subscription failed with exception message: ' . $e->getMessage());
         return $this->respondWithInternalServerError(['message' => fragment('newsletter.subscription.result.error'), 'type' => 'error']);
     }
     return $this->respond(['message' => fragment('newsletter.subscription.result.ok'), 'type' => 'success']);
 }