discoverlance / filament-page-hints
为您的Filament页面创建提示,作为用户指南。
Requires
- php: ^8.1
- filament/filament: ^2.0
- illuminate/contracts: ^9.0
- spatie/laravel-package-tools: ^1.13.0
Requires (Dev)
- laravel-lang/attributes: ^2.0
- laravel-lang/lang: ^12.0
- laravel-lang/publisher: ^14.0
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- pestphp/pest-plugin-livewire: ^1.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-10-03 16:21:07 UTC
README
为您的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)。请参阅许可证文件获取更多信息。