Skip to content

Commit

Permalink
Middleware 'public' set in routes service provider
Browse files Browse the repository at this point in the history
  • Loading branch information
sdebacker committed Jan 9, 2018
1 parent 6f4d36c commit dbcfeab
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ public function map()
* Front office routes
*/
if ($page = TypiCMS::getPageLinkedToModule('events')) {
$options = $page->private ? ['middleware' => 'auth'] : [];
foreach (locales() as $lang) {
if ($page->translate('status', $lang) && $uri = $page->uri($lang)) {
$router->get($uri, $options + ['uses' => 'PublicController@index'])->name($lang.'::index-events');
$router->get($uri.'/{slug}', $options + ['uses' => 'PublicController@show'])->name($lang.'::event');
$router->get($uri.'/{slug}/ics', $options + ['uses' => 'PublicController@ics'])->name($lang.'::event-ics');
$router->middleware('public')->group(function (Router $router) use ($page) {
$options = $page->private ? ['middleware' => 'auth'] : [];
foreach (locales() as $lang) {
if ($page->translate('status', $lang) && $uri = $page->uri($lang)) {
$router->get($uri, $options + ['uses' => 'PublicController@index'])->name($lang.'::index-events');
$router->get($uri.'/{slug}', $options + ['uses' => 'PublicController@show'])->name($lang.'::event');
$router->get($uri.'/{slug}/ics', $options + ['uses' => 'PublicController@ics'])->name($lang.'::event-ics');
}
}
}
});
}

/*
Expand Down

0 comments on commit dbcfeab

Please sign in to comment.