metasync-site / sanctum-tokens
A Laravel Nova resource tool for sanctum tokens.
Installs: 549
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Language:Vue
Requires
- php: ^8.1|^8.2|^8.3|^8.4
- laravel/nova: ^4.0|^5.0
Requires (Dev)
- laravel/pint: ^1.14
README
This package allows you to use Sanctum to generate a Personal Access Tokens in Nova.
Screenshot
Prerequisites
- Install and Configure Sanctum
- Have Laravel Nova
- Support - Nova 4.x | Nova 5.x
- Laravel 10.x | 11.x | 12.x
Installation
composer require metasync-site/sanctum-tokens
php artisan vendor:publish --provider="MetasyncSite\SanctumTokens\ToolServiceProvider" --tag="sanctum-tokens-migrations"
php artisan migrate
Register the plugin by adding SanctumTokens::make()
to the array of fields in the Nova resource. Make sure the
HasApiTokens
trait from the Sanctum package has been added to your model.
use MetasyncSite\SanctumTokens\SanctumTokens; public function fields(Request $request) { return [ SanctumTokens::make(), ]; }
Features
Hide Abilities
You can hide the reference to the token abilities from the UI by calling the hideAbilities()
method on the field.
use MetasyncSite\SanctumTokens\SanctumTokens; public function fields(Request $request) { return [ SanctumTokens::make()->hideAbilities(), ]; }
Set Default Abilities
If you don't want to use the default *
token ability you can set your own by simply passing an array of strings to the defaultAbilities()
method on the field.
This works well with the the hideAbilities()
method if you want to hide the abilities logic from your users.
use MetasyncSite\SanctumTokens\SanctumTokens; public function fields(Request $request) { return [ SanctumTokens::make()->defaultAbilities(['crm', 'cms']), ]; }
Localization
Publish the package language files to your application's resources/lang/vendor
directory: