ferdiunal/nova-password-confirm-modal

管理数据可用性的 Laravel Nova 字段。

v1.0.4 2024-09-16 18:58 UTC

This package is auto-updated.

Last update: 2024-09-16 18:58:47 UTC


README

此 Laravel Nova 字段通过模态对话框要求密码确认来管理数据的可用性。

视频

Nova Password Confirm Modal

功能

  • 安全数据访问:确保敏感操作需要密码确认。
  • 与 Laravel Nova 集成:无缝集成到 Laravel Nova 面板中的字段。

安装

要安装此包,请在您的 Nova 项目中运行以下命令

composer require ferdiunal/nova-password-confirm-modal

用法

安装后,您可以将密码确认字段添加到您的 Nova 资源中,如下所示

代码示例
namespace App\Nova;

use Ferdiunal\NovaPasswordConfirmModal\NovaPasswordConfirmModal;
use Illuminate\Http\Request;
use Illuminate\Validation\Rules;
use Laravel\Nova\Fields\Gravatar;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;

class User extends Resource
{
    public static function permissionsForAbilities(): array
    {
        return Permissions::$users;
    }

    /**
     * The model the resource corresponds to.
     *
     * @var class-string<\App\Models\User>
     */
    public static $model = \App\Models\User::class;

    /**
     * The single value that should be used to represent the resource when being displayed.
     *
     * @var string
     */
    public static $title = 'name';

    /**
     * The columns that should be searched.
     *
     * @var array
     */
    public static $search = [
        'id', 'name', 'email',
    ];

    /**
     * Get the fields displayed by the resource.
     *
     * @return array
     */
    public function fields(NovaRequest $request)
    {
        return [
            ID::make()->sortable()->hideFromIndex(),
            Gravatar::make()->maxWidth(50),
            Text::make('Name')
                ->sortable()
                ->maxlength(255)
                ->enforceMaxlength()
                ->rules('required', 'max:255'),

            NovaPasswordConfirmModal::make('Passport Number', 'email')
                ->lockField()
                ->maskChar('#') //  Character to use for masking. (*,#,-,+)
                ->maskIndent(4, 3) // The number of characters to appear at the start or end of the data.
                ->countdown(3) // The data is masked back after the second you provide.,
        ];
    }

    /**
     * Get the cards available for the request.
     *
     * @return array
     */
    public function cards(NovaRequest $request)
    {
        return [];
    }

    /**
     * Get the filters available for the resource.
     *
     * @return array
     */
    public function filters(NovaRequest $request)
    {
        return [];
    }

    /**
     * Get the lenses available for the resource.
     *
     * @return array
     */
    public function lenses(NovaRequest $request)
    {
        return [];
    }

    /**
     * Get the actions available for the resource.
     *
     * @return array
     */
    public function actions(NovaRequest $request)
    {
        return [];
    }
}

许可证

本项目是开源软件,许可协议为 MIT 许可证

贡献

欢迎贡献,所有贡献者必须遵守项目的代码行为准则和许可条款。

支持

如需支持,请在 GitHub 存储库中创建一个问题。