Esempio n. 1
0
 public function subscribe(SubscribeRequest $request, Newsletter $newsletter)
 {
     try {
         $newsletter->subscribe($request->get('subscriber_email'));
         alert()->success('Gracias por suscribirte. Cada semana recibirás los productos más molones en tu email.', 'Sí, sí, sí!')->persistent('Cerrar');
     } catch (AlreadySubscribed $exception) {
         alert()->warning('Tu email ya se encontraba en nuestra base de datos. ¡Te gradecemos el interés!', '¡Oops!')->persistent('Cerrar');
     }
     return redirect()->back();
 }
 public function subscribe($address)
 {
     $email = $address;
     $success = true;
     $message = '';
     try {
         $result = $this->newsletter->subscribe($address);
         $email = $result['email'];
         $message = 'Thank you!';
     } catch (AlreadySubscribed $alreadySubscibed) {
         $success = false;
         $message = 'You are already subscribed';
     } catch (\Exception $e) {
         $success = false;
         $message = 'Ooops! An error occurred';
         Log::info($e->getMessage());
     } finally {
         return ['email' => $email, 'success' => $success, 'message' => $message];
     }
 }