Skip to content

Commit 4e236c2

Browse files
committed
add to docs
1 parent 8accaf4 commit 4e236c2

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

middleware.md

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ This command will place a new `CheckAge` class within your `app/Http/Middleware`
5050

5151
return $next($request);
5252
}
53-
5453
}
5554

5655
As you can see, if the given `age` is less than or equal to `200`, the middleware will return an HTTP redirect to the client; otherwise, the request will be passed further into the application. To pass the request deeper into the application (allowing the middleware to "pass"), simply call the `$next` callback with the `$request`.

routing.md

+20
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,26 @@ If the named route defines parameters, you may pass the parameters as the second
170170

171171
$url = route('profile', ['id' => 1]);
172172

173+
#### Inspecting The Current Route
174+
175+
If you would like to determine if the current request was routed to a given named route, you may use the `named` method on a Route instance. For example, you may check the current route name from a route middleware:
176+
177+
/**
178+
* Handle an incoming request.
179+
*
180+
* @param \Illuminate\Http\Request $request
181+
* @param \Closure $next
182+
* @return mixed
183+
*/
184+
public function handle($request, Closure $next)
185+
{
186+
if ($request->route()->named('profile')) {
187+
//
188+
}
189+
190+
return $next($request);
191+
}
192+
173193
<a name="route-groups"></a>
174194
## Route Groups
175195

0 commit comments

Comments
 (0)