withPageTitle(Setting::get('app_name')) ->withAboutApp(Markdown::convertToHtml(Setting::get('app_about'))); } /** * Handle the subscribe user. * * @return \Illuminate\View\View */ public function postSubscribe() { try { $this->dispatch(new SubscribeSubscriberCommand(Binput::get('email'))); } catch (ValidationException $e) { return Redirect::route('subscribe.subscribe') ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure'))) ->withErrors($e->getMessageBag()); } return Redirect::route('status-page') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.subscribed'))); } /** * Handle the verify subscriber email. * * @param string|null $code * * @return \Illuminate\View\View */ public function getVerify($code = null) { if (is_null($code)) { throw new NotFoundHttpException(); } $subscriber = Subscriber::where('verify_code', '=', $code)->first(); if (!$subscriber || $subscriber->verified()) { throw new BadRequestHttpException(); } $this->dispatch(new VerifySubscriberCommand($subscriber)); return Redirect::route('status-page') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.verified'))); } /** * Handle the unsubscribe. * * @param string|null $code * * @return \Illuminate\View\View */ public function getUnsubscribe($code = null) { if (is_null($code)) { throw new NotFoundHttpException(); } $subscriber = Subscriber::where('verify_code', '=', $code)->first(); if (!$subscriber || !$subscriber->verified()) { throw new BadRequestHttpException(); } $this->dispatch(new UnsubscribeSubscriberCommand($subscriber)); return Redirect::route('status-page') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.unsuscribed'))); } }