Skip to content

Commit

Permalink
Merge pull request #17 from CasperLaiTW/fix-middleware-closure
Browse files Browse the repository at this point in the history
Fix controller middleware maybe is closure
  • Loading branch information
garygreen authored Nov 5, 2016
2 parents b67503f + ee2f5b1 commit 01401de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/MainMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ public function handle($request, Closure $next)
{
if ($request->is(config('pretty-routes.url')))
{
$middlewareClosure = function ($middleware) {
return $middleware instanceof Closure ? 'Closure' : $middleware;
};
return new Response(view('pretty-routes::routes', [
'routes' => Route::getRoutes(),
'middlewareClosure' => $middlewareClosure,
]));
}

Expand Down
2 changes: 1 addition & 1 deletion views/routes.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<td>{!! preg_replace('#(@.*)$#', '<span class="text-warning">$1</span>', $route->getActionName()) !!}</td>
<td>
@if (method_exists($route, 'controllerMiddleware'))
{{ implode(', ', array_merge($route->middleware(), $route->controllerMiddleware())) }}
{{ implode(', ', array_map($middlewareClosure, array_merge($route->middleware(), $route->controllerMiddleware()))) }}
@else
{{ implode(', ', $route->middleware()) }}
@endif
Expand Down

0 comments on commit 01401de

Please sign in to comment.