vincent15000's avatar

Middleware to test something else than User

Hello,

Is it possible to use a middleware to test for example if the registrations are open for a game ?

if (! $game->registrationsAreOpen())
{
	return redirect()->...
}
return $next($request);

I have checked the documentation, but I do not understand how it could be possible to add a parameter like $game (which could be the game that is used at the moment in the code). It seems that the middleware can only use the $user variable to check something about the connected user.

Thanks for your answer.

Vincent

0 likes
2 replies
jlrdw's avatar
jlrdw
Best Answer
Level 75

You could even look that up (check the db) anywhere, including the controller method prior to loading any game, it's just a check. Why would you need middleware.

1 like
vincent15000's avatar

No specific need of middleware, but middlewares are very simple to use ;) ...

But it's true that middlewares are only used to test some users properties.

If it's not possible to use a middleware, I will use a policy ;).

Please or to participate in this conversation.