It sounds like it is a global middleware which doesn't have access to the route parameters.
Feb 3, 2016
1
Level 1
Lumen 5.2 - Middleware Route Parameters
Hi all,
I'm creating a new API using Lumen 5.2 and I'm having issues when trying to set up a middleware. I'll explain the situation. I have this route
$app->get('/company/{id}', 'CompanyController@show');
The controller is as simple as a Eloquent object with a find for the id parameter from the route. Now, what I want to do is set up a middleware so I can read that id and use it to check if the user logged in can access this company. I searched and I found that in Laravel you can do something like
$request->id;
But it doesn't work in Lumen. I also tried
$request->route()[2]['id']
as someone suggested here in StackOverflow but $request->route() returns null in the handle method of the middleware.
Any suggestions?
Thank you!!
Please or to participate in this conversation.