Skip to content

Commit

Permalink
Completely refactor all routes
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrooksuk committed Oct 12, 2016
1 parent 446e428 commit 5a9f613
Show file tree
Hide file tree
Showing 90 changed files with 486 additions and 341 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function notify(Component $component, Subscriber $subscriber)
];

$mail['email'] = $subscriber->email;
$mail['manage_link'] = route('subscribe.manage', ['code' => $subscriber->verify_code]);
$mail['manage_link'] = cachet_route('subscribe.manage', [$subscriber->verify_code]);

$this->mailer->queue([
'html' => 'emails.components.update-html',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ public function notify(IncidentWasReportedEvent $event, $subscriber)
'html_content' => $incident->formattedMessage,
'text_content' => $incident->message,
'token' => $subscriber->token,
'manage_link' => route('subscribe.manage', ['code' => $subscriber->verify_code]),
'unsubscribe_link' => route('subscribe.unsubscribe', ['code' => $subscriber->verify_code]),
'manage_link' => cachet_route('subscribe.manage', [$subscriber->verify_code]),
'unsubscribe_link' => cachet_route('subscribe.unsubscribe', [$subscriber->verify_code]),
];

$this->mailer->queue([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ public function notify(MaintenanceWasScheduledEvent $event, $subscriber)
'html_content' => $incident->formattedMessage,
'text_content' => $incident->message,
'token' => $subscriber->token,
'manage_link' => route('subscribe.manage', ['code' => $subscriber->verify_code]),
'unsubscribe_link' => route('subscribe.unsubscribe', ['code' => $subscriber->verify_code]),
'manage_link' => cachet_route('subscribe.manage', [$subscriber->verify_code]),
'unsubscribe_link' => cachet_route('subscribe.unsubscribe', [$subscriber->verify_code]),
];

$this->mailer->queue([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function handle(UserWasInvitedEvent $event)
$mail = [
'email' => $event->invite->email,
'subject' => 'You have been invited.',
'link' => route('signup.invite', ['code' => $event->invite->code]),
'link' => cachet_route('signup.invite', [$event->invite->code]),
];

$this->mailer->queue([
Expand Down
9 changes: 8 additions & 1 deletion app/Foundation/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Routing\Router;

/**
* This is the route service provider.
*
* @author James Brooks <james@alt-three.com>
* @author Joseph Cohen <joe@alt-three.com>
* @author Graham Campbell <graham@alt-three.com>
*/
class RouteServiceProvider extends ServiceProvider
{
/**
Expand Down Expand Up @@ -67,7 +74,7 @@ protected function registerBindings()
*/
public function map(Router $router)
{
$router->group(['namespace' => $this->namespace], function (Router $router) {
$router->group(['namespace' => $this->namespace, 'as' => 'core::'], function (Router $router) {
$path = app_path('Http/Routes');

foreach (glob("{$path}/*{,/*}.php", GLOB_BRACE) as $file) {
Expand Down
10 changes: 5 additions & 5 deletions app/Http/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ public function postLogin()
if (Auth::user()->hasTwoFactor) {
Session::put('2fa_id', Auth::user()->id);

return Redirect::route('auth.two-factor');
return cachet_route('auth.two-factor');
}

Auth::attempt($loginData, $rememberUser);

event(new UserLoggedInEvent(Auth::user()));

return Redirect::intended('dashboard');
return Redirect::intended(cachet_route('dashboard'));
}

return Redirect::route('auth.login')
return cachet_route('auth.login')
->withInput(Binput::except('password'))
->withError(trans('forms.login.invalid'));
}
Expand Down Expand Up @@ -113,11 +113,11 @@ public function postTwoFactor()
// Failed login, log back out.
Auth::logout();

return Redirect::route('auth.login')->withError(trans('forms.login.invalid-token'));
return cachet_route('auth.login')->withError(trans('forms.login.invalid-token'));
}
}

return Redirect::route('auth.login')->withError(trans('forms.login.invalid-token'));
return cachet_route('auth.login')->withError(trans('forms.login.invalid-token'));
}

/**
Expand Down
25 changes: 12 additions & 13 deletions app/Http/Controllers/Dashboard/ComponentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use CachetHQ\Cachet\Models\Tag;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;

class ComponentController extends Controller
Expand All @@ -45,13 +44,13 @@ public function __construct()
$this->subMenu = [
'components' => [
'title' => trans('dashboard.components.components'),
'url' => route('dashboard.components.index'),
'url' => cachet_route('dashboard.components'),
'icon' => 'ion-ios-browsers',
'active' => false,
],
'groups' => [
'title' => trans_choice('dashboard.components.groups.groups', 2),
'url' => route('dashboard.components.groups'),
'url' => cachet_route('dashboard.components.groups'),
'icon' => 'ion-folder',
'active' => false,
],
Expand Down Expand Up @@ -138,7 +137,7 @@ public function updateComponentAction(Component $component)
$componentData['enabled']
));
} catch (ValidationException $e) {
return Redirect::route('dashboard.components.edit', ['id' => $component->id])
return cachet_route('dashboard.components.edit', [$component->id])
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.edit.failure')))
->withErrors($e->getMessageBag());
Expand All @@ -154,7 +153,7 @@ public function updateComponentAction(Component $component)

$component->tags()->sync($componentTags);

return Redirect::route('dashboard.components.edit', ['id' => $component->id])
return cachet_route('dashboard.components.edit', [$component->id])
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.edit.success')));
}

Expand Down Expand Up @@ -191,7 +190,7 @@ public function createComponentAction()
$componentData['enabled']
));
} catch (ValidationException $e) {
return Redirect::route('dashboard.components.add')
return cachet_route('dashboard.components.create')
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.add.failure')))
->withErrors($e->getMessageBag());
Expand All @@ -207,7 +206,7 @@ public function createComponentAction()

$component->tags()->sync($componentTags);

return Redirect::route('dashboard.components.index')
return cachet_route('dashboard.components')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.add.success')));
}

Expand All @@ -222,7 +221,7 @@ public function deleteComponentAction(Component $component)
{
dispatch(new RemoveComponentCommand($component));

return Redirect::route('dashboard.components.index')
return cachet_route('dashboard.components')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.delete.success')));
}

Expand All @@ -237,7 +236,7 @@ public function deleteComponentGroupAction(ComponentGroup $group)
{
dispatch(new RemoveComponentGroupCommand($group));

return Redirect::route('dashboard.components.groups')
return cachet_route('dashboard.components.groups')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.delete.success')));
}

Expand Down Expand Up @@ -281,13 +280,13 @@ public function postAddComponentGroup()
Binput::get('visible')
));
} catch (ValidationException $e) {
return Redirect::route('dashboard.components.groups.add')
return cachet_route('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 Redirect::route('dashboard.components.groups')
return cachet_route('dashboard.components.groups')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.groups.add.success')));
}

Expand All @@ -309,13 +308,13 @@ public function updateComponentGroupAction(ComponentGroup $group)
Binput::get('visible')
));
} catch (ValidationException $e) {
return Redirect::route('dashboard.components.groups.edit', ['id' => $group->id])
return cachet_route('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 Redirect::route('dashboard.components.groups.edit', ['id' => $group->id])
return cachet_route('dashboard.components.groups.edit', [$group->id])
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.groups.edit.success')));
}
}
3 changes: 1 addition & 2 deletions app/Http/Controllers/Dashboard/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
use Jenssegers\Date\Date;

Expand Down Expand Up @@ -83,7 +82,7 @@ public function __construct(Feed $feed, Guard $guard)
*/
public function redirectAdmin()
{
return Redirect::route('dashboard.index');
return cachet_route('dashboard');
}

/**
Expand Down
29 changes: 14 additions & 15 deletions app/Http/Controllers/Dashboard/IncidentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;

/**
Expand Down Expand Up @@ -61,13 +60,13 @@ public function __construct(Guard $auth)
$this->subMenu = [
'incidents' => [
'title' => trans('dashboard.incidents.incidents'),
'url' => route('dashboard.incidents.index'),
'url' => cachet_route('dashboard.incidents'),
'icon' => 'ion-android-checkmark-circle',
'active' => true,
],
'schedule' => [
'title' => trans('dashboard.schedule.schedule'),
'url' => route('dashboard.schedule.index'),
'url' => cachet_route('dashboard.schedule'),
'icon' => 'ion-android-calendar',
'active' => false,
],
Expand Down Expand Up @@ -139,13 +138,13 @@ public function createIncidentAction()
null
));
} catch (ValidationException $e) {
return Redirect::route('dashboard.incidents.add')
return cachet_route('dashboard.incidents.create')
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.add.failure')))
->withErrors($e->getMessageBag());
}

return Redirect::route('dashboard.incidents.index')
return cachet_route('dashboard.incidents')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.add.success')));
}

Expand Down Expand Up @@ -185,7 +184,7 @@ public function deleteTemplateAction(IncidentTemplate $template)
{
$template->delete();

return Redirect::route('dashboard.templates.index')
return cachet_route('dashboard.templates')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.templates.delete.success')));
}

Expand All @@ -199,13 +198,13 @@ public function createIncidentTemplateAction()
try {
IncidentTemplate::create(Binput::get('template'));
} catch (ValidationException $e) {
return Redirect::route('dashboard.templates.add')
return cachet_route('dashboard.templates.create')
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.add.failure')))
->withErrors($e->getMessageBag());
}

return Redirect::route('dashboard.templates.index')
return cachet_route('dashboard.templates')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.templates.add.success')));
}

Expand All @@ -220,7 +219,7 @@ public function deleteIncidentAction(Incident $incident)
{
dispatch(new RemoveIncidentCommand($incident));

return Redirect::route('dashboard.incidents.index')
return cachet_route('dashboard.incidents')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.delete.success')));
}

Expand Down Expand Up @@ -265,7 +264,7 @@ public function editIncidentAction(Incident $incident)
null
));
} catch (ValidationException $e) {
return Redirect::route('dashboard.incidents.edit', ['id' => $incident->id])
return cachet_route('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());
Expand All @@ -275,7 +274,7 @@ public function editIncidentAction(Incident $incident)
$incident->component->update(['status' => Binput::get('component_status')]);
}

return Redirect::route('dashboard.incidents.edit', ['id' => $incident->id])
return cachet_route('dashboard.incidents.edit', ['id' => $incident->id])
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.edit.success')));
}

Expand All @@ -291,12 +290,12 @@ public function editTemplateAction(IncidentTemplate $template)
try {
$template->update(Binput::get('template'));
} catch (ValidationException $e) {
return Redirect::route('dashboard.templates.edit', ['id' => $template->id])
return cachet_route('dashboard.templates.edit', ['id' => $template->id])
->withUpdatedTemplate($template)
->withTemplateErrors($e->getMessageBag()->getErrors());
}

return Redirect::route('dashboard.templates.edit', ['id' => $template->id])
return cachet_route('dashboard.templates.edit', ['id' => $template->id])
->withUpdatedTemplate($template);
}

Expand Down Expand Up @@ -329,13 +328,13 @@ public function createIncidentUpdateAction(Incident $incident)
$this->auth->user()
));
} catch (ValidationException $e) {
return Redirect::route('dashboard.incidents.update', ['id' => $incident->id])
return cachet_route('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 Redirect::route('dashboard.incidents.index')
return cachet_route('dashboard.incidents')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.delete.success')));
}
}
11 changes: 5 additions & 6 deletions app/Http/Controllers/Dashboard/MetricController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use CachetHQ\Cachet\Models\MetricPoint;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;

class MetricController extends Controller
Expand Down Expand Up @@ -83,13 +82,13 @@ public function createMetricAction()
$metricData['threshold']
));
} catch (ValidationException $e) {
return Redirect::route('dashboard.metrics.add')
return cachet_route('dashboard.metrics.create')
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.metrics.add.failure')))
->withErrors($e->getMessageBag());
}

return Redirect::route('dashboard.metrics.index')
return cachet_route('dashboard.metrics')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.add.success')));
}

Expand All @@ -115,7 +114,7 @@ public function deleteMetricAction(Metric $metric)
{
dispatch(new RemoveMetricCommand($metric));

return Redirect::route('dashboard.metrics.index')
return cachet_route('dashboard.metrics')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.delete.success')));
}

Expand Down Expand Up @@ -156,13 +155,13 @@ public function editMetricAction(Metric $metric)
Binput::get('threshold', null, false)
));
} catch (ValidationException $e) {
return Redirect::route('dashboard.metrics.edit', ['id' => $metric->id])
return cachet_route('dashboard.metrics.edit', [$metric->id])
->withInput(Binput::all())
->withTitle(sprintf('<strong>%s</strong>', trans('dashboard.notifications.whoops')))
->withErrors($e->getMessageBag());
}

return Redirect::route('dashboard.metrics.edit', ['id' => $metric->id])
return cachet_route('dashboard.metrics.edit', [$metric->id])
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.edit.success')));
}
}
Loading

0 comments on commit 5a9f613

Please sign in to comment.