承接 karelvanzijl/sanctum-tokens 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

karelvanzijl/sanctum-tokens

最新稳定版本:v1.0.1

Composer 安装命令:

composer require karelvanzijl/sanctum-tokens

包简介

A Laravel Nova resource tool for sanctum tokens.

README 文档

README

This package allows you to use Sanctum to generate a Personal Access Tokens in Nova.

Screenshot

View without any tokens Create Token View Post Create Token View View with single token Revoke Token Prompt

Prerequisites

  1. Install and Configure Sanctum
  2. Have Laravel Nova
    • For Nova 4, use v2
    • Nova 3, use v1

Installation

composer require karelvanzijl/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 Karelvanzijl\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 Karelvanzijl\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 Karelvanzijl\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="Karelvanzijl\SanctumTokens\ToolServiceProvider"

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 39
  • 开发语言: Vue

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-22