mstfkhzaal/filament-page-hints

为您的Filament页面创建提示,可作为用户指南。

v1.1 2023-04-13 14:57 UTC

This package is auto-updated.

Last update: 2024-09-13 18:23:21 UTC


README

Latest Version on Packagist Total Downloads

为您的Filament页面创建提示,可作为用户指南。您可以为每个页面创建提示,当用户点击它时,将打开侧边栏以查看页面提示。

安装

您可以通过composer安装此包

composer require discoverlance/filament-page-hints

快速入门

为了快速开始,您可以安装包配置、迁移,并可选地使用以下命令运行您的迁移

php artisan filament-page-hints:install

您可以使用以下命令发布和运行迁移

php artisan vendor:publish --tag="filament-page-hints-migrations"
php artisan migrate

可选地,您可以使用以下命令发布配置文件

php artisan vendor:publish --tag="filament-page-hints-config"

这是已发布的配置文件内容,查找设置不同表名、更新用于样式化提示功能部分图标和类的选项。

return [
    /**
     * Filament page table
     */
    'table_name' => 'filament_page_hints',
    /**
     * This is the icon of the hint button in the topbar
     */
    'hint_icon' => 'heroicon-o-question-mark-circle',

    /**
     * The class of the hint button can be changed here
     */
    'hint_class' => 'w-5 h-5 cursor-pointer text-gray-800 dark:text-white',

    /**
     * Creating or updating a hint button color can be changed here
     */
    'upsert_hint_button_color' => 'success',
    'delete_hint_button_color' => 'warning',

    /**
     * Use this option to control whether you want to show the page hint resource in the navigation.
     */
    'show_resource_in_navigation' => true,
    /**
     * Rich Text Editor used for hints toolbar buttons can be edited here.
     */
    'toolbar_buttons' => [
        'blockquote',
        'bold',
        'bulletList',
        'codeBlock',
        'h3',
        'italic',
        'link',
        'orderedList',
        'strike',
    ],
];

可选地,您可以使用以下命令发布视图

php artisan vendor:publish --tag="filament-page-hints-views"

可选地,您可以使用以下命令发布翻译

php artisan vendor:publish --tag="filament-page-hints-translations"

用法

要显示应用中的提示供用户访问,您至少需要发布您的迁移。您可以使用配置选项更改表名

'table_name' => 'filament_page_hints'

添加新提示

要添加新提示

  • 点击顶栏上的提示图标。
  • 点击新建提示
  • 填写表单以创建新的提示。

您可以在配置选项中更新用于提示的RichEditor组件的工具栏('toolbar_buttons' => [...]

编辑提示

要编辑提示

  • 点击顶栏上的提示图标。
  • 点击编辑提示
  • 进行更新并提交表单。

编辑提示

要删除提示

  • 点击顶栏上的提示图标。
  • 点击删除提示

使用页面提示填充和初始化数据库

作为一个方便的助手,您可以运行命令php artisan filament-page-hints:seeder,它将所有当前页面提示加载到种子类中,database\seeder\PageHintSeeder

注意:如果您在数据库提示中使用了引号,如单引号,您可能需要手动使用转义(/)来修复它。我找不到修复它的方法,因此目前即使addslashes也在添加双斜杠而不是单斜杠,因此请确保在生成种子类后,检查$allPageHints数组(json)以确保没有引号问题。

为提示操作添加权限

由于在filament管理面板中没有全局方法来分配权限,您可能正在使用filament-shield或不同的包来处理您的用户权限,因此目前这是一个处理此问题的建议方法

您可以在blade中完成大部分工作

// First publish the views _if you have not already done_ so with the command:
php artisan vendor:publish --tag="filament-page-hints-views"

以下是一个使用具有create_hints权限来限制创建操作的示例

// `views/vendor/filament-page-hints/components/modal/actions.blade.php`
// hide the create action
@can('create_hints')
    <div {{ $attributes }}>
        ... // other blade code here
    </div>
@endcan

// `views/vendor/filament-page-hints/page-hints.blade.php`
// also hide the create/edit modal
@can('create_hints')
    <x-filament::modal id="create-hint" width="xl">
        ... // other blade code here
    </x-filament::modal>
@endcan

如果您还想要隐藏编辑/删除操作,您可以在views/vendor/filament-page-hints/components/modal/index.blade.php中这样做

测试

composer test

变更日志

有关最近更改的更多信息,请参阅变更日志

贡献

有关详细信息,请参阅贡献指南

安全漏洞

有关如何报告安全漏洞的更多信息,请参阅我们的安全策略

鸣谢

许可证

MIT许可证(MIT)。有关更多信息,请参阅许可证文件