F
Filament6mo 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
toeknee6mo ago
Just build a resource to generate them.
Nicole
NicoleOP6mo ago
What resource should I create?
toeknee
toeknee6mo ago
The one to interact with your tokens table...
Nicole
NicoleOP6mo ago
Is it the personal_access_tokens table, Sir?
toeknee
toeknee6mo 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
NicoleOP6mo 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
awcodes6mo ago
you can tell the resource what model to use
protected static ?string $model = User::class;
protected static ?string $model = User::class;
toeknee
toeknee6mo ago
Are your tokens attached to the user model or as a relationship of the user model?
Nicole
NicoleOP6mo 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
toeknee6mo 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