F
Filament7mo ago
Nicole

Generate API Token within admin panel

As admin I would like to be able create or generate api toke via admin panel
10 Replies
toeknee
toeknee7mo ago
Just build a resource to generate them.
Nicole
NicoleOP7mo ago
What resource should I create?
toeknee
toeknee7mo ago
The one to interact with your tokens table...
Nicole
NicoleOP7mo ago
Is it the personal_access_tokens table, Sir?
toeknee
toeknee7mo ago
So build a new Resource for the EPRsonal Access Tokens, or add personal access tokens as a relationship on the users resource if you have created one.
Nicole
NicoleOP7mo ago
Can I create a resource with different name, let say "API Tokens" but the class I will be using is user? Because I already have resource for my user and I don't want to merge them, I want them in a separate resource.
awcodes
awcodes7mo ago
you can tell the resource what model to use
protected static ?string $model = User::class;
protected static ?string $model = User::class;
toeknee
toeknee7mo ago
Are your tokens attached to the user model or as a relationship of the user model?
Nicole
NicoleOP7mo ago
I am using laravel sanctum so I believe it is attached to user Or do you think better to use the personal_access_tokens instead?
toeknee
toeknee7mo ago
Fairly sure they have their own tokens table and it’s not part of the user table. Accessed via the trait
Want results from more Discord servers?
Add your server