[4.x] Factor token last_used_at update into separate method#567
Merged
taylorotwell merged 3 commits intolaravel:4.xfrom Jun 26, 2025
Merged
[4.x] Factor token last_used_at update into separate method#567taylorotwell merged 3 commits intolaravel:4.xfrom
last_used_at update into separate method#567taylorotwell merged 3 commits intolaravel:4.xfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For apps that are high usage or perhaps just don't want the overhead of performing an UPDATE query on every API request, avoiding the update to
personal_access_tokens.last_used_atrequires extending the Guard class, but copying over the entirety of the__invoke()method.I was considering writing this to Redis or just not writing it at all, as we have app usage visibility in other places.
Other options:
TokenAuthenticatedevent. This separates concerns nicely, however, it could be a breaking change if userland listeners depend on the model being updated but events are now handled out of order. Definitely a minor concern in my eyes, but a possible risk nonetheless.PersonalAccessTokenlikeupdateLastUsed()and call that instead of the forceFill inside ofGuard@__invoke()In the app I'm work on, we've already extended the PersonalAccessToken. Here I might choose to write to Redis instead, or just make the function a no-op.Sanctumclass, akin to$personalAccessTokenModel,$accessTokenRetrievalCallback, etc.