I wanted to know if there is any option to use the middleware parameter like laravel.
To make a long story short:
So if you’ve done some authentication (AuthenticationMiddleware) and you pass to another one (i.e. AuthorizationMiddleware) you can simply:
$request = $request->withAttribute('user', ['whatever']);
and then within next middleware in chain:
$user = $request->getAttribute('user');
This is not what I am looking for.
I know the use of
attribute but I think that doesn’t satisfies my need.
Instead of one generic RoleMiddlware you could use add more specific role based middleware to the route groups, e.g.
The good thing is, they are autoload only on demand, and you could also combine them.
Yeah, I am using it and everything works fine but out of curiosity, just wanted to know if it is possible without making changes to the core framework.
I think this can be done just using the constructor method in the middleware class.