-
Notifications
You must be signed in to change notification settings - Fork 783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$timestamps = false is set as default on Token model #786
Comments
Re: #787 (@taylorotwell)
As this is a small change, I don't see a reason why the existing tests won't cover this change. However, the other questions seem useful to answer as I'm working with Laravel Nova and it requires the fields to be cast to So, I looked up the commit history, and the first ever version of the That presumably was done to keep all tables synchronized on creation instead of a possible 1 second delay on a loaded server creating datetime discrepancies. However, the fact that Passport can still manually set those fields on creation keeps that concept intact, thus getting rid of any possible "breaking" changes. I believe that answers Taylors original request.
|
@rickmacgillis hmm I'm actually not sure why it can't be enabled. I get that token records shouldn't update but at the same time it takes away functionality like @justinasposiunas described above. I'll mark this for review so @taylorotwell can have a look and perhaps tell us why this is done in this way. |
Perhaps the better way is to add This way it doesn't interfere with how the Tokens' timestamps are created and updated, but we can still use them as dates without having to create Carbon instances every time. |
PR was attempted here: #1075 I'll take a look at this somewhere this month. |
After looking into this again I agree with @rickmacgillis that this isn't necessary because the timestamps are indeed getting set manually. If you still want to customize this behavior you can override the model with https://laravel.com/docs/6.x/passport#overriding-default-models |
I have created the index page for personal access tokens in my application and tried to output the time every record was created like this
$token->created_at->diffForHumans()
since I expect thatcreated_at
andupdated_at
should be mutated to Carbon instances like documented. But it requires$timestamps = true
at first so those fields will be mutated:https://github.com/laravel/framework/blob/16983a689d15333e7101457c3e0c0d0b7da01d69/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php#L803-L810
Token
model with current$timestamps = false
value:passport/src/Token.php
Line 54 in 86af026
Migration for
access_tokens
table implies that table has timestamps:passport/database/migrations/2016_06_01_000002_create_oauth_access_tokens_table.php
Line 23 in 3492cc0
It is a very quick fix and I will make a PR easily but I am aware that maybe it has a purpose by setting
$timestamps
to false.The text was updated successfully, but these errors were encountered: