jeffbeltran / sanctum-tokens
A Laravel Nova resource tool for sanctum tokens.
Installs: 397 713
Dependents: 0
Suggesters: 0
Security: 0
Stars: 51
Watchers: 3
Forks: 29
Open Issues: 12
Language:Vue
Requires
- php: ^7.3|^8.0
- laravel/nova: ^4.0
Requires (Dev)
- laravel/pint: ^1.14
- dev-master
- v2.1.1
- v2.1.0
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.5.8
- v1.5.7
- v1.5.6
- v1.5.5
- v1.5.4
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.0
- v1.3.6
- v1.3.5
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.1
- v1.2.0
- v1.1.0
- v1.0.1
- v1.0.0
- dev-dependabot/npm_and_yarn/tar-6.2.1
- dev-dependabot/npm_and_yarn/express-4.19.2
- dev-dependabot/npm_and_yarn/webpack-dev-middleware-5.3.4
- dev-dependabot/npm_and_yarn/follow-redirects-1.15.6
This package is auto-updated.
Last update: 2025-01-11 16:53:28 UTC
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
- For Nova 4, use v2
- Nova 3, use v1
Installation
composer require jeffbeltran/sanctum-tokens
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 Jeffbeltran\SanctumTokens\SanctumTokens; /** * Get the fields displayed by the resource. * * @param \Illuminate\Http\Request $request * @return array */ public function fields(Request $request) { return [ ID::make('ID', 'id')->sortable(), ... 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 Jeffbeltran\SanctumTokens\SanctumTokens; /** * Get the fields displayed by the resource. * * @param \Illuminate\Http\Request $request * @return array */ public function fields(Request $request) { return [ ID::make('ID', 'id')->sortable(), ... 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 Jeffbeltran\SanctumTokens\SanctumTokens; /** * Get the fields displayed by the resource. * * @param \Illuminate\Http\Request $request * @return array */ public function fields(Request $request) { return [ ID::make('ID', 'id')->sortable(), ... SanctumTokens::make()->defaultAbilities(['foo', 'bar-baz']), ]; }
Localization
Publish the package language files to your application's resources/lang/vendor
directory:
php artisan vendor:publish --provider="Jeffbeltran\SanctumTokens\ToolServiceProvider"