/** * Handle the subscribe user. * * @return \Illuminate\View\View */ public function postSubscribe() { try { $subscriber = Subscriber::create(['email' => Binput::get('email')]); } catch (ValidationException $e) { return Redirect::route('subscribe.subscribe')->withInput(Binput::all())->withTitle(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))->withErrors($e->getMessageBag()); } event(new CustomerHasSubscribedEvent($subscriber)); return Redirect::route('status-page')->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.subscribed'))); }
/** * Handle the subscribe user. * * @return \Illuminate\View\View */ public function postSubscribe() { $subscriber = Subscriber::create(['email' => Binput::get('email')]); if (!$subscriber->isValid()) { return Redirect::back()->withInput(Binput::all())->with('title', sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))->with('errors', $subscriber->getErrors()); } $successMsg = sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.subscribed')); event(new CustomerHasSubscribedEvent($subscriber)); return Redirect::route('status-page')->with('success', $successMsg); }
/** * Handle the subscribe subscriber command. * * @param \CachetHQ\Cachet\Commands\Subscriber\SubscribeSubscriberCommand $command * * @return \CachetHQ\Cachet\Models\Subscriber */ public function handle(SubscribeSubscriberCommand $command) { $subscriber = Subscriber::create(['email' => $command->email]); if ($command->verified) { $this->dispatch(new VerifySubscriberCommand($subscriber)); } else { event(new SubscriberHasSubscribedEvent($subscriber)); } return $subscriber; }
/** * Creates a new subscriber. * * @return \Illuminate\Http\RedirectResponse */ public function createSubscriberAction() { $email = Binput::get('email'); try { $subscriber = Subscriber::create(['email' => $email]); } catch (ValidationException $e) { return Redirect::route('dashboard.subscribers.add')->withInput(Binput::all())->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.subscribers.add.failure')))->withErrors($e->getMessageBag()); } event(new CustomerHasSubscribedEvent($subscriber)); return Redirect::route('dashboard.subscribers.add')->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.subscribers.add.success'))); }
/** * Creates a new subscriber. * * @return \Illuminate\Http\RedirectResponse */ public function createSubscriberAction() { $email = Binput::get('email'); $subscriber = Subscriber::create(['email' => $email]); if (!$subscriber->isValid()) { return Redirect::back()->withInput(Binput::all())->with('title', sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.subscribers.add.failure')))->with('errors', $subscriber->getErrors()); } $successMsg = sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.subscribers.add.success')); event(new CustomerHasSubscribedEvent($subscriber)); return Redirect::back()->with('success', $successMsg); }
/** * Handle the subscribe subscriber command. * * @param \CachetHQ\Cachet\Commands\Subscriber\SubscribeSubscriberCommand $command * * @throws \CachetHQ\Cachet\Exceptions\AlreadySubscribedException * * @return \CachetHQ\Cachet\Models\Subscriber */ public function handle(SubscribeSubscriberCommand $command) { if (Subscriber::where('email', $command->email)->first()) { throw new AlreadySubscribedException("Cannot subscribe {$command->email} because they're already subscribed."); } $subscriber = Subscriber::create(['email' => $command->email]); if ($command->verified) { $this->dispatch(new VerifySubscriberCommand($subscriber)); } else { event(new SubscriberHasSubscribedEvent($subscriber)); } return $subscriber; }
/** * Create a new subscriber. * * @return \Illuminate\Http\JsonResponse */ public function postSubscribers() { $subscriberData = Binput::except('verify'); try { $subscriber = Subscriber::create($subscriberData); } catch (Exception $e) { throw new BadRequestHttpException(); } // If we're auto-verifying the subscriber, don't bother with this event. if (!Binput::get('verify')) { event(new CustomerHasSubscribedEvent($subscriber)); } return $this->item($subscriber); }