Skip to content

Commit 5a9f613

Browse files
committed
Completely refactor all routes
1 parent 446e428 commit 5a9f613

File tree

90 files changed

+486
-341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+486
-341
lines changed

app/Bus/Handlers/Events/Component/SendComponentUpdateEmailNotificationHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function notify(Component $component, Subscriber $subscriber)
105105
];
106106

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

110110
$this->mailer->queue([
111111
'html' => 'emails.components.update-html',

app/Bus/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ public function notify(IncidentWasReportedEvent $event, $subscriber)
119119
'html_content' => $incident->formattedMessage,
120120
'text_content' => $incident->message,
121121
'token' => $subscriber->token,
122-
'manage_link' => route('subscribe.manage', ['code' => $subscriber->verify_code]),
123-
'unsubscribe_link' => route('subscribe.unsubscribe', ['code' => $subscriber->verify_code]),
122+
'manage_link' => cachet_route('subscribe.manage', [$subscriber->verify_code]),
123+
'unsubscribe_link' => cachet_route('subscribe.unsubscribe', [$subscriber->verify_code]),
124124
];
125125

126126
$this->mailer->queue([

app/Bus/Handlers/Events/Incident/SendMaintenanceEmailNotificationHandler.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ public function notify(MaintenanceWasScheduledEvent $event, $subscriber)
116116
'html_content' => $incident->formattedMessage,
117117
'text_content' => $incident->message,
118118
'token' => $subscriber->token,
119-
'manage_link' => route('subscribe.manage', ['code' => $subscriber->verify_code]),
120-
'unsubscribe_link' => route('subscribe.unsubscribe', ['code' => $subscriber->verify_code]),
119+
'manage_link' => cachet_route('subscribe.manage', [$subscriber->verify_code]),
120+
'unsubscribe_link' => cachet_route('subscribe.unsubscribe', [$subscriber->verify_code]),
121121
];
122122

123123
$this->mailer->queue([

app/Bus/Handlers/Events/User/SendInviteUserEmailHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function handle(UserWasInvitedEvent $event)
4848
$mail = [
4949
'email' => $event->invite->email,
5050
'subject' => 'You have been invited.',
51-
'link' => route('signup.invite', ['code' => $event->invite->code]),
51+
'link' => cachet_route('signup.invite', [$event->invite->code]),
5252
];
5353

5454
$this->mailer->queue([

app/Foundation/Providers/RouteServiceProvider.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
1515
use Illuminate\Routing\Router;
1616

17+
/**
18+
* This is the route service provider.
19+
*
20+
* @author James Brooks <james@alt-three.com>
21+
* @author Joseph Cohen <joe@alt-three.com>
22+
* @author Graham Campbell <graham@alt-three.com>
23+
*/
1724
class RouteServiceProvider extends ServiceProvider
1825
{
1926
/**
@@ -67,7 +74,7 @@ protected function registerBindings()
6774
*/
6875
public function map(Router $router)
6976
{
70-
$router->group(['namespace' => $this->namespace], function (Router $router) {
77+
$router->group(['namespace' => $this->namespace, 'as' => 'core::'], function (Router $router) {
7178
$path = app_path('Http/Routes');
7279

7380
foreach (glob("{$path}/*{,/*}.php", GLOB_BRACE) as $file) {

app/Http/Controllers/AuthController.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@ public function postLogin()
5858
if (Auth::user()->hasTwoFactor) {
5959
Session::put('2fa_id', Auth::user()->id);
6060

61-
return Redirect::route('auth.two-factor');
61+
return cachet_route('auth.two-factor');
6262
}
6363

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

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

68-
return Redirect::intended('dashboard');
68+
return Redirect::intended(cachet_route('dashboard'));
6969
}
7070

71-
return Redirect::route('auth.login')
71+
return cachet_route('auth.login')
7272
->withInput(Binput::except('password'))
7373
->withError(trans('forms.login.invalid'));
7474
}
@@ -113,11 +113,11 @@ public function postTwoFactor()
113113
// Failed login, log back out.
114114
Auth::logout();
115115

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

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

123123
/**

app/Http/Controllers/Dashboard/ComponentController.php

+12-13
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use CachetHQ\Cachet\Models\Tag;
2424
use GrahamCampbell\Binput\Facades\Binput;
2525
use Illuminate\Routing\Controller;
26-
use Illuminate\Support\Facades\Redirect;
2726
use Illuminate\Support\Facades\View;
2827

2928
class ComponentController extends Controller
@@ -45,13 +44,13 @@ public function __construct()
4544
$this->subMenu = [
4645
'components' => [
4746
'title' => trans('dashboard.components.components'),
48-
'url' => route('dashboard.components.index'),
47+
'url' => cachet_route('dashboard.components'),
4948
'icon' => 'ion-ios-browsers',
5049
'active' => false,
5150
],
5251
'groups' => [
5352
'title' => trans_choice('dashboard.components.groups.groups', 2),
54-
'url' => route('dashboard.components.groups'),
53+
'url' => cachet_route('dashboard.components.groups'),
5554
'icon' => 'ion-folder',
5655
'active' => false,
5756
],
@@ -138,7 +137,7 @@ public function updateComponentAction(Component $component)
138137
$componentData['enabled']
139138
));
140139
} catch (ValidationException $e) {
141-
return Redirect::route('dashboard.components.edit', ['id' => $component->id])
140+
return cachet_route('dashboard.components.edit', [$component->id])
142141
->withInput(Binput::all())
143142
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.edit.failure')))
144143
->withErrors($e->getMessageBag());
@@ -154,7 +153,7 @@ public function updateComponentAction(Component $component)
154153

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

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

@@ -191,7 +190,7 @@ public function createComponentAction()
191190
$componentData['enabled']
192191
));
193192
} catch (ValidationException $e) {
194-
return Redirect::route('dashboard.components.add')
193+
return cachet_route('dashboard.components.create')
195194
->withInput(Binput::all())
196195
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.add.failure')))
197196
->withErrors($e->getMessageBag());
@@ -207,7 +206,7 @@ public function createComponentAction()
207206

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

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

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

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

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

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

@@ -281,13 +280,13 @@ public function postAddComponentGroup()
281280
Binput::get('visible')
282281
));
283282
} catch (ValidationException $e) {
284-
return Redirect::route('dashboard.components.groups.add')
283+
return cachet_route('dashboard.components.groups.create')
285284
->withInput(Binput::all())
286285
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.groups.add.failure')))
287286
->withErrors($e->getMessageBag());
288287
}
289288

290-
return Redirect::route('dashboard.components.groups')
289+
return cachet_route('dashboard.components.groups')
291290
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.groups.add.success')));
292291
}
293292

@@ -309,13 +308,13 @@ public function updateComponentGroupAction(ComponentGroup $group)
309308
Binput::get('visible')
310309
));
311310
} catch (ValidationException $e) {
312-
return Redirect::route('dashboard.components.groups.edit', ['id' => $group->id])
311+
return cachet_route('dashboard.components.groups.edit', [$group->id])
313312
->withInput(Binput::all())
314313
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.groups.edit.failure')))
315314
->withErrors($e->getMessageBag());
316315
}
317316

318-
return Redirect::route('dashboard.components.groups.edit', ['id' => $group->id])
317+
return cachet_route('dashboard.components.groups.edit', [$group->id])
319318
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.groups.edit.success')));
320319
}
321320
}

app/Http/Controllers/Dashboard/DashboardController.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use Illuminate\Routing\Controller;
2222
use Illuminate\Support\Facades\Auth;
2323
use Illuminate\Support\Facades\Config;
24-
use Illuminate\Support\Facades\Redirect;
2524
use Illuminate\Support\Facades\View;
2625
use Jenssegers\Date\Date;
2726

@@ -83,7 +82,7 @@ public function __construct(Feed $feed, Guard $guard)
8382
*/
8483
public function redirectAdmin()
8584
{
86-
return Redirect::route('dashboard.index');
85+
return cachet_route('dashboard');
8786
}
8887

8988
/**

app/Http/Controllers/Dashboard/IncidentController.php

+14-15
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use GrahamCampbell\Binput\Facades\Binput;
2424
use Illuminate\Contracts\Auth\Guard;
2525
use Illuminate\Routing\Controller;
26-
use Illuminate\Support\Facades\Redirect;
2726
use Illuminate\Support\Facades\View;
2827

2928
/**
@@ -61,13 +60,13 @@ public function __construct(Guard $auth)
6160
$this->subMenu = [
6261
'incidents' => [
6362
'title' => trans('dashboard.incidents.incidents'),
64-
'url' => route('dashboard.incidents.index'),
63+
'url' => cachet_route('dashboard.incidents'),
6564
'icon' => 'ion-android-checkmark-circle',
6665
'active' => true,
6766
],
6867
'schedule' => [
6968
'title' => trans('dashboard.schedule.schedule'),
70-
'url' => route('dashboard.schedule.index'),
69+
'url' => cachet_route('dashboard.schedule'),
7170
'icon' => 'ion-android-calendar',
7271
'active' => false,
7372
],
@@ -139,13 +138,13 @@ public function createIncidentAction()
139138
null
140139
));
141140
} catch (ValidationException $e) {
142-
return Redirect::route('dashboard.incidents.add')
141+
return cachet_route('dashboard.incidents.create')
143142
->withInput(Binput::all())
144143
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.add.failure')))
145144
->withErrors($e->getMessageBag());
146145
}
147146

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

@@ -185,7 +184,7 @@ public function deleteTemplateAction(IncidentTemplate $template)
185184
{
186185
$template->delete();
187186

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

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

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

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

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

@@ -265,7 +264,7 @@ public function editIncidentAction(Incident $incident)
265264
null
266265
));
267266
} catch (ValidationException $e) {
268-
return Redirect::route('dashboard.incidents.edit', ['id' => $incident->id])
267+
return cachet_route('dashboard.incidents.edit', ['id' => $incident->id])
269268
->withInput(Binput::all())
270269
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure')))
271270
->withErrors($e->getMessageBag());
@@ -275,7 +274,7 @@ public function editIncidentAction(Incident $incident)
275274
$incident->component->update(['status' => Binput::get('component_status')]);
276275
}
277276

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

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

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

@@ -329,13 +328,13 @@ public function createIncidentUpdateAction(Incident $incident)
329328
$this->auth->user()
330329
));
331330
} catch (ValidationException $e) {
332-
return Redirect::route('dashboard.incidents.update', ['id' => $incident->id])
331+
return cachet_route('dashboard.incidents.update', ['id' => $incident->id])
333332
->withInput(Binput::all())
334333
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure')))
335334
->withErrors($e->getMessageBag());
336335
}
337336

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

app/Http/Controllers/Dashboard/MetricController.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use CachetHQ\Cachet\Models\MetricPoint;
2020
use GrahamCampbell\Binput\Facades\Binput;
2121
use Illuminate\Routing\Controller;
22-
use Illuminate\Support\Facades\Redirect;
2322
use Illuminate\Support\Facades\View;
2423

2524
class MetricController extends Controller
@@ -83,13 +82,13 @@ public function createMetricAction()
8382
$metricData['threshold']
8483
));
8584
} catch (ValidationException $e) {
86-
return Redirect::route('dashboard.metrics.add')
85+
return cachet_route('dashboard.metrics.create')
8786
->withInput(Binput::all())
8887
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.metrics.add.failure')))
8988
->withErrors($e->getMessageBag());
9089
}
9190

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

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

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

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

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

0 commit comments

Comments
 (0)