Skip to content
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

[4.x] use method instead of array for casts on PersonalAccessToken #543

Closed
wants to merge 3 commits into from

Conversation

cosmastech
Copy link
Contributor

@cosmastech cosmastech commented Nov 13, 2024

I need to be able to add some additional columns to my personal_access_tokens table. This makes it possible that I can do the following:

class TeamworksToken extends PersonalAccessToken
{
    protected function casts()
    {
        return parent::casts() + ['is_impersonation' => 'bool'];
    }
}

@cosmastech
Copy link
Contributor Author

Taking a look at how https://github.com/laravel/framework/blob/a296e813d041ddff000d856aa2f7ae1cd4d616b7/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php#L196 is setup, for my use case, it wouldn't matter, since a casts() method on the child class would get merged in.

Possibly other people would want to manipulate the casts in a different way. 🤷

If you don't want to accept this PR because it's fine as is, I'll make a follow up to just add in the proper typehints on the model.

@taylorotwell
Copy link
Member

Since it's fine as is we can just do the type-hints PR.

@cosmastech cosmastech mentioned this pull request Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants