This sounds like a good use-case for using the cache. I'd create a SecurityTokenService class with a single getToken method. This method would do the following:
Check the cache for an existing token (which will automatically be false if the expiration time has passed)
If no token is found, generate a new token and store it in the cache
Return the token
The only downside is that the token will be reset whenever you use the cache:clear command.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community