withAboutApp(Markdown::convertToHtml(Setting::get('app_about'))); } /** * Handle the subscribe user. * * @return \Illuminate\View\View */ public function postSubscribe() { $email = Binput::get('email'); try { dispatch(new SubscribeSubscriberCommand($email)); } catch (AlreadySubscribedException $e) { return Redirect::route('subscribe.subscribe') ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure'))) ->withErrors(trans('cachet.subscriber.email.already-subscribed', ['email' => $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 ($code === null) { throw new NotFoundHttpException(); } $subscriber = Subscriber::where('verify_code', '=', $code)->first(); if (!$subscriber || $subscriber->is_verified) { throw new BadRequestHttpException(); } 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 ($code === null) { throw new NotFoundHttpException(); } $subscriber = Subscriber::where('verify_code', '=', $code)->first(); if (!$subscriber || !$subscriber->is_verified) { throw new BadRequestHttpException(); } dispatch(new UnsubscribeSubscriberCommand($subscriber)); return Redirect::route('status-page') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.unsubscribed'))); } }