From 05f93e16e875ca17eca1fefb1842f84e3ee1f787 Mon Sep 17 00:00:00 2001 From: Davide Bellini Date: Thu, 13 Oct 2016 09:51:44 +0200 Subject: [PATCH] =?UTF-8?q?Fixed=20redirects=20with=20=E2=80=9Ccachet=5Fre?= =?UTF-8?q?direct=E2=80=9D=20helper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/AuthController.php | 8 +++---- .../Dashboard/ComponentController.php | 20 ++++++++-------- .../Dashboard/DashboardController.php | 2 +- .../Dashboard/IncidentController.php | 24 +++++++++---------- .../Dashboard/MetricController.php | 10 ++++---- .../Dashboard/ScheduleController.php | 12 +++++----- .../Dashboard/SubscriberController.php | 6 ++--- .../Controllers/Dashboard/TeamController.php | 14 +++++------ .../Controllers/Dashboard/UserController.php | 6 ++--- app/Http/Controllers/SetupController.php | 4 ++-- app/Http/Controllers/SignupController.php | 4 ++-- app/Http/Controllers/SubscribeController.php | 14 +++++------ app/helpers.php | 21 ++++++++++++++++ 13 files changed, 83 insertions(+), 62 deletions(-) diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 691daba7..ef17d71c 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -58,7 +58,7 @@ class AuthController extends Controller if (Auth::user()->hasTwoFactor) { Session::put('2fa_id', Auth::user()->id); - return cachet_route('auth.two-factor'); + return cachet_redirect('auth.two-factor'); } Auth::attempt($loginData, $rememberUser); @@ -68,7 +68,7 @@ class AuthController extends Controller return Redirect::intended(cachet_route('dashboard')); } - return cachet_route('auth.login') + return cachet_redirect('auth.login') ->withInput(Binput::except('password')) ->withError(trans('forms.login.invalid')); } @@ -113,11 +113,11 @@ class AuthController extends Controller // Failed login, log back out. Auth::logout(); - return cachet_route('auth.login')->withError(trans('forms.login.invalid-token')); + return cachet_redirect('auth.login')->withError(trans('forms.login.invalid-token')); } } - return cachet_route('auth.login')->withError(trans('forms.login.invalid-token')); + return cachet_redirect('auth.login')->withError(trans('forms.login.invalid-token')); } /** diff --git a/app/Http/Controllers/Dashboard/ComponentController.php b/app/Http/Controllers/Dashboard/ComponentController.php index 03af1ed2..c8bc20fd 100644 --- a/app/Http/Controllers/Dashboard/ComponentController.php +++ b/app/Http/Controllers/Dashboard/ComponentController.php @@ -137,7 +137,7 @@ class ComponentController extends Controller $componentData['enabled'] )); } catch (ValidationException $e) { - return cachet_route('dashboard.components.edit', [$component->id]) + return cachet_redirect('dashboard.components.edit', [$component->id]) ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.edit.failure'))) ->withErrors($e->getMessageBag()); @@ -153,7 +153,7 @@ class ComponentController extends Controller $component->tags()->sync($componentTags); - return cachet_route('dashboard.components.edit', [$component->id]) + return cachet_redirect('dashboard.components.edit', [$component->id]) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.edit.success'))); } @@ -190,7 +190,7 @@ class ComponentController extends Controller $componentData['enabled'] )); } catch (ValidationException $e) { - return cachet_route('dashboard.components.create') + return cachet_redirect('dashboard.components.create') ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.add.failure'))) ->withErrors($e->getMessageBag()); @@ -206,7 +206,7 @@ class ComponentController extends Controller $component->tags()->sync($componentTags); - return cachet_route('dashboard.components') + return cachet_redirect('dashboard.components') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.add.success'))); } @@ -221,7 +221,7 @@ class ComponentController extends Controller { dispatch(new RemoveComponentCommand($component)); - return cachet_route('dashboard.components') + return cachet_redirect('dashboard.components') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.delete.success'))); } @@ -236,7 +236,7 @@ class ComponentController extends Controller { dispatch(new RemoveComponentGroupCommand($group)); - return cachet_route('dashboard.components.groups') + return cachet_redirect('dashboard.components.groups') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.delete.success'))); } @@ -280,13 +280,13 @@ class ComponentController extends Controller Binput::get('visible') )); } catch (ValidationException $e) { - return cachet_route('dashboard.components.groups.create') + return cachet_redirect('dashboard.components.groups.create') ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.groups.add.failure'))) ->withErrors($e->getMessageBag()); } - return cachet_route('dashboard.components.groups') + return cachet_redirect('dashboard.components.groups') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.groups.add.success'))); } @@ -308,13 +308,13 @@ class ComponentController extends Controller Binput::get('visible') )); } catch (ValidationException $e) { - return cachet_route('dashboard.components.groups.edit', [$group->id]) + return cachet_redirect('dashboard.components.groups.edit', [$group->id]) ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.groups.edit.failure'))) ->withErrors($e->getMessageBag()); } - return cachet_route('dashboard.components.groups.edit', [$group->id]) + return cachet_redirect('dashboard.components.groups.edit', [$group->id]) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.groups.edit.success'))); } } diff --git a/app/Http/Controllers/Dashboard/DashboardController.php b/app/Http/Controllers/Dashboard/DashboardController.php index d1e84d0d..a0ee0df6 100644 --- a/app/Http/Controllers/Dashboard/DashboardController.php +++ b/app/Http/Controllers/Dashboard/DashboardController.php @@ -82,7 +82,7 @@ class DashboardController extends Controller */ public function redirectAdmin() { - return cachet_route('dashboard'); + return cachet_redirect('dashboard'); } /** diff --git a/app/Http/Controllers/Dashboard/IncidentController.php b/app/Http/Controllers/Dashboard/IncidentController.php index 5b42ed00..9a0091ce 100644 --- a/app/Http/Controllers/Dashboard/IncidentController.php +++ b/app/Http/Controllers/Dashboard/IncidentController.php @@ -138,13 +138,13 @@ class IncidentController extends Controller null )); } catch (ValidationException $e) { - return cachet_route('dashboard.incidents.create') + return cachet_redirect('dashboard.incidents.create') ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.add.failure'))) ->withErrors($e->getMessageBag()); } - return cachet_route('dashboard.incidents') + return cachet_redirect('dashboard.incidents') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.add.success'))); } @@ -184,7 +184,7 @@ class IncidentController extends Controller { $template->delete(); - return cachet_route('dashboard.templates') + return cachet_redirect('dashboard.templates') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.templates.delete.success'))); } @@ -198,13 +198,13 @@ class IncidentController extends Controller try { IncidentTemplate::create(Binput::get('template')); } catch (ValidationException $e) { - return cachet_route('dashboard.templates.create') + return cachet_redirect('dashboard.templates.create') ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.add.failure'))) ->withErrors($e->getMessageBag()); } - return cachet_route('dashboard.templates') + return cachet_redirect('dashboard.templates') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.templates.add.success'))); } @@ -219,7 +219,7 @@ class IncidentController extends Controller { dispatch(new RemoveIncidentCommand($incident)); - return cachet_route('dashboard.incidents') + return cachet_redirect('dashboard.incidents') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.delete.success'))); } @@ -264,7 +264,7 @@ class IncidentController extends Controller null )); } catch (ValidationException $e) { - return cachet_route('dashboard.incidents.edit', ['id' => $incident->id]) + return cachet_redirect('dashboard.incidents.edit', ['id' => $incident->id]) ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure'))) ->withErrors($e->getMessageBag()); @@ -274,7 +274,7 @@ class IncidentController extends Controller $incident->component->update(['status' => Binput::get('component_status')]); } - return cachet_route('dashboard.incidents.edit', ['id' => $incident->id]) + return cachet_redirect('dashboard.incidents.edit', ['id' => $incident->id]) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.edit.success'))); } @@ -290,12 +290,12 @@ class IncidentController extends Controller try { $template->update(Binput::get('template')); } catch (ValidationException $e) { - return cachet_route('dashboard.templates.edit', ['id' => $template->id]) + return cachet_redirect('dashboard.templates.edit', ['id' => $template->id]) ->withUpdatedTemplate($template) ->withTemplateErrors($e->getMessageBag()->getErrors()); } - return cachet_route('dashboard.templates.edit', ['id' => $template->id]) + return cachet_redirect('dashboard.templates.edit', ['id' => $template->id]) ->withUpdatedTemplate($template); } @@ -328,13 +328,13 @@ class IncidentController extends Controller $this->auth->user() )); } catch (ValidationException $e) { - return cachet_route('dashboard.incidents.update', ['id' => $incident->id]) + return cachet_redirect('dashboard.incidents.update', ['id' => $incident->id]) ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure'))) ->withErrors($e->getMessageBag()); } - return cachet_route('dashboard.incidents') + return cachet_redirect('dashboard.incidents') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.delete.success'))); } } diff --git a/app/Http/Controllers/Dashboard/MetricController.php b/app/Http/Controllers/Dashboard/MetricController.php index 13324bd2..a451ed44 100644 --- a/app/Http/Controllers/Dashboard/MetricController.php +++ b/app/Http/Controllers/Dashboard/MetricController.php @@ -82,13 +82,13 @@ class MetricController extends Controller $metricData['threshold'] )); } catch (ValidationException $e) { - return cachet_route('dashboard.metrics.create') + return cachet_redirect('dashboard.metrics.create') ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.metrics.add.failure'))) ->withErrors($e->getMessageBag()); } - return cachet_route('dashboard.metrics') + return cachet_redirect('dashboard.metrics') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.add.success'))); } @@ -114,7 +114,7 @@ class MetricController extends Controller { dispatch(new RemoveMetricCommand($metric)); - return cachet_route('dashboard.metrics') + return cachet_redirect('dashboard.metrics') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.delete.success'))); } @@ -155,13 +155,13 @@ class MetricController extends Controller Binput::get('threshold', null, false) )); } catch (ValidationException $e) { - return cachet_route('dashboard.metrics.edit', [$metric->id]) + return cachet_redirect('dashboard.metrics.edit', [$metric->id]) ->withInput(Binput::all()) ->withTitle(sprintf('%s', trans('dashboard.notifications.whoops'))) ->withErrors($e->getMessageBag()); } - return cachet_route('dashboard.metrics.edit', [$metric->id]) + return cachet_redirect('dashboard.metrics.edit', [$metric->id]) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.edit.success'))); } } diff --git a/app/Http/Controllers/Dashboard/ScheduleController.php b/app/Http/Controllers/Dashboard/ScheduleController.php index 6f24a3c0..d65bca16 100644 --- a/app/Http/Controllers/Dashboard/ScheduleController.php +++ b/app/Http/Controllers/Dashboard/ScheduleController.php @@ -100,13 +100,13 @@ class ScheduleController extends Controller Binput::get('scheduled_at') )); } catch (ValidationException $e) { - return cachet_route('dashboard.schedule.create') + return cachet_redirect('dashboard.schedule.create') ->withInput(Binput::all()) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.add.failure'))) ->withErrors($e->getMessageBag()); } - return cachet_route('dashboard.schedule') + return cachet_redirect('dashboard.schedule') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.add.success'))); } @@ -145,7 +145,7 @@ class ScheduleController extends Controller $messageBag = new MessageBag(); $messageBag->add('scheduled_at', trans('validation.date', ['attribute' => 'scheduled time you supplied'])); - return cachet_route('dashboard.schedule.edit', [$schedule->id])->withErrors($messageBag); + return cachet_redirect('dashboard.schedule.edit', [$schedule->id])->withErrors($messageBag); } $scheduleData['scheduled_at'] = $scheduledAt; @@ -155,13 +155,13 @@ class ScheduleController extends Controller try { $schedule->update($scheduleData); } catch (ValidationException $e) { - return cachet_route('dashboard.schedule.edit', [$schedule->id]) + return cachet_redirect('dashboard.schedule.edit', [$schedule->id]) ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.edit.failure'))) ->withErrors($e->getMessageBag()); } - return cachet_route('dashboard.schedule.edit', [$schedule->id]) + return cachet_redirect('dashboard.schedule.edit', [$schedule->id]) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.edit.success'))); } @@ -176,7 +176,7 @@ class ScheduleController extends Controller { $schedule->delete(); - return cachet_route('dashboard.schedule') + return cachet_redirect('dashboard.schedule') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.delete.success'))); } } diff --git a/app/Http/Controllers/Dashboard/SubscriberController.php b/app/Http/Controllers/Dashboard/SubscriberController.php index 5ab4438d..e9749996 100644 --- a/app/Http/Controllers/Dashboard/SubscriberController.php +++ b/app/Http/Controllers/Dashboard/SubscriberController.php @@ -61,13 +61,13 @@ class SubscriberController extends Controller dispatch(new SubscribeSubscriberCommand($subscriber, $verified)); } } catch (ValidationException $e) { - return cachet_route('dashboard.subscribers.create') + return cachet_redirect('dashboard.subscribers.create') ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.subscribers.add.failure'))) ->withErrors($e->getMessageBag()); } - return cachet_route('dashboard.subscribers.create') + return cachet_redirect('dashboard.subscribers.create') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.subscribers.add.success'))); } @@ -84,6 +84,6 @@ class SubscriberController extends Controller { dispatch(new UnsubscribeSubscriberCommand($subscriber)); - return cachet_route('dashboard.subscribers'); + return cachet_redirect('dashboard.subscribers'); } } diff --git a/app/Http/Controllers/Dashboard/TeamController.php b/app/Http/Controllers/Dashboard/TeamController.php index b3c925a8..152f0971 100644 --- a/app/Http/Controllers/Dashboard/TeamController.php +++ b/app/Http/Controllers/Dashboard/TeamController.php @@ -87,13 +87,13 @@ class TeamController extends Controller Binput::get('level') )); } catch (ValidationException $e) { - return cachet_route('dashboard.team.create') + return cachet_redirect('dashboard.team.create') ->withInput(Binput::except('password')) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.add.failure'))) ->withErrors($e->getMessageBag()); } - return cachet_route('dashboard.team.create') + return cachet_redirect('dashboard.team.create') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.add.success'))); } @@ -111,13 +111,13 @@ class TeamController extends Controller try { $user->update($userData); } catch (ValidationException $e) { - return cachet_route('dashboard.team.edit', [$user->id]) + return cachet_redirect('dashboard.team.edit', [$user->id]) ->withInput($userData) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure'))) ->withErrors($e->getMessageBag()); } - return cachet_route('dashboard.team.edit', [$user->id]) + return cachet_redirect('dashboard.team.edit', [$user->id]) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.edit.success'))); } @@ -133,13 +133,13 @@ class TeamController extends Controller array_unique(array_filter((array) Binput::get('emails'))) )); } catch (ValidationException $e) { - return cachet_route('dashboard.team.invite') + return cachet_redirect('dashboard.team.invite') ->withInput(Binput::except('password')) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.invite.failure'))) ->withErrors($e->getMessageBag()); } - return cachet_route('dashboard.team.invite') + return cachet_redirect('dashboard.team.invite') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.invite.success'))); } @@ -154,7 +154,7 @@ class TeamController extends Controller { dispatch(new RemoveUserCommand($user)); - return cachet_route('dashboard.team') + return cachet_redirect('dashboard.team') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.delete.success'))); } } diff --git a/app/Http/Controllers/Dashboard/UserController.php b/app/Http/Controllers/Dashboard/UserController.php index a04b4928..f9112b1e 100644 --- a/app/Http/Controllers/Dashboard/UserController.php +++ b/app/Http/Controllers/Dashboard/UserController.php @@ -58,13 +58,13 @@ class UserController extends Controller try { Auth::user()->update($userData); } catch (ValidationException $e) { - return cachet_route('dashboard.user') + return cachet_redirect('dashboard.user') ->withInput($userData) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure'))) ->withErrors($e->getMessageBag()); } - return cachet_route('dashboard.user') + return cachet_redirect('dashboard.user') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.edit.success'))); } @@ -82,6 +82,6 @@ class UserController extends Controller event(new UserRegeneratedApiTokenEvent($user)); - return cachet_route('dashboard.user'); + return cachet_redirect('dashboard.user'); } } diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php index af02c861..f1a4cdcd 100644 --- a/app/Http/Controllers/SetupController.php +++ b/app/Http/Controllers/SetupController.php @@ -267,14 +267,14 @@ class SetupController extends Controller return Response::json(['status' => 1]); } - return cachet_route('dashboard'); + return cachet_redirect('dashboard'); } if (Request::ajax()) { return Response::json(['errors' => $v->getMessageBag()], 400); } - return cachet_route('setup')->withInput()->withErrors($v->getMessageBag()); + return cachet_redirect('setup')->withInput()->withErrors($v->getMessageBag()); } /** diff --git a/app/Http/Controllers/SignupController.php b/app/Http/Controllers/SignupController.php index a36af25f..a506c59f 100644 --- a/app/Http/Controllers/SignupController.php +++ b/app/Http/Controllers/SignupController.php @@ -76,7 +76,7 @@ class SignupController extends Controller User::LEVEL_USER )); } catch (ValidationException $e) { - return cachet_route('signup.invite', [$invite->code]) + return cachet_redirect('signup.invite', [$invite->code]) ->withInput(Binput::except('password')) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.signup.failure'))) ->withErrors($e->getMessageBag()); @@ -84,7 +84,7 @@ class SignupController extends Controller dispatch(new ClaimInviteCommand($invite)); - return cachet_route('status-page') + return cachet_redirect('status-page') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.signup.success'))); } } diff --git a/app/Http/Controllers/SubscribeController.php b/app/Http/Controllers/SubscribeController.php index 280eb9af..9498871d 100644 --- a/app/Http/Controllers/SubscribeController.php +++ b/app/Http/Controllers/SubscribeController.php @@ -62,17 +62,17 @@ class SubscribeController extends Controller try { $subscription = dispatch(new SubscribeSubscriberCommand($email, $verified)); } catch (ValidationException $e) { - return cachet_route('status-page') + return cachet_redirect('status-page') ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure'))) ->withErrors($e->getMessageBag()); } if ($subscription->is_verified) { - return cachet_route('status-page')->withSuccess(trans('cachet.subscriber.email.already-subscribed', ['email' => $email])); + return cachet_redirect('status-page')->withSuccess(trans('cachet.subscriber.email.already-subscribed', ['email' => $email])); } - return cachet_route('subscribe.manage', $subscription->verify_code) + return cachet_redirect('subscribe.manage', $subscription->verify_code) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.subscribed'))); } @@ -99,7 +99,7 @@ class SubscribeController extends Controller dispatch(new VerifySubscriberCommand($subscriber)); } - return cachet_route('status-page') + return cachet_redirect('status-page') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.verified'))); } @@ -129,7 +129,7 @@ class SubscribeController extends Controller dispatch(new UnsubscribeSubscriberCommand($subscriber, $subscription)); } - return cachet_route('status-page') + return cachet_redirect('status-page') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.unsubscribed'))); } @@ -184,13 +184,13 @@ class SubscribeController extends Controller try { dispatch(new UpdateSubscriberSubscriptionCommand($subscriber, Binput::get('subscriptions'))); } catch (ValidationException $e) { - return cachet_route('subscribe.manage', $subscriber->verify_code) + return cachet_redirect('subscribe.manage', $subscriber->verify_code) ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure'))) ->withErrors($e->getMessageBag()); } - return cachet_route('subscribe.manage', $subscriber->verify_code) + return cachet_redirect('subscribe.manage', $subscriber->verify_code) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.subscribed'))); } } diff --git a/app/helpers.php b/app/helpers.php index 0d7f4135..dc0fc7ed 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -156,3 +156,24 @@ if (!function_exists('cachet_route')) { return app('url')->route("{$domain}::{$method}:{$name}", $parameters, true); } } + +if (!function_exists('cachet_redirect')) { + /** + * Create a new redirect response to a named route, which resides in a given domain. + * + * @param string $name + * @param array $parameters + * @param int $status + * @param array $headers + * @param string $method + * @param string $domain + * + * @return \Illuminate\Http\RedirectResponse + */ + function cachet_redirect($name, $parameters = [], $status = 302, $headers = [], $method = 'get', $domain = 'core') + { + $url = cachet_route($name, $parameters, $method, $domain); + + return app('redirect')->to($url, $status, $headers); + } +}