Skip to content

Commit

Permalink
start session before the preview route
Browse files Browse the repository at this point in the history
  • Loading branch information
themsaid committed Apr 21, 2016
1 parent 47baf86 commit 502e5e3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/MailPreviewServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function boot()

if ($this->app['config']['mailpreview.show_link_to_preview']) {
if (! $this->app->routesAreCached()) {
$this->app['router']->group(['middleware' => (array) $this->app['config']['mailpreview.middleware']], function ($router) {
$this->app['router']->group(['middleware' => $this->middleware()], function ($router) {
$router->get('/themsaid/mail-preview', function () {
if ($previewPath = $this->app['request']->input('path')) {
$content = file_get_contents(storage_path('email-previews/'.$previewPath.'.html'));
Expand Down Expand Up @@ -53,4 +53,17 @@ public function register()
__DIR__.'/config/mailpreview.php', 'mailpreview'
);
}

/**
* The array of middleware for the preview route.
*
* @return array
*/
private function middleware()
{
return array_merge(
(array) $this->app['config']['mailpreview.middleware'],
[\Illuminate\Session\Middleware\StartSession::class]
);
}
}

0 comments on commit 502e5e3

Please sign in to comment.