Reputation: 665
At the moment I have to check if job record, which is being edited, belongs to right person. My get job edit route:
/user/job-edit/{slug}
So I created JobEditMiddleware
but the problems is I can't access {slug}
variable in my middlewar. Is there any way to do it? Thanks.
Upvotes: 0
Views: 105
Reputation: 740
You can access to your slug parameter easier.
public function handle($request, Closure $next, $role) {
//
}
You have to call your slug parameter like this :
$request->slug;
I think it's a better way than segment if you'll need to change your route later.
Upvotes: 1
Reputation: 10330
You can use segment()
method to retrieve various segments of your URI.
Try following in your middleware,
\Request::segment(3)
Upvotes: 4